Exemplo n.º 1
0
    def __init__(self, **kwargs):
        """
        Initialise the object
        :param kwargs: keyword-value pairs
        """
        super(PlotResPhaseMaps, self).__init__(**kwargs)

        self._logger = MtPyLog.get_mtpy_logger(self.__class__.__name__)

        fn_list = kwargs.pop('fn_list', [])

        if(len(fn_list)==0): raise NameError('File list is empty.')

        # ----set attributes for the class-------------------------
        self.mt_list = mtpl.get_mtlist(fn_list=fn_list)

        # read in map scale
        self.mapscale = kwargs.pop('mapscale', 'deg')
        if self.mapscale == 'km':
            self.dscale = 1000.
        elif self.mapscale == 'm':
            self.dscale = 1.
        # end if

        self.plot_title = kwargs.pop('plot_title', None)
        self.fig_dpi = kwargs.pop('fig_dpi', 100)

        self.fig_size = kwargs.pop('fig_size', [8, 6])

        self.font_size = kwargs.pop('font_size', 7)

        self.plot_yn = kwargs.pop('plot_yn', 'y')
        self.save_fn = kwargs.pop('save_fn', "/c/tmp")

        # By this stage all keyword arguments meant to be set as class properties will have
        # been processed. Popping all class properties that still exist in kwargs
        self.kwargs = kwargs
        for key in vars(self):
            self.kwargs.pop(key, None)

        self.axesList = []
Exemplo n.º 2
0
    def __init__(self, fn_list1, fn_list2, **kwargs):
        assert len(fn_list1) == len(fn_list2)
        self.fn_list1 = fn_list1
        self.fn_list2 = fn_list2

        self.mt_list1 = mtpl.get_mtlist(fn_list=fn_list1)
        self.mt_list2 = mtpl.get_mtlist(fn_list=fn_list2)

        self.residual_pt_list = []
        self.freq_list = None
        self.rpt_array = None
        self.med_filt_kernel = kwargs.pop('med_filt_kernel', None)
        self.rot90 = kwargs.pop('rot90', True)

        #--> set the ellipse properties
        self._ellipse_dict = kwargs.pop('ellipse_dict', {
            'cmap': 'mt_yl2rd',
            'range': (0, 10),
            'colorby': 'geometric_mean'
        })
        self._read_ellipse_dict()
        self.ellipse_scale = kwargs.pop('ellipse_scale', 10)

        #--> set colorbar properties---------------------------------
        #set orientation to horizontal
        cb_dict = kwargs.pop('cb_dict', {})
        try:
            self.cb_orientation = cb_dict['orientation']
        except KeyError:
            self.cb_orientation = 'vertical'

        #set the position to middle outside the plot
        try:
            self.cb_position = cb_dict['position']
        except KeyError:
            self.cb_position = None

        #--> set plot properties ------------------------------
        self.fig_num = kwargs.pop('fig_num', 'residual_PT')
        self.plot_title = kwargs.pop('plot_title', None)
        self.fig_dpi = kwargs.pop('fig_dpi', 300)
        self.tscale = kwargs.pop('tscale', 'period')
        self.fig_size = kwargs.pop('fig_size', [6, 6])
        self.linedir = kwargs.pop('linedir', 'ew')
        self.font_size = kwargs.pop('font_size', 7)
        self.station_id = kwargs.pop('station_id', [0, 4])
        self.ystep = kwargs.pop('ystep', 4)
        self.xstep = kwargs.pop('xstep', 1)
        self.xlimits = kwargs.pop('xlimits', None)
        self.ylimits = kwargs.pop('ylimits', None)

        #--> set spacing of plot
        self.subplot_wspace = .1
        self.subplot_hspace = .15
        self.subplot_right = .98
        self.subplot_left = .085
        self.subplot_top = .93
        self.subplot_bottom = .1

        #set the stretching in each direction
        self.xstretch = kwargs.pop('xstretch', 1000)
        self.ystretch = kwargs.pop('ystretch', 25)

        #if rotation angle is an int or float make an array the length of
        #mt_list for plotting purposes

        self._rot_z = kwargs.pop('rot_z', 0)
        if type(self._rot_z) is float or type(self._rot_z) is int:
            self._rot_z = np.array([self._rot_z] * len(self.mt_list1))

        #if the rotation angle is an array for rotation of different
        #freq than repeat that rotation array to the len(mt_list)
        elif type(self._rot_z) is np.ndarray:
            if self._rot_z.shape[0] != len(self.mt_list1):
                self._rot_z = np.repeat(self._rot_z, len(self.mt_list1))

        else:
            pass

        #--> set station name properties
        station_dict = kwargs.pop('station_dict', {})
        self.station_id = station_dict.pop('id', self.station_id)
        self.station_pad = station_dict.pop('pad', .0005)
        self.station_font_dict = station_dict.pop('font_dict', {
            'size': self.font_size,
            'weight': 'bold'
        })

        #--> plot if desired ------------------------
        self.plot_yn = kwargs.pop('plot_yn', 'y')
        if self.plot_yn == 'y':
            self.plot()
