Esempio n. 1
0
    def addtoplot(self, plot, properties, colors=None, customlabels=None):

        # Check that plot is a Plot
        if not isinstance(plot, Plot):
            raise TypeError("Plot must be an instance of the class Plot.")

        # Get the material properties.
        self.getplotvals()

        max_x = 0
        yvals = []

        for i in xrange(self.startingpoint.depth, self.todepth + 1,
                        self.spacing):
            yvals.append(i)

        if customlabels != None and "vp" in properties:
            vplabel = customlabels["vp"]
        else:
            vplabel = "Vp (km/s)"

        if customlabels != None and "vs" in properties:
            vslabel = customlabels["vs"]
        else:
            vslabel = "Vs (km/s)"

        if customlabels != None and "density" in properties:
            densitylabel = customlabels["density"]
        else:
            densitylabel = "Density (g/cm^3)"

        if colors != None and "vp" in properties:
            vpcolor = colors["vp"]
        else:
            vpcolor = "r"

        if colors != None and "vs" in properties:
            vscolor = colors["vs"]
        else:
            vscolor = "b"

        if colors != None and "density" in properties:
            densitycolor = colors["density"]
        else:
            densitycolor = "g"

        if "vp" in properties:
            max_x = max(max_x, max(self.vplist))
            plot.addsubplot().plot(self.vplist,
                                   yvals,
                                   "-",
                                   color=vpcolor,
                                   label=vplabel)
        if "vs" in properties:
            max_x = max(max_x, max(self.vslist))
            plot.addsubplot().plot(self.vslist,
                                   yvals,
                                   "-",
                                   color=vscolor,
                                   label=vslabel)
        if "density" in properties:
            max_x = max(max_x, max(self.rholist))
            plot.addsubplot().plot(self.rholist,
                                   yvals,
                                   "-",
                                   color=densitycolor,
                                   label=densitylabel)

        plt.legend(loc="lower left")

        if plt.ylim()[0] < plt.ylim()[1]:
            plt.gca().invert_yaxis()

        if max_x > plt.xlim()[1]:
            plt.xlim(0, math.ceil(max_x / 0.5) * 0.5)
Esempio n. 2
0
    def addtoplot(self, plot, colors=None, customlabels=None):
        # defaults:
        # colors={"vs":"b","vp":"y","density":"g"}
        # customlabels={"vs":"Vs (km/s)","vp":"Vp (km/s)","density":"Density (g/cm^3)"}

        # Check that plot is a Plot
        if not isinstance(plot, Plot):
            raise TypeError("Plot must be an instance of the class Plot.")

        # Get the material properties.
        self.getplotvals()

        max_x = 0
        yvals = []

        toto = self.toelevation
        if (toto <= 0):
            toto = toto - 1
        else:
            toto = toto + 1

        for i in xrange(int(self.startelevation), int(toto),
                        int(self.spacing)):
            yvals.append(i)

        if customlabels != None and "vp" in self.properties:
            vplabel = customlabels["vp"]
        else:
            vplabel = "Vp (km/s)"

        if customlabels != None and "vs" in self.properties:
            vslabel = customlabels["vs"]
        else:
            vslabel = "Vs (km/s)"

        if customlabels != None and "density" in self.properties:
            densitylabel = customlabels["density"]
        else:
            densitylabel = "Density (g/cm^3)"

        if colors != None and "vp" in self.properties:
            vpcolor = colors["vp"]
        else:
            vpcolor = "r"

        if colors != None and "vs" in self.properties:
            vscolor = colors["vs"]
        else:
            vscolor = "b"

        if colors != None and "density" in self.properties:
            densitycolor = colors["density"]
        else:
            densitycolor = "g"

        if "vp" in self.properties:
            myInt = 1000
            newvplist = np.array(self.vplist) / myInt
            max_x = max(max_x, max(newvplist))
            plot.addsubplot().plot(newvplist,
                                   yvals,
                                   "-",
                                   color=vpcolor,
                                   label=vplabel)

        if "vs" in self.properties:
            myInt = 1000
            newvslist = np.array(self.vslist) / myInt
            max_x = max(max_x, max(newvslist))
            plot.addsubplot().plot(newvslist,
                                   yvals,
                                   "-",
                                   color=vscolor,
                                   label=vslabel)

            ## attempted to draw a smoothed line, not good
            ##            xs=np.array(self.vslist)
            ##            ys=np.array(yvals)
            ##            # spline parameters
            ##            s=3.0 # smoothness parameter
            ##            k=2 # spline order
            ##            nest=-1 # estimate of number of knots needed (-1 = maximal)
            ##            # find the knot points
            ##            tckp,u = splprep([xs,ys],s=s,k=k,nest=nest)
            ##            # evaluate spline, including interpolated points
            ##            newx,newy = splev(np.linspace(0,1,500),tckp)
            ##            plot.addsubplot().plot(newx, newy, "b-", label="smoothed"+vslabel)
            ## add a vline if there is a vs threshold
            if self.threshold != None:
                plot.addsubplot().axvline(self.threshold / 1000,
                                          color='k',
                                          linestyle='dashed')

        self.elevationlist = yvals

        if "density" in self.properties:
            myInt = 1000
            newrholist = np.array(self.rholist) / myInt
            max_x = max(max_x, max(newrholist))
            plot.addsubplot().plot(newrholist,
                                   yvals,
                                   "-",
                                   color=densitycolor,
                                   label=densitylabel)

        plt.legend(loc="lower left")

        if plt.ylim()[0] < plt.ylim()[1]:
            plt.gca().invert_yaxis()

        if max_x > plt.xlim()[1]:
            plt.xlim(0, math.ceil(max_x / 0.5) * 0.5)

        plt.axis([0, max_x, int(self.toelevation), int(self.startelevation)])