예제 #1
0
def Translation_analytical_raypath(
    velocity_translation=2.01 * 1221.0 / 1.0e6, direction=positions.CartesianPoint(1, 0, 0)
):

    # Initialize map
    m, fig = plot_data.setting_map()
    cm = plt.cm.get_cmap("RdYlBu")

    # seismic data set (from Lauren's file)
    data_points = read_write.read_from_file(
        "results.dat",
        slices=[
            "PKIKP-PKiKP travel time residual",
            "turn lat",
            "turn lon",
            "turn depth",
            "in lat",
            "in lon",
            "out lat",
            "out lon",
        ],
    )
    nlines, ncolumns = data_points.shape
    print data_points.info

    # translate it in the correct format
    dataset = []
    translation_dataset = []
    phi, theta, age, dt = [], [], [], []
    print nlines, "points to write."
    for i in range(nlines):
        if i % 100 == 0:  # print every 100 values
            print "Writing point ", i, ". Coordinates: ", data_points.ix[i]
        # because it's analytical solution, we don't need to define a grid. model is calulated exactly.
        translation_dataset.append(
            geodynamic.Translation(
                positions.SeismoPoint(
                    1221.0 - data_points.ix[i, "turn depth"],
                    data_points.ix[i, "turn lat"],
                    data_points.ix[i, "turn lon"],
                )
            )
        )
        translation_dataset[i].analytical(velocity_translation, direction)

        phi.append(translation_dataset[i].initial_position.phi)
        theta.append(translation_dataset[i].initial_position.theta)
        age.append(translation_dataset[i].exact_solution)

    x, y = m(phi, theta)
    m.scatter(x, y, c=age, zorder=10, cmap=plt.cm.RdYlGn)
    m.colorbar()

    fig, ax = plt.subplots()
    ax.plot(phi, age / max(age), ".")
    dt = data_points["PKIKP-PKiKP travel time residual"]
    print dt.shape
    ax.plot(phi, dt, ".r")

    plt.show()
예제 #2
0
    def map_plot(self, geodyn_model=''):
        """ plot data on a map."""
        # user should plot on map in the main code.

        m, fig = plot_data.setting_map()
        colormap = plt.cm.get_cmap('RdYlBu')
        _, theta, phi = self.extract_rtp("bottom_turning_point")
        x, y = m(phi, theta)
        proxy = np.array([self.proxy]).T.astype(float)
        sc = m.scatter(x, y, c=proxy, zorder=10, cmap=colormap)

        # TO DO : make a function to plot great circles correctly!
        #r1, theta1, phi1 = self.extract_in() #use extract_rtp()
        #r2, theta2, phi2 = self.extract_out()
        # for i, t in enumerate(theta1):
        #    z, w = m.gcpoints(phi1[i], theta1[i], phi2[i], theta2[i], 200)#
        #    m.plot(z, w, zorder=5, c="black")
        #    m.drawgreatcircle(phi1[i], theta1[i], phi2[i], theta2[i], zorder=5, c="black")
        title = "Dataset: {},\n geodynamic model: {}".format(
            self.name, geodyn_model)
        plt.title(title)
        plt.colorbar(sc)
data_set_random.method = "bt_point"

proxy_random = geodyn.evaluate_proxy(data_set_random, geodynModel, verbose=False)
r, t, p = data_set_random.extract_rtp("bottom_turning_point")
dist = positions.angular_distance_to_point(t, p, *velocity_center)


#data_set_random.map_plot(geodynModel.name)
#data_set_random.phi_plot(geodynModel.name)
#data_set_random.distance_plot(geodynModel.name, positions.SeismoPoint(1., 0., -80.)) 


# In[7]:

## map
m, fig = plot_data.setting_map() 
cm = plt.cm.get_cmap('RdYlBu')
x, y = m(p, t)
sc = m.scatter(x, y, c=proxy_random, zorder=10, cmap=cm)
plt.title("Dataset: {},\n geodynamic model: {}".format(data_set_random.name, geodynModel.name))
plt.colorbar(sc)


# In[8]:

## phi and distance plots
fig, ax = plt.subplots(1,2, sharey=True)
cm2 = plt.cm.get_cmap('winter')
sc1 = ax[0].scatter(p, proxy_random, c=abs(t), cmap=cm2, vmin =-0, vmax =90)
ax[0].set_xlabel("longitude")
ax[0].set_ylabel("age (Myears)")