Exemplo n.º 3
0
    def __init__(self, fn_list1, fn_list2, **kwargs):
        assert len(fn_list1) == len(fn_list2)
        self.fn_list1 = fn_list1
        self.fn_list2 = fn_list2

        self.mt_list1 = mtpl.get_mtlist(fn_list=fn_list1)
        self.mt_list2 = mtpl.get_mtlist(fn_list=fn_list2)

        self.residual_pt_list = []
        self.med_filt_kernel = kwargs.pop("med_filt_kernel", None)

        # --> set the ellipse properties
        self._ellipse_dict = kwargs.pop("ellipse_dict", {"cmap": "mt_wh2or", "range": (0, 2)})
        self._read_ellipse_dict()

        # --> set colorbar properties---------------------------------
        # set orientation to horizontal
        cb_dict = kwargs.pop("cb_dict", {})
        try:
            self.cb_orientation = cb_dict["orientation"]
        except KeyError:
            self.cb_orientation = "vertical"

        # set the position to middle outside the plot
        try:
            self.cb_position = cb_dict["position"]
        except KeyError:
            self.cb_position = None

        # --> set plot properties ------------------------------
        self.fig_num = kwargs.pop("fig_num", "residual_PT")
        self.plot_title = kwargs.pop("plot_title", None)
        self.fig_dpi = kwargs.pop("fig_dpi", 300)
        self.tscale = kwargs.pop("tscale", "period")
        self.fig_size = kwargs.pop("fig_size", [6, 6])
        self.linedir = kwargs.pop("linedir", "ew")
        self.font_size = kwargs.pop("font_size", 7)
        self.station_id = kwargs.pop("station_id", [0, 4])
        self.ystep = kwargs.pop("ystep", 4)
        self.xstep = kwargs.pop("xstep", 1)
        self.xlimits = kwargs.pop("xlimits", None)
        self.ylimits = kwargs.pop("ylimits", None)

        # --> set the freq to plot
        self.ftol = kwargs.pop("ftol", 0.1)

        # --> set spacing of plot
        self.subplot_wspace = 0.1
        self.subplot_hspace = 0.15
        self.subplot_right = 0.98
        self.subplot_left = 0.085
        self.subplot_top = 0.93
        self.subplot_bottom = 0.1

        # set the stretching in each direction
        stretch = kwargs.pop("stretch", (50, 25))
        if type(stretch) == float or type(stretch) == int:
            self.xstretch = stretch
            self.ystretch = stretch
        else:
            self.xstretch = stretch[0]
            self.ystretch = stretch[1]

        # if rotation angle is an int or float make an array the length of
        # mt_list for plotting purposes

        self._rot_z = kwargs.pop("rot_z", 0)
        if type(self._rot_z) is float or type(self._rot_z) is int:
            self._rot_z = np.array([self._rot_z] * len(self.mt_list1))

        # if the rotation angle is an array for rotation of different
        # freq than repeat that rotation array to the len(mt_list)
        elif type(self._rot_z) is np.ndarray:
            if self._rot_z.shape[0] != len(self.mt_list1):
                self._rot_z = np.repeat(self._rot_z, len(self.mt_list1))

        else:
            pass

        # --> set station name properties
        station_dict = kwargs.pop("station_dict", {})
        self.station_id = station_dict.pop("id", (0, 3))
        self.station_pad = station_dict.pop("pad", 0.0005)
        self.station_font_dict = station_dict.pop("font_dict", {"size": self.font_size, "weight": "bold"})

        # --> plot if desired ------------------------
        self.plot_yn = kwargs.pop("plot_yn", "y")
        if self.plot_yn == "y":
            self.plot()
