コード例 #1
0
ファイル: plotpseudosection.py プロジェクト: azeezkk/mtpy
    def __init__(self, **kwargs):
        """
        Initialize parameters
        """
        
        #read in key word arguments and set defaults if none given
        fn_lst = kwargs.pop('fn_lst', None)
        res_object_lst = kwargs.pop('res_object_lst', None)
        z_object_lst = kwargs.pop('z_object_lst', None)
        mt_object_lst = kwargs.pop('mt_object_lst', None)
        
        #--> get the inputs into a list of mt objects
        self.mt_lst = mtpl.get_mtlst(fn_lst=fn_lst, 
                                     res_object_lst=res_object_lst,
                                     z_object_lst=z_object_lst, 
                                     mt_object_lst=mt_object_lst)
        
        #--> 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.stationlst = []
        self.offsetlst = []
        
        #make a list of periods from each station assuming the longest one
        #is the most complete ==> largest range.  
        period_lst = np.array([len(mt.period) for mt in self.mt_lst])
        
        #find index where the longest period is if multiple pick the first one
        max_find = np.where(period_lst==period_lst.max())[0]
        if len(max_find)>0:
            max_find = max_find[0]
    
        if self.plot_period is None:
            self.plot_period = \
                  self.mt_lst[max_find].period
            
        #create empty arrays to put data into
        ns = len(self.mt_lst)
        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_lst 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_lst))
        
        #if the rotation angle is an array for rotation of different 
        #freq than repeat that rotation array to the len(mt_lst)
        elif type(rot_z) is np.ndarray:
            if rot_z.shape[0]!=len(self.mt_lst):
                self.rot_z = np.repeat(rot_z, len(self.mt_lst))
                
        else:
            self.rot_z = rot_z
        
        if self.plot_yn == 'y':
            self.plot()