Exemplo n.º 4
0
    def __init__(self, fn_list1, fn_list2, **kwargs):
        assert len(fn_list1) == len(fn_list2)
        self.fn_list1 = fn_list1
        self.fn_list2 = fn_list2
        
        self.mt_list1 = mtpl.get_mtlist(fn_list=fn_list1)
        self.mt_list2 = mtpl.get_mtlist(fn_list=fn_list2)
        
        self.residual_pt_list = []
        self.freq_list = None
        self.rpt_array = None
        self.med_filt_kernel = kwargs.pop('med_filt_kernel', None)
        self.rot90 = kwargs.pop('rot90', True)
        
        #--> set the ellipse properties
        self._ellipse_dict = kwargs.pop('ellipse_dict',
                                        {'cmap':'mt_yl2rd',
                                         'range':(0, 10),
                                         'colorby':'geometric_mean'})
        self._read_ellipse_dict()
        self.ellipse_scale = kwargs.pop('ellipse_scale', 10)
        
        #--> set colorbar properties---------------------------------
        #set orientation to horizontal
        cb_dict = kwargs.pop('cb_dict', {})
        try:
            self.cb_orientation = cb_dict['orientation']
        except KeyError:
            self.cb_orientation = 'vertical'
        
        #set the position to middle outside the plot            
        try:
            self.cb_position = cb_dict['position']
        except KeyError:
            self.cb_position = None
            
        #--> set plot properties ------------------------------
        self.fig_num = kwargs.pop('fig_num', 'residual_PT')
        self.plot_title = kwargs.pop('plot_title', None)
        self.fig_dpi = kwargs.pop('fig_dpi', 300)
        self.tscale = kwargs.pop('tscale', 'period')
        self.fig_size = kwargs.pop('fig_size', [6, 6])
        self.linedir = kwargs.pop('linedir', 'ew')
        self.font_size = kwargs.pop('font_size', 7)
        self.station_id = kwargs.pop('station_id', [0,4])
        self.ystep = kwargs.pop('ystep', 4)
        self.xstep = kwargs.pop('xstep', 1)
        self.xlimits = kwargs.pop('xlimits', None)
        self.ylimits = kwargs.pop('ylimits', None)
        
        #--> set spacing of plot
        self.subplot_wspace = .1
        self.subplot_hspace = .15
        self.subplot_right = .98
        self.subplot_left = .085
        self.subplot_top = .93
        self.subplot_bottom = .1
        
        #set the stretching in each direction
        self.xstretch = kwargs.pop('xstretch', 1000)
        self.ystretch = kwargs.pop('ystretch', 25)

        
        #if rotation angle is an int or float make an array the length of 
        #mt_list for plotting purposes
        
        self._rot_z = kwargs.pop('rot_z', 0)
        if type(self._rot_z) is float or type(self._rot_z) is int:
            self._rot_z = np.array([self._rot_z]*len(self.mt_list1))
        
        #if the rotation angle is an array for rotation of different 
        #freq than repeat that rotation array to the len(mt_list)
        elif type(self._rot_z) is np.ndarray:
            if self._rot_z.shape[0]  !=  len(self.mt_list1):
                self._rot_z = np.repeat(self._rot_z, len(self.mt_list1))
                
        else:
            pass
        
            
        #--> set station name properties
        station_dict = kwargs.pop('station_dict', {})
        self.station_id = station_dict.pop('id', self.station_id)
        self.station_pad = station_dict.pop('pad', .0005)
        self.station_font_dict = station_dict.pop('font_dict', 
                                                  {'size':self.font_size,
                                                   'weight':'bold'})     
        
        #--> plot if desired ------------------------
        self.plot_yn = kwargs.pop('plot_yn', 'y')
        if self.plot_yn == 'y':
            self.plot()
Exemplo n.º 5
0
 def __init__(self, fn_list1, fn_list2, **kwargs):
     assert len(fn_list1) == len(fn_list2)
     self.fn_list1 = fn_list1
     self.fn_list2 = fn_list2
     
     self.mt_list1 = mtpl.get_mtlist(fn_list=fn_list1)
     self.mt_list2 = mtpl.get_mtlist(fn_list=fn_list2)
     
     self.residual_pt_list = []
     self.med_filt_kernel = kwargs.pop('med_filt_kernel', None)
     
     
     #--> set colorbar properties---------------------------------
     #set orientation to horizontal
     cb_dict = kwargs.pop('cb_dict', {})
     try:
         self.cb_orientation = cb_dict['orientation']
     except KeyError:
         self.cb_orientation = 'vertical'
     
     #set the position to middle outside the plot            
     try:
         self.cb_position = cb_dict['position']
     except KeyError:
         self.cb_position = None
         
     #--> set plot properties ------------------------------
     #set some of the properties as attributes much to Lars' discontent
     self.fig_num = kwargs.pop('fig_num', 1)
     self.plot_num = kwargs.pop('plot_num', 1)
     self.plot_style = kwargs.pop('plot_style', 'pseudo')
     self.plot_title = kwargs.pop('plot_title', None)
     self.fig_dpi = kwargs.pop('fig_dpi', 300)
     
     self.tscale = kwargs.pop('tscale', 'period')
     self.fig_size = kwargs.pop('fig_size', [8, 8])
     self.mapscale = kwargs.pop('mapscale', 'latlon')
     if self.mapscale == 'latlon':        
         self.xpad = kwargs.pop('xpad', .001)
         self.ypad = kwargs.pop('ypad', .001)
         #--> set the ellipse properties -------------------
         self._ellipse_dict = kwargs.pop('ellipse_dict', 
                                         {'range':(0,1), 'cmap':'mt_wh2or',
                                          'size':.005}) 
         self._read_ellipse_dict()
     elif self.mapscale == 'eastnorth':        
         self.xpad = kwargs.pop('xpad', 1000)
         self.ypad = kwargs.pop('ypad', 1000)
         #--> set the ellipse properties -------------------
         self._ellipse_dict = kwargs.pop('ellipse_dict', 
                                         {'range':(0,1), 'cmap':'mt_wh2or',
                                          'size':500})
     elif self.mapscale == 'eastnorthkm':        
         self.xpad = kwargs.pop('xpad', 1)
         self.ypad = kwargs.pop('ypad', 1)
         #--> set the ellipse properties -------------------
         self._ellipse_dict = kwargs.pop('ellipse_dict', 
                                         {'range':(0,1), 'cmap':'mt_wh2or',
                                          'size':.5})
     self.font_size = kwargs.pop('font_size', 7)
     
     #--> set the freq to plot
     self.plot_freq = kwargs.pop('plot_freq', 1.0)
     self.ftol = kwargs.pop('ftol', .1)
     
     #--> set spacing of plot
     self.subplot_wspace = .1
     self.subplot_hspace = .15
     self.subplot_right = .98
     self.subplot_left = .085
     self.subplot_top = .93
     self.subplot_bottom = .1
     
     #if rotation angle is an int or float make an array the length of 
     #mt_list for plotting purposes
     
     self._rot_z = kwargs.pop('rot_z', 0)
     if type(self._rot_z) is float or type(self._rot_z) is int:
         self._rot_z = np.array([self._rot_z]*len(self.mt_list1))
     
     #if the rotation angle is an array for rotation of different 
     #freq than repeat that rotation array to the len(mt_list)
     elif type(self._rot_z) is np.ndarray:
         if self._rot_z.shape[0]  !=  len(self.mt_list1):
             self._rot_z = np.repeat(self._rot_z, len(self.mt_list1))
             
     else:
         pass
     
     #--> set background image properties
     image_dict = kwargs.pop('image_dict', None)
     if image_dict!=None:
         # make sure there is a file
         try:
             self.image_file = image_dict['file']
             if not os.path.isfile(image_dict['file']):
                 raise IOError('Image file does not exist')
                 
         except KeyError:
             raise IOError('Need to include filename if plotting an image')
           
         # make sure an extent is given
         try:
             self.image_extent = image_dict['extent']
         except KeyError:
             raise NameError('Need to include the extent of the image as '+\
                             '(left, right, bottom, top)')
                             
     #--> set a central reference point
     self.plot_reference_point = kwargs.pop('reference_point', (0, 0))
         
     #--> set station name properties
     station_dict = kwargs.pop('station_dict', None)
     if station_dict!=None:
         try:
             self.station_id = station_dict['id']
         except KeyError:
             self.station_id = (0,2)
         
         #set spacing of station name and ellipse
         try:
             self.station_pad = station_dict['pad']
         except KeyError:
             self.station_pad = .0005
             
         #set font properties of the station label
         try:
             self.station_font_size = station_dict['font_dict']
         except KeyError:
             self.station_font_dict = {'size':self.font_size,
                                       'weight':'bold'}        
     
     #--> plot if desired ------------------------
     self.plot_yn = kwargs.pop('plot_yn', 'y')
     if self.plot_yn == 'y':
         self.plot()
Exemplo n.º 6
0
    def __init__(self, fn_list1, fn_list2, **kwargs):
        assert len(fn_list1) == len(fn_list2)
        self.fn_list1 = fn_list1
        self.fn_list2 = fn_list2

        self.mt_list1 = mtpl.get_mtlist(fn_list=fn_list1)
        self.mt_list2 = mtpl.get_mtlist(fn_list=fn_list2)

        self.residual_pt_list = None
        self.plot_data = None
        self.med_filt_kernel = kwargs.pop("med_filt_kernel", None)

        # --> set colorbar properties---------------------------------
        # set orientation to horizontal
        cb_dict = kwargs.pop("cb_dict", {})
        try:
            self.cb_orientation = cb_dict["orientation"]
        except KeyError:
            self.cb_orientation = "vertical"

        # set the position to middle outside the plot
        try:
            self.cb_position = cb_dict["position"]
        except KeyError:
            self.cb_position = None

        # --> set plot properties ------------------------------
        # set some of the properties as attributes much to Lars' discontent
        self.fig_num = kwargs.pop("fig_num", 1)
        self.plot_num = kwargs.pop("plot_num", 1)
        self.plot_style = kwargs.pop("plot_style", "pseudo")
        self.plot_title = kwargs.pop("plot_title", None)
        self.fig_dpi = kwargs.pop("fig_dpi", 300)

        self.tscale = kwargs.pop("tscale", "period")
        self.fig_size = kwargs.pop("fig_size", [8, 8])
        self.map_scale = kwargs.pop("map_scale", "deg")
        self.rot90 = kwargs.pop("rot90", 90)
        if self.map_scale == "deg":
            self.xpad = kwargs.pop("xpad", 0.005)
            self.ypad = kwargs.pop("ypad", 0.005)
            # --> set the ellipse properties -------------------
            self._ellipse_dict = kwargs.pop(
                "ellipse_dict", {"range": (0, 5), "cmap": "mt_wh2or", "size": 0.005, "colorby": "geometric_mean"}
            )
            self._read_ellipse_dict()
        elif self.map_scale == "m":
            self.xpad = kwargs.pop("xpad", 1000)
            self.ypad = kwargs.pop("ypad", 1000)
            # --> set the ellipse properties -------------------
            self._ellipse_dict = kwargs.pop(
                "ellipse_dict", {"range": (0, 5), "cmap": "mt_wh2or", "size": 500, "colorby": "geometric_mean"}
            )
            self._read_ellipse_dict()
        elif self.map_scale == "km":
            self.xpad = kwargs.pop("xpad", 1)
            self.ypad = kwargs.pop("ypad", 1)
            # --> set the ellipse properties -------------------
            self._ellipse_dict = kwargs.pop(
                "ellipse_dict", {"range": (0, 5), "cmap": "mt_wh2or", "size": 0.5, "colorby": "geometric_mean"}
            )
            self._read_ellipse_dict()
        self.font_size = kwargs.pop("font_size", 7)

        # --> set the freq to plot
        self.plot_freq = kwargs.pop("plot_freq", 1.0)
        self.ftol = kwargs.pop("ftol", 0.1)

        # --> set spacing of plot
        self.subplot_wspace = 0.1
        self.subplot_hspace = 0.15
        self.subplot_right = 0.98
        self.subplot_left = 0.085
        self.subplot_top = 0.93
        self.subplot_bottom = 0.1

        # if rotation angle is an int or float make an array the length of
        # mt_list for plotting purposes

        self._rot_z = kwargs.pop("rot_z", 0)
        if type(self._rot_z) is float or type(self._rot_z) is int:
            self._rot_z = np.array([self._rot_z] * len(self.mt_list1))

        # if the rotation angle is an array for rotation of different
        # freq than repeat that rotation array to the len(mt_list)
        elif type(self._rot_z) is np.ndarray:
            if self._rot_z.shape[0] != len(self.mt_list1):
                self._rot_z = np.repeat(self._rot_z, len(self.mt_list1))

        else:
            pass

        # --> set background image properties
        image_dict = kwargs.pop("image_dict", None)
        if image_dict != None:
            # make sure there is a file
            try:
                self.image_file = image_dict["file"]
                if not os.path.isfile(image_dict["file"]):
                    raise IOError("Image file does not exist")

            except KeyError:
                raise IOError("Need to include filename if plotting an image")

            # make sure an extent is given
            try:
                self.image_extent = image_dict["extent"]
            except KeyError:
                raise NameError("Need to include the extent of the image as " + "(left, right, bottom, top)")

        # --> set a central reference point
        self.plot_reference_point = kwargs.pop("reference_point", (0, 0))

        # --> set station name properties
        station_dict = kwargs.pop("station_dict", None)
        if station_dict != None:
            try:
                self.station_id = station_dict["id"]
            except KeyError:
                self.station_id = (0, 2)

            # set spacing of station name and ellipse
            try:
                self.station_pad = station_dict["pad"]
            except KeyError:
                self.station_pad = 0.0005

            # set font properties of the station label
            try:
                self.station_font_size = station_dict["font_dict"]
            except KeyError:
                self.station_font_dict = {"size": self.font_size, "weight": "bold"}

        # --> plot if desired ------------------------
        self.plot_yn = kwargs.pop("plot_yn", "y")
        if self.plot_yn == "y":
            self.plot()
Exemplo n.º 7
0
    def __init__(self, **kwargs):
        """
        Initialize parameters
        """

        #read in key word arguments and set defaults if none given
        fn_list = kwargs.pop('fn_list', None)
        res_object_list = kwargs.pop('res_object_list', None)
        z_object_list = kwargs.pop('z_object_list', None)
        mt_object_list = kwargs.pop('mt_object_list', None)

        #--> get the inputs into a list of mt objects
        self.mt_list = mtpl.get_mtlist(fn_list=fn_list,
                                       res_object_list=res_object_list,
                                       z_object_list=z_object_list,
                                       mt_object_list=mt_object_list)

        #--> set figure parameters
        self.fig_num = kwargs.pop('fig_num', 1)
        self.fig_size = kwargs.pop('fig_size', [8, 4])
        self.fig_dpi = kwargs.pop('fig_dpi', 300)
        self.font_size = kwargs.pop('font_size', 7)
        self.aspect = kwargs.pop('aspect', 'auto')

        self.xtickspace = kwargs.pop('xtickspace', 1)
        self.ftol = kwargs.pop('ftol', 0.1)
        self.stationid = kwargs.pop('stationid', [0, 4])
        self.linedir = kwargs.pop('linedir', 'ew')

        #--> set plots to plot and how to plot them
        self.plot_yn = kwargs.pop('plot_yn', 'y')
        self.plot_xx = kwargs.pop('plot_xx', 'n')
        self.plot_xy = kwargs.pop('plot_xy', 'y')
        self.plot_yx = kwargs.pop('plot_yx', 'y')
        self.plot_yy = kwargs.pop('plot_yy', 'n')
        self.plot_style = kwargs.pop('plot_style', 'imshow')
        self.imshow_interp = kwargs.pop('imshow_interp', 'bicubic')
        self.plot_period = kwargs.pop('plot_period', None)

        #--> set plot limits
        self.res_limits = kwargs.pop('res_limits', (0, 3))
        self.phase_limits = kwargs.pop('phase_limits', (0, 90))
        self.period_limits = kwargs.pop('period_limits', None)

        #--> set colorbar properties
        self.cb_pad = kwargs.pop('cb_pad', .0375)
        self.cb_orientation = kwargs.pop('cb_orientation', 'vertical')
        self.cb_shrink = kwargs.pop('cb_shrink', .75)
        self.cb_position = kwargs.pop('cb_position', None)

        #--> set text box parameters
        self.text_location = kwargs.pop('text_location', None)
        self.text_xpad = kwargs.pop('text_xpad', .95)
        self.text_ypad = kwargs.pop('text_ypad', .95)
        self.text_size = kwargs.pop('text_size', self.font_size)
        self.text_weight = kwargs.pop('text_weight', 'bold')

        #--> set colormaps Note only mtcolors is supported
        self.res_cmap = kwargs.pop('res_cmap', mtcl.cmapdict['mt_rd2gr2bl'])
        self.phase_cmap = kwargs.pop('phase_cmap',
                                     mtcl.cmapdict['mt_bl2gr2rd'])

        #create empty lists to put things into
        self.stationlist = []
        self.offsetlist = []

        #make a list of periods from each station assuming the longest one
        #is the most complete ==> largest range.
        period_list = np.array([len(mt.period) for mt in self.mt_list])

        #find index where the longest period is if multiple pick the first one
        max_find = np.where(period_list == period_list.max())[0]
        if len(max_find) > 0:
            max_find = max_find[0]

        if self.plot_period is None:
            self.plot_period = \
                  self.mt_list[max_find].period

        #create empty arrays to put data into
        ns = len(self.mt_list)
        nt = len(self.plot_period)

        self.resxx = np.zeros((nt, ns))
        self.resxy = np.zeros((nt, ns))
        self.resyx = np.zeros((nt, ns))
        self.resyy = np.zeros((nt, ns))

        self.phasexx = np.zeros((nt, ns))
        self.phasexy = np.zeros((nt, ns))
        self.phaseyx = np.zeros((nt, ns))
        self.phaseyy = np.zeros((nt, ns))

        rot_z = kwargs.pop('rot_z', 0)
        #if rotation angle is an int or float make an array the length of
        #mt_list for plotting purposes
        if type(rot_z) is float or type(rot_z) is int:
            self.rot_z = np.array([rot_z] * len(self.mt_list))

        #if the rotation angle is an array for rotation of different
        #freq than repeat that rotation array to the len(mt_list)
        elif type(rot_z) is np.ndarray:
            if rot_z.shape[0] != len(self.mt_list):
                self.rot_z = np.repeat(rot_z, len(self.mt_list))

        else:
            self.rot_z = rot_z

        if self.plot_yn == 'y':
            self.plot()
Exemplo n.º 8
0
    def __init__(self, **kwargs):
        """
        Initialize parameters
        """
        
        #read in key word arguments and set defaults if none given
        fn_list = kwargs.pop('fn_list', None)
        res_object_list = kwargs.pop('res_object_list', None)
        z_object_list = kwargs.pop('z_object_list', None)
        mt_object_list = kwargs.pop('mt_object_list', None)
        
        #--> get the inputs into a list of mt objects
        self.mt_list = mtpl.get_mtlist(fn_list=fn_list, 
                                     res_object_list=res_object_list,
                                     z_object_list=z_object_list, 
                                     mt_object_list=mt_object_list)
        
        #--> set figure parameters
        self.fig_num = kwargs.pop('fig_num', 1)
        self.fig_size = kwargs.pop('fig_size', [8, 4])
        self.fig_dpi = kwargs.pop('fig_dpi', 300)
        self.font_size = kwargs.pop('font_size', 7)
        self.aspect = kwargs.pop('aspect', 'auto')
        
        self.xtickspace = kwargs.pop('xtickspace', 1)
        self.ftol = kwargs.pop('ftol', 0.1)
        self.stationid = kwargs.pop('stationid', [0,4])
        self.linedir = kwargs.pop('linedir', 'ew')

        #--> set plots to plot and how to plot them
        self.plot_yn = kwargs.pop('plot_yn', 'y')
        self.plot_xx = kwargs.pop('plot_xx', 'n')
        self.plot_xy = kwargs.pop('plot_xy', 'y')
        self.plot_yx = kwargs.pop('plot_yx', 'y')
        self.plot_yy = kwargs.pop('plot_yy', 'n')
        self.plot_style = kwargs.pop('plot_style', 'imshow')
        self.imshow_interp = kwargs.pop('imshow_interp', 'bicubic')
        self.plot_period = kwargs.pop('plot_period', None)
        
        #--> set plot limits
        self.res_limits = kwargs.pop('res_limits', (0, 3))
        self.phase_limits = kwargs.pop('phase_limits', (0, 90))
        self.period_limits = kwargs.pop('period_limits', None)

        #--> set colorbar properties
        self.cb_pad = kwargs.pop('cb_pad', .0375)
        self.cb_orientation = kwargs.pop('cb_orientation', 'vertical')
        self.cb_shrink = kwargs.pop('cb_shrink', .75)
        self.cb_position = kwargs.pop('cb_position', None)
        
        #--> set text box parameters
        self.text_location = kwargs.pop('text_location', None)
        self.text_xpad = kwargs.pop('text_xpad', .95)
        self.text_ypad = kwargs.pop('text_ypad', .95)
        self.text_size = kwargs.pop('text_size', self.font_size)
        self.text_weight = kwargs.pop('text_weight', 'bold')
        
        
        
        #--> set colormaps Note only mtcolors is supported
        self.res_cmap = kwargs.pop('res_cmap', mtcl.cmapdict['mt_rd2gr2bl'])
        self.phase_cmap = kwargs.pop('phase_cmap', mtcl.cmapdict['mt_bl2gr2rd'])
        
        #create empty lists to put things into
        self.stationlist = []
        self.offsetlist = []
        
        #make a list of periods from each station assuming the longest one
        #is the most complete ==> largest range.  
        period_list = np.array([len(mt.period) for mt in self.mt_list])
        
        #find index where the longest period is if multiple pick the first one
        max_find = np.where(period_list==period_list.max())[0]
        if len(max_find)>0:
            max_find = max_find[0]
    
        if self.plot_period is None:
            self.plot_period = \
                  self.mt_list[max_find].period
            
        #create empty arrays to put data into
        ns = len(self.mt_list)
        nt = len(self.plot_period)
        
        self.resxx = np.zeros((nt, ns))
        self.resxy = np.zeros((nt, ns))
        self.resyx = np.zeros((nt, ns))
        self.resyy = np.zeros((nt, ns))
        
        self.phasexx = np.zeros((nt, ns))
        self.phasexy = np.zeros((nt, ns))
        self.phaseyx = np.zeros((nt, ns))
        self.phaseyy = np.zeros((nt, ns))
        
        rot_z = kwargs.pop('rot_z', 0)
        #if rotation angle is an int or float make an array the length of 
        #mt_list for plotting purposes
        if type(rot_z) is float or type(rot_z) is int:
            self.rot_z = np.array([rot_z]*len(self.mt_list))
        
        #if the rotation angle is an array for rotation of different 
        #freq than repeat that rotation array to the len(mt_list)
        elif type(rot_z) is np.ndarray:
            if rot_z.shape[0]!=len(self.mt_list):
                self.rot_z = np.repeat(rot_z, len(self.mt_list))
                
        else:
            self.rot_z = rot_z
        
        if self.plot_yn == 'y':
            self.plot()
Exemplo n.º 9
0
    def __init__(self, **kwargs):

        fn_list = kwargs.pop('fn_list', None)
        z_object_list = kwargs.pop('z_object_list', None)
        tipper_object_list = kwargs.pop('tipper_object_list', None)
        mt_object_list = kwargs.pop('mt_object_list', None)

        #------Set attributes of the class-----------------

        #--> get the inputs into a list of mt objects
        self.mt_list = mtpl.get_mtlist(fn_list=fn_list,
                                       z_object_list=z_object_list,
                                       tipper_object_list=tipper_object_list,
                                       mt_object_list=mt_object_list)

        self._rot_z = kwargs.pop('rot_z', 0)
        if isinstance(self._rot_z, float) or isinstance(self._rot_z, int):
            self._rot_z = np.array([self._rot_z] * len(self.mt_list))

        # if the rotation angle is an array for rotation of different
        # freq than repeat that rotation array to the len(mt_list)
        elif isinstance(self._rot_z, np.ndarray):
            if self._rot_z.shape[0] != len(self.mt_list):
                self._rot_z = np.repeat(self._rot_z, len(self.mt_list))

        else:
            pass

        #--> set plot properties
        self.fig_num = kwargs.pop('fig_num', 1)
        self.fig_dpi = kwargs.pop('fig_dpi', 300)
        self.fig_size = kwargs.pop('fig_size', [7, 5])

        self.plot_num = kwargs.pop('plot_num', 1)
        self.plot_type = kwargs.pop('plot_type', 2)
        self.plot_title = kwargs.pop('plot_title', None)
        self.plot_range = kwargs.pop('plot_range', 'data')
        self.plot_tipper = kwargs.pop('plot_tipper', 'n')

        self.period_tolerance = kwargs.pop('period_tolerance', .05)
        self.pt_error_floor = kwargs.pop('pt_error_floor', None)
        self.fold = kwargs.pop('fold', True)
        self.bin_width = kwargs.pop('bin_width', 5)
        self.skew_threshold = kwargs.pop('skew_threshold', 3)

        self.font_size = kwargs.pop('font_size', 7)

        text_dict = kwargs.pop('text_dict', {})
        try:
            self.text_pad = text_dict['pad']
        except KeyError:
            self.text_pad = 0.6

        try:
            self.text_size = text_dict['size']
        except KeyError:
            self.text_size = self.font_size

        # make a dictionary for plotting titles
        self.title_dict = {}
        self.title_dict[-5] = '10$^{-5}$--10$^{-4}$s'
        self.title_dict[-4] = '10$^{-4}$--10$^{-3}$s'
        self.title_dict[-3] = '10$^{-3}$--10$^{-2}$s'
        self.title_dict[-2] = '10$^{-2}$--10$^{-1}$s'
        self.title_dict[-1] = '10$^{-1}$--10$^{0}$s'
        self.title_dict[0] = '10$^{0}$--10$^{1}$s'
        self.title_dict[1] = '10$^{1}$--10$^{2}$s'
        self.title_dict[2] = '10$^{2}$--10$^{3}$s'
        self.title_dict[3] = '10$^{3}$--10$^{4}$s'
        self.title_dict[4] = '10$^{4}$--10$^{5}$s'
        self.title_dict[5] = '10$^{5}$--10$^{6}$s'

        self.plot_yn = kwargs.pop('plot_yn', 'y')
        if self.plot_yn == 'y':
            self.plot()