Пример #1
0
    def plot(self):
        """
        plot the data
        """

        if self.station is None:
            return

        s_index = np.where(self.ws_data.data['station'] == self.station)[0][0]

        z_obj = mtz.Z(self.ws_data.data[s_index]['z_data'],
                      self.ws_data.data[s_index]['z_data_err']*\
                        self.ws_data.data[s_index]['z_err_map'],
                      1./self.ws_data.period_list)
        period = self.ws_data.period_list

        # need to make sure that resistivity and phase is computed
        z_obj._compute_res_phase()

        plt.rcParams['font.size'] = self.plot_settings.fs
        fontdict = {'size': self.plot_settings.fs + 2, 'weight': 'bold'}

        #--> make key word dictionaries for plotting
        kw_xx = {
            'color': self.plot_settings.cted,
            'marker': self.plot_settings.mted,
            'ms': self.plot_settings.ms,
            'ls': ':',
            'lw': self.plot_settings.lw,
            'e_capsize': self.plot_settings.e_capsize,
            'e_capthick': self.plot_settings.e_capthick,
            'picker': 3
        }

        kw_yy = {
            'color': self.plot_settings.ctmd,
            'marker': self.plot_settings.mtmd,
            'ms': self.plot_settings.ms,
            'ls': ':',
            'lw': self.plot_settings.lw,
            'e_capsize': self.plot_settings.e_capsize,
            'e_capthick': self.plot_settings.e_capthick,
            'picker': 3
        }

        #convert to apparent resistivity and phase
        if self.plot_z == True:
            scaling = np.zeros_like(z_obj.z)
            for ii in range(2):
                for jj in range(2):
                    scaling[:, ii, jj] = 1. / np.sqrt(z_obj.freq)
            plot_res = abs(z_obj.z.real * scaling)
            plot_res_err = abs(z_obj.z_err * scaling)
            plot_phase = abs(z_obj.z.imag * scaling)
            plot_phase_err = abs(z_obj.z_err * scaling)
            h_ratio = [1, 1]

        elif self.plot_z == False:
            plot_res = z_obj.resistivity
            plot_res_err = z_obj.resistivity_err
            plot_phase = z_obj.phase
            plot_phase_err = z_obj.phase_err
            h_ratio = [2, 1]

        #find locations where points have been masked
        nzxx = np.nonzero(z_obj.z[:, 0, 0])[0]
        nzxy = np.nonzero(z_obj.z[:, 0, 1])[0]
        nzyx = np.nonzero(z_obj.z[:, 1, 0])[0]
        nzyy = np.nonzero(z_obj.z[:, 1, 1])[0]

        self.figure.clf()
        self.figure.suptitle(str(self.station), fontdict=fontdict)

        #set the grid of subplots
        gs = gridspec.GridSpec(2, 4, height_ratios=h_ratio)
        gs.update(wspace=self.plot_settings.subplot_wspace,
                  left=self.plot_settings.subplot_left,
                  top=self.plot_settings.subplot_top,
                  bottom=self.plot_settings.subplot_bottom,
                  right=self.plot_settings.subplot_right,
                  hspace=self.plot_settings.subplot_hspace)

        axrxx = self.figure.add_subplot(gs[0, 0])
        axrxy = self.figure.add_subplot(gs[0, 1], sharex=axrxx)
        axryx = self.figure.add_subplot(gs[0, 2], sharex=axrxx)
        axryy = self.figure.add_subplot(gs[0, 3], sharex=axrxx)

        axpxx = self.figure.add_subplot(gs[1, 0])
        axpxy = self.figure.add_subplot(gs[1, 1], sharex=axrxx)
        axpyx = self.figure.add_subplot(gs[1, 2], sharex=axrxx)
        axpyy = self.figure.add_subplot(gs[1, 3], sharex=axrxx)

        self.ax_list = [axrxx, axrxy, axryx, axryy, axpxx, axpxy, axpyx, axpyy]

        # plot data response
        erxx = mtplottools.plot_errorbar(axrxx, period[nzxx], plot_res[nzxx, 0,
                                                                       0],
                                         plot_res_err[nzxx, 0, 0], **kw_xx)
        erxy = mtplottools.plot_errorbar(axrxy, period[nzxy], plot_res[nzxy, 0,
                                                                       1],
                                         plot_res_err[nzxy, 0, 1], **kw_xx)
        eryx = mtplottools.plot_errorbar(axryx, period[nzyx], plot_res[nzyx, 1,
                                                                       0],
                                         plot_res_err[nzyx, 1, 0], **kw_yy)
        eryy = mtplottools.plot_errorbar(axryy, period[nzyy], plot_res[nzyy, 1,
                                                                       1],
                                         plot_res_err[nzyy, 1, 1], **kw_yy)
        #plot phase
        epxx = mtplottools.plot_errorbar(axpxx, period[nzxx], plot_phase[nzxx,
                                                                         0, 0],
                                         plot_phase_err[nzxx, 0, 0], **kw_xx)
        epxy = mtplottools.plot_errorbar(axpxy, period[nzxy], plot_phase[nzxy,
                                                                         0, 1],
                                         plot_phase_err[nzxy, 0, 1], **kw_xx)
        epyx = mtplottools.plot_errorbar(axpyx, period[nzyx], plot_phase[nzyx,
                                                                         1, 0],
                                         plot_phase_err[nzyx, 1, 0], **kw_yy)
        epyy = mtplottools.plot_errorbar(axpyy, period[nzyy], plot_phase[nzyy,
                                                                         1, 1],
                                         plot_phase_err[nzyy, 1, 1], **kw_yy)

        #----------------------------------------------
        # get error bar list for editing later
        self._err_list = [[erxx[1][0], erxx[1][1], erxx[2][0]],
                          [erxy[1][0], erxy[1][1], erxy[2][0]],
                          [eryx[1][0], eryx[1][1], eryx[2][0]],
                          [eryy[1][0], eryy[1][1], eryy[2][0]]]
        line_list = [[erxx[0]], [erxy[0]], [eryx[0]], [eryy[0]]]

        #------------------------------------------
        # make things look nice
        # set titles of the Z components
        label_list = [['$Z_{xx}$'], ['$Z_{xy}$'], ['$Z_{yx}$'], ['$Z_{yy}$']]
        for ax, label in zip(self.ax_list[0:4], label_list):
            ax.set_title(label[0],
                         fontdict={
                             'size': self.plot_settings.fs + 2,
                             'weight': 'bold'
                         })

        #--> set limits if input
        if self.plot_settings.res_xx_limits is not None:
            axrxx.set_ylim(self.plot_settings.res_xx_limits)
        if self.plot_settings.res_xy_limits is not None:
            axrxy.set_ylim(self.plot_settings.res_xy_limits)
        if self.plot_settings.res_yx_limits is not None:
            axryx.set_ylim(self.plot_settings.res_yx_limits)
        if self.plot_settings.res_yy_limits is not None:
            axryy.set_ylim(self.plot_settings.res_yy_limits)

        if self.plot_settings.phase_xx_limits is not None:
            axpxx.set_ylim(self.plot_settings.phase_xx_limits)
        if self.plot_settings.phase_xy_limits is not None:
            axpxy.set_ylim(self.plot_settings.phase_xy_limits)
        if self.plot_settings.phase_yx_limits is not None:
            axpyx.set_ylim(self.plot_settings.phase_yx_limits)
        if self.plot_settings.phase_yy_limits is not None:
            axpyy.set_ylim(self.plot_settings.phase_yy_limits)

        #set axis properties
        for aa, ax in enumerate(self.ax_list):
            ax.tick_params(axis='y', pad=self.plot_settings.ylabel_pad)
            ylabels = ax.get_yticks().tolist()
            if aa < 4:
                ylabels[-1] = ''
                ylabels[0] = ''
                ax.set_yticklabels(ylabels)
                plt.setp(ax.get_xticklabels(), visible=False)
                if self.plot_z == True:
                    ax.set_yscale('log')

            else:
                ax.set_xlabel('Period (s)', fontdict=fontdict)

            if aa < 4 and self.plot_z is False:
                ax.set_yscale('log')

            #set axes labels
            if aa == 0:
                if self.plot_z == False:
                    ax.set_ylabel('App. Res. ($\mathbf{\Omega \cdot m}$)',
                                  fontdict=fontdict)
                elif self.plot_z == True:
                    ax.set_ylabel('Re[Z (mV/km nT)]', fontdict=fontdict)
            elif aa == 4:
                if self.plot_z == False:
                    ax.set_ylabel('Phase (deg)', fontdict=fontdict)
                elif self.plot_z == True:
                    ax.set_ylabel('Im[Z (mV/km nT)]', fontdict=fontdict)

            ax.set_xscale('log')
            ax.set_xlim(xmin=10**(np.floor(np.log10(period[0]))) * 1.01,
                        xmax=10**(np.ceil(np.log10(period[-1]))) * .99)
            ax.grid(True, alpha=.25)

        ##----------------------------------------------
        #plot model response
        if self.ws_resp is not None:
            s_index = np.where(
                self.ws_resp.resp['station'] == self.station)[0][0]

            resp_z_obj = mtz.Z(self.ws_resp.resp[s_index]['z_resp'], None,
                               1. / self.ws_resp.period_list)

            resp_z_err = np.nan_to_num((z_obj.z - resp_z_obj.z) / z_obj.z_err)
            resp_z_obj._compute_res_phase()

            #convert to apparent resistivity and phase
            if self.plot_z == True:
                scaling = np.zeros_like(resp_z_obj.z)
                for ii in range(2):
                    for jj in range(2):
                        scaling[:, ii, jj] = 1. / np.sqrt(resp_z_obj.freq)
                r_plot_res = abs(resp_z_obj.z.real * scaling)
                r_plot_phase = abs(resp_z_obj.z.imag * scaling)

            elif self.plot_z == False:
                r_plot_res = resp_z_obj.resistivity
                r_plot_phase = resp_z_obj.phase

            rms_xx = resp_z_err[:, 0, 0].std()
            rms_xy = resp_z_err[:, 0, 1].std()
            rms_yx = resp_z_err[:, 1, 0].std()
            rms_yy = resp_z_err[:, 1, 1].std()

            #--> make key word dictionaries for plotting
            kw_xx = {
                'color': self.plot_settings.ctem,
                'marker': self.plot_settings.mtem,
                'ms': self.plot_settings.ms,
                'ls': ':',
                'lw': self.plot_settings.lw,
                'e_capsize': self.plot_settings.e_capsize,
                'e_capthick': self.plot_settings.e_capthick
            }

            kw_yy = {
                'color': self.plot_settings.ctmm,
                'marker': self.plot_settings.mtmm,
                'ms': self.plot_settings.ms,
                'ls': ':',
                'lw': self.plot_settings.lw,
                'e_capsize': self.plot_settings.e_capsize,
                'e_capthick': self.plot_settings.e_capthick
            }

            # plot data response
            rerxx = mtplottools.plot_errorbar(axrxx, period[nzxx],
                                              r_plot_res[nzxx, 0,
                                                         0], None, **kw_xx)
            rerxy = mtplottools.plot_errorbar(axrxy, period[nzxy],
                                              r_plot_res[nzxy, 0,
                                                         1], None, **kw_xx)
            reryx = mtplottools.plot_errorbar(axryx, period[nzyx],
                                              r_plot_res[nzyx, 1,
                                                         0], None, **kw_yy)
            reryy = mtplottools.plot_errorbar(axryy, period[nzyy],
                                              r_plot_res[nzyy, 1,
                                                         1], None, **kw_yy)
            #plot phase
            repxx = mtplottools.plot_errorbar(axpxx, period[nzxx],
                                              r_plot_phase[nzxx, 0,
                                                           0], None, **kw_xx)
            repxy = mtplottools.plot_errorbar(axpxy, period[nzxy],
                                              r_plot_phase[nzxy, 0,
                                                           1], None, **kw_xx)
            repyx = mtplottools.plot_errorbar(axpyx, period[nzyx],
                                              r_plot_phase[nzyx, 1,
                                                           0], None, **kw_yy)
            repyy = mtplottools.plot_errorbar(axpyy, period[nzyy],
                                              r_plot_phase[nzyy, 1,
                                                           1], None, **kw_yy)

            # add labels to legends
            line_list[0] += [rerxx[0]]
            line_list[1] += [rerxy[0]]
            line_list[2] += [reryx[0]]
            line_list[3] += [reryy[0]]
            label_list[0] += ['$Z^m_{xx}$ ' + 'rms={0:.2f}'.format(rms_xx)]
            label_list[1] += ['$Z^m_{xy}$ ' + 'rms={0:.2f}'.format(rms_xy)]
            label_list[2] += ['$Z^m_{yx}$ ' + 'rms={0:.2f}'.format(rms_yx)]
            label_list[3] += ['$Z^m_{yy}$ ' + 'rms={0:.2f}'.format(rms_yy)]

            legend_ax_list = self.ax_list[0:4]
            for aa, ax in enumerate(legend_ax_list):
                ax.legend(
                    line_list[aa],
                    label_list[aa],
                    loc=self.plot_settings.legend_loc,
                    bbox_to_anchor=self.plot_settings.legend_pos,
                    markerscale=self.plot_settings.legend_marker_scale,
                    borderaxespad=self.plot_settings.legend_border_axes_pad,
                    labelspacing=self.plot_settings.legend_label_spacing,
                    handletextpad=self.plot_settings.legend_handle_text_pad,
                    borderpad=self.plot_settings.legend_border_pad,
                    prop={'size': max([self.plot_settings.fs, 5])})

        self.mpl_widget.draw()
Пример #2
0
    def plot(self):
        """
        plot the data
        """

        if self.station is None:
            return
            
        z_obj = self.modem_data.mt_dict[self.station].Z
        t_obj = self.modem_data.mt_dict[self.station].Tipper
        period = self.modem_data.period_list
        
        # need to make sure that resistivity and phase is computed
        z_obj.compute_resistivity_phase()
        z_obj.compute_resistivity_phase()

        plt.rcParams['font.size'] = self.plot_settings.fs
        fontdict = {'size':self.plot_settings.fs+2, 'weight':'bold'} 

        #--> make key word dictionaries for plotting
        kw_xx = {'color':self.plot_settings.cted,
                 'marker':self.plot_settings.mted,
                 'ms':self.plot_settings.ms,
                 'ls':':',
                 'lw':self.plot_settings.lw,
                 'e_capsize':self.plot_settings.e_capsize,
                 'e_capthick':self.plot_settings.e_capthick,
                 'picker':3}        
       
        kw_yy = {'color':self.plot_settings.ctmd,
                 'marker':self.plot_settings.mtmd,
                 'ms':self.plot_settings.ms,
                 'ls':':',
                 'lw':self.plot_settings.lw,
                 'e_capsize':self.plot_settings.e_capsize,
                 'e_capthick':self.plot_settings.e_capthick,
                 'picker':3} 

        #convert to apparent resistivity and phase
        if self.plot_z == True:
            scaling = np.zeros_like(z_obj.z)
            for ii in range(2):
                for jj in range(2):
                    scaling[:, ii, jj] = 1./np.sqrt(z_obj.freq)
            plot_res = abs(z_obj.z.real*scaling)
            plot_res_err = abs(z_obj.z_err*scaling)
            plot_phase = abs(z_obj.z.imag*scaling)
            plot_phase_err = abs(z_obj.z_err*scaling)
            h_ratio = [1, 1, .5]
            
        elif self.plot_z == False:
            plot_res = z_obj.resistivity
            plot_res_err = z_obj.resistivity_err
            plot_phase = z_obj.phase
            plot_phase_err = z_obj.phase_err
            h_ratio = [1.5, 1, .5]
        
        #find locations where points have been masked
        nzxx = np.nonzero(z_obj.z[:, 0, 0])[0]
        nzxy = np.nonzero(z_obj.z[:, 0, 1])[0]
        nzyx = np.nonzero(z_obj.z[:, 1, 0])[0]
        nzyy = np.nonzero(z_obj.z[:, 1, 1])[0]
        ntx = np.nonzero(t_obj.tipper[:, 0, 0])[0]
        nty = np.nonzero(t_obj.tipper[:, 0, 1])[0]
        

        self.figure.clf()
        self.figure.suptitle(str(self.station), fontdict=fontdict)
        
        #set the grid of subplots
        if np.all(t_obj.tipper == 0.0) == True:
            self.plot_tipper = False
        else:
            self.plot_tipper = True
            
        gs = gridspec.GridSpec(3, 4, height_ratios=h_ratio)
        gs.update(wspace=self.plot_settings.subplot_wspace,
                   left=self.plot_settings.subplot_left,
                   top=self.plot_settings.subplot_top,
                   bottom=self.plot_settings.subplot_bottom, 
                   right=self.plot_settings.subplot_right, 
                   hspace=self.plot_settings.subplot_hspace)

        axrxx = self.figure.add_subplot(gs[0, 0])
        axrxy = self.figure.add_subplot(gs[0, 1], sharex=axrxx)
        axryx = self.figure.add_subplot(gs[0, 2], sharex=axrxx)
        axryy = self.figure.add_subplot(gs[0, 3], sharex=axrxx)
        
        axpxx = self.figure.add_subplot(gs[1, 0])
        axpxy = self.figure.add_subplot(gs[1, 1], sharex=axrxx)
        axpyx = self.figure.add_subplot(gs[1, 2], sharex=axrxx)
        axpyy = self.figure.add_subplot(gs[1, 3], sharex=axrxx)
        
        axtxr = self.figure.add_subplot(gs[2, 0], sharex=axrxx)
        axtxi = self.figure.add_subplot(gs[2, 1], sharex=axrxx)
        axtyr = self.figure.add_subplot(gs[2, 2], sharex=axrxx)
        axtyi = self.figure.add_subplot(gs[2, 3], sharex=axrxx)
        
        self.ax_list = [axrxx, axrxy, axryx, axryy,
                        axpxx, axpxy, axpyx, axpyy,
                        axtxr, axtxi, axtyr, axtyi]
        

        # plot data response
        erxx = mtplottools.plot_errorbar(axrxx, 
                                         period[nzxx], 
                                         plot_res[nzxx, 0, 0], 
                                         plot_res_err[nzxx, 0, 0],
                                         **kw_xx)
        erxy = mtplottools.plot_errorbar(axrxy, 
                                         period[nzxy], 
                                         plot_res[nzxy, 0, 1], 
                                         plot_res_err[nzxy, 0, 1],
                                         **kw_xx)
        eryx = mtplottools.plot_errorbar(axryx, 
                                         period[nzyx], 
                                         plot_res[nzyx, 1, 0], 
                                         plot_res_err[nzyx, 1, 0],
                                         **kw_yy)
        eryy = mtplottools.plot_errorbar(axryy, 
                                         period[nzyy], 
                                         plot_res[nzyy, 1, 1], 
                                         plot_res_err[nzyy, 1, 1],
                                         **kw_yy)
        #plot phase                         
        epxx = mtplottools.plot_errorbar(axpxx, 
                                         period[nzxx], 
                                         plot_phase[nzxx, 0, 0], 
                                         plot_phase_err[nzxx, 0, 0],
                                         **kw_xx)
        epxy = mtplottools.plot_errorbar(axpxy, 
                                         period[nzxy], 
                                         plot_phase[nzxy, 0, 1], 
                                         plot_phase_err[nzxy, 0, 1],
                                         **kw_xx)
        epyx = mtplottools.plot_errorbar(axpyx, 
                                         period[nzyx], 
                                         plot_phase[nzyx, 1, 0], 
                                         plot_phase_err[nzyx, 1, 0],
                                         **kw_yy)
        epyy = mtplottools.plot_errorbar(axpyy, 
                                         period[nzyy], 
                                         plot_phase[nzyy, 1, 1], 
                                         plot_phase_err[nzyy, 1, 1],
                                         **kw_yy)
                                      
        #plot tipper
        if self.plot_tipper == True:
            ertx = mtplottools.plot_errorbar(axtxr, 
                                             period[ntx],
                                             t_obj.tipper[ntx, 0, 0].real,
                                             t_obj.tipper_err[ntx, 0, 0],
                                             **kw_xx)
            erty = mtplottools.plot_errorbar(axtyr, 
                                             period[nty],
                                             t_obj.tipper[nty, 0, 1].real,
                                             t_obj.tipper_err[nty, 0, 1],
                                             **kw_yy)
                                     
            eptx = mtplottools.plot_errorbar(axtxi, 
                                             period[ntx],
                                             t_obj.tipper[ntx, 0, 0].imag,
                                             t_obj.tipper_err[ntx, 0, 0],
                                             **kw_xx)
            epty = mtplottools.plot_errorbar(axtyi, 
                                             period[nty],
                                             t_obj.tipper[nty, 0, 1].imag,
                                             t_obj.tipper_err[nty, 0, 1],
                                             **kw_yy)
        
        #----------------------------------------------
        # get error bar list for editing later        
        if self.plot_tipper == False: 
            try:                   
                self._err_list = [[erxx[1][0], erxx[1][1], erxx[2][0]],
                                  [erxy[1][0], erxy[1][1], erxy[2][0]],
                                  [eryx[1][0], eryx[1][1], eryx[2][0]],
                                  [eryy[1][0], eryy[1][1], eryy[2][0]], 
                                  [epxx[1][0], epxx[1][1], epxx[2][0]],
                                  [epxy[1][0], epxy[1][1], epxy[2][0]],
                                  [epyx[1][0], epyx[1][1], epyx[2][0]],
                                  [epyy[1][0], epyy[1][1], epyy[2][0]]]
                line_list = [[erxx[0]], [erxy[0]], [eryx[0]], [eryy[0]]]
            except IndexError:
                print 'Found no Z components for {0}'.format(self.station)
                line_list = [[None], [None], 
                             [None], [None]]
                                     
                self._err_list = [[None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None]]

        else:
            try:                    
                line_list = [[erxx[0]], [erxy[0]], 
                             [eryx[0]], [eryy[0]],
                             [ertx[0]], [erty[0]]]
                                     
                self._err_list = [[erxx[1][0], erxx[1][1], erxx[2][0]],
                                  [erxy[1][0], erxy[1][1], erxy[2][0]],
                                  [eryx[1][0], eryx[1][1], eryx[2][0]],
                                  [eryy[1][0], eryy[1][1], eryy[2][0]],
                                  [epxx[1][0], epxx[1][1], epxx[2][0]],
                                  [epxy[1][0], epxy[1][1], epxy[2][0]],
                                  [epyx[1][0], epyx[1][1], epyx[2][0]],
                                  [epyy[1][0], epyy[1][1], epyy[2][0]],
                                  [ertx[1][0], ertx[1][1], ertx[2][0]],
                                  [eptx[1][0], eptx[1][1], eptx[2][0]],
                                  [erty[1][0], erty[1][1], erty[2][0]],
                                  [epty[1][0], epty[1][1], epty[2][0]]]
            except IndexError:
                print 'Found no Z components for {0}'.format(self.station)
                line_list = [[None], [None], 
                             [None], [None],
                             [None], [None]]
                                     
                self._err_list = [[None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None],
                                  [None, None, None]]
        
        #------------------------------------------
        # make things look nice        
        # set titles of the Z components
        label_list = [['$Z_{xx}$'], ['$Z_{xy}$'], 
                       ['$Z_{yx}$'], ['$Z_{yy}$']] 
        for ax, label in zip(self.ax_list[0:4], label_list):
            ax.set_title(label[0],fontdict={'size':self.plot_settings.fs+2, 
                                          'weight':'bold'}) 
                                          
        # set legends for tipper components
        # fake a line
        l1 = plt.Line2D([0], [0], linewidth=0, color='w', linestyle='None', 
                        marker='.')
        t_label_list = ['Re{$T_x$}', 'Im{$T_x$}', 'Re{$T_y$}', 'Im{$T_y$}']
        label_list += [['$T_{x}$'], ['$T_{y}$']]
        for ax, label in zip(self.ax_list[-4:], t_label_list):
            ax.legend([l1], [label], loc='upper left',
                      markerscale=.01,
                      borderaxespad=.05,
                      labelspacing=.01,
                      handletextpad=.05,
                      borderpad=.05,
                      prop={'size':max([self.plot_settings.fs, 5])})
        
        #--> set limits if input
        if self.plot_settings.res_xx_limits is not None:
            axrxx.set_ylim(self.plot_settings.res_xx_limits)    
        if self.plot_settings.res_xy_limits is not None:
            axrxy.set_ylim(self.plot_settings.res_xy_limits)    
        if self.plot_settings.res_yx_limits is not None:
            axryx.set_ylim(self.plot_settings.res_yx_limits)    
        if self.plot_settings.res_yy_limits is not None:
            axryy.set_ylim(self.plot_settings.res_yy_limits) 
            
        if self.plot_settings.phase_xx_limits is not None:
            axpxx.set_ylim(self.plot_settings.phase_xx_limits)    
        if self.plot_settings.phase_xy_limits is not None:
            axpxy.set_ylim(self.plot_settings.phase_xy_limits)    
        if self.plot_settings.phase_yx_limits is not None:
            axpyx.set_ylim(self.plot_settings.phase_yx_limits)    
        if self.plot_settings.phase_yy_limits is not None:
            axpyy.set_ylim(self.plot_settings.phase_yy_limits) 
    
        #set axis properties
        for aa, ax in enumerate(self.ax_list):
            ax.tick_params(axis='y', pad=self.plot_settings.ylabel_pad)
            ylabels = ax.get_yticks().tolist()
            if aa < 8:
                ylabels[-1] = ''
                ylabels[0] = ''
                ax.set_yticklabels(ylabels)
                plt.setp(ax.get_xticklabels(), visible=False)
                if self.plot_z == True:
                    ax.set_yscale('log', nonposy='clip')

            else:
                ax.set_xlabel('Period (s)', fontdict=fontdict)
                
            if aa < 4 and self.plot_z is False:
                ax.set_yscale('log', nonposy='clip')
                    
            #set axes labels
            if aa == 0:
                if self.plot_z == False:
                    ax.set_ylabel('App. Res. ($\mathbf{\Omega \cdot m}$)',
                                  fontdict=fontdict)
                elif self.plot_z == True:
                    ax.set_ylabel('Re[Z (mV/km nT)]',
                                  fontdict=fontdict)
            elif aa == 4:
                if self.plot_z == False:
                    ax.set_ylabel('Phase (deg)',
                                  fontdict=fontdict)
                elif self.plot_z == True:
                    ax.set_ylabel('Im[Z (mV/km nT)]',
                                  fontdict=fontdict)
            elif aa == 8:
                ax.set_ylabel('Tipper',
                              fontdict=fontdict)
                    
            if aa > 7:
                if self.plot_settings.tipper_limits is not None:
                    ax.set_ylim(self.plot_settings.tipper_limits)
                else:
                    pass

            ax.set_xscale('log', nonposx='clip')
            ax.set_xlim(xmin=10**(np.floor(np.log10(period[0])))*1.01,
                     xmax=10**(np.ceil(np.log10(period[-1])))*.99)
            ax.grid(True, alpha=.25)
            
        ##----------------------------------------------
        #plot model response
        if self.modem_resp is not None:
            resp_z_obj = self.modem_resp.mt_dict[self.station].Z
            resp_z_err = np.nan_to_num((z_obj.z-resp_z_obj.z)/z_obj.z_err)
            resp_z_obj.compute_resistivity_phase()
            
            resp_t_obj = self.modem_resp.mt_dict[self.station].Tipper
            resp_t_err = np.nan_to_num((t_obj.tipper-resp_t_obj.tipper)/t_obj.tipper_err)
            
            #convert to apparent resistivity and phase
            if self.plot_z == True:
                scaling = np.zeros_like(resp_z_obj.z)
                for ii in range(2):
                    for jj in range(2):
                        scaling[:, ii, jj] = 1./np.sqrt(resp_z_obj.freq)
                r_plot_res = abs(resp_z_obj.z.real*scaling)
                r_plot_phase = abs(resp_z_obj.z.imag*scaling)
                
            elif self.plot_z == False:
                r_plot_res = resp_z_obj.resistivity
                r_plot_phase = resp_z_obj.phase

            rms_xx = resp_z_err[nzxx, 0, 0].std()
            rms_xy = resp_z_err[nzxy, 0, 1].std()
            rms_yx = resp_z_err[nzyx, 1, 0].std()
            rms_yy = resp_z_err[nzyy, 1, 1].std()
            
            #--> make key word dictionaries for plotting
            kw_xx = {'color':self.plot_settings.ctem,
                     'marker':self.plot_settings.mtem,
                     'ms':self.plot_settings.ms,
                     'ls':':',
                     'lw':self.plot_settings.lw,
                     'e_capsize':self.plot_settings.e_capsize,
                     'e_capthick':self.plot_settings.e_capthick}        
           
            kw_yy = {'color':self.plot_settings.ctmm,
                     'marker':self.plot_settings.mtmm,
                     'ms':self.plot_settings.ms,
                     'ls':':',
                     'lw':self.plot_settings.lw,
                     'e_capsize':self.plot_settings.e_capsize,
                     'e_capthick':self.plot_settings.e_capthick}
            
            # plot data response
            rerxx = mtplottools.plot_errorbar(axrxx, 
                                             period[nzxx], 
                                             r_plot_res[nzxx, 0, 0], 
                                             None,
                                             **kw_xx)
            rerxy = mtplottools.plot_errorbar(axrxy, 
                                             period[nzxy], 
                                             r_plot_res[nzxy, 0, 1], 
                                             None,
                                             **kw_xx)
            reryx = mtplottools.plot_errorbar(axryx, 
                                             period[nzyx], 
                                             r_plot_res[nzyx, 1, 0], 
                                             None,
                                             **kw_yy)
            reryy = mtplottools.plot_errorbar(axryy, 
                                             period[nzyy], 
                                             r_plot_res[nzyy, 1, 1], 
                                             None,
                                             **kw_yy)
            #plot phase                         
            repxx = mtplottools.plot_errorbar(axpxx, 
                                             period[nzxx], 
                                             r_plot_phase[nzxx, 0, 0], 
                                             None,
                                             **kw_xx)
            repxy = mtplottools.plot_errorbar(axpxy, 
                                             period[nzxy], 
                                             r_plot_phase[nzxy, 0, 1], 
                                             None,
                                             **kw_xx)
            repyx = mtplottools.plot_errorbar(axpyx, 
                                             period[nzyx], 
                                             r_plot_phase[nzyx, 1, 0], 
                                             None,
                                             **kw_yy)
            repyy = mtplottools.plot_errorbar(axpyy, 
                                             period[nzyy], 
                                             r_plot_phase[nzyy, 1, 1], 
                                             None,
                                             **kw_yy)
                                          
            #plot tipper
            if self.plot_tipper == True:
                rertx = mtplottools.plot_errorbar(axtxr, 
                                                 period[ntx],
                                                 resp_t_obj.tipper[ntx, 0, 0].real,
                                                 None,
                                                 **kw_xx)
                rerty = mtplottools.plot_errorbar(axtyr, 
                                                 period[nty],
                                                 resp_t_obj.tipper[nty, 0, 1].real,
                                                 None,
                                                 **kw_yy)
                                         
                reptx = mtplottools.plot_errorbar(axtxi, 
                                                 period[ntx],
                                                 resp_t_obj.tipper[ntx, 0, 0].imag,
                                                 None,
                                                 **kw_xx)
                repty = mtplottools.plot_errorbar(axtyi, 
                                                 period[nty],
                                                 resp_t_obj.tipper[nty, 0, 1].imag,
                                                 None,
                                                 **kw_yy)
                             
            if self.plot_tipper == False:
                line_list[0] += [rerxx[0]]
                line_list[1] += [rerxy[0]]
                line_list[2] += [reryx[0]]
                line_list[3] += [reryy[0]]
                label_list[0] += ['$Z^m_{xx}$ '+
                                   'rms={0:.2f}'.format(rms_xx)]
                label_list[1] += ['$Z^m_{xy}$ '+
                               'rms={0:.2f}'.format(rms_xy)]
                label_list[2] += ['$Z^m_{yx}$ '+
                               'rms={0:.2f}'.format(rms_yx)]
                label_list[3] += ['$Z^m_{yy}$ '+
                               'rms={0:.2f}'.format(rms_yy)]
            else:
                line_list[0] += [rerxx[0]]
                line_list[1] += [rerxy[0]]
                line_list[2] += [reryx[0]]
                line_list[3] += [reryy[0]]
                line_list[4] += [rertx[0]]
                line_list[5] += [rerty[0]]
                label_list[0] += ['$Z^m_{xx}$ '+
                                   'rms={0:.2f}'.format(rms_xx)]
                label_list[1] += ['$Z^m_{xy}$ '+
                               'rms={0:.2f}'.format(rms_xy)]
                label_list[2] += ['$Z^m_{yx}$ '+
                               'rms={0:.2f}'.format(rms_yx)]
                label_list[3] += ['$Z^m_{yy}$ '+
                               'rms={0:.2f}'.format(rms_yy)]
                label_list[4] += ['$T^m_{x}$ '+
                                'rms={0:.2f}'.format(resp_t_err[ntx, 0, 0].std())]
                label_list[5] += ['$T^m_{y}$'+
                                'rms={0:.2f}'.format(resp_t_err[nty, 0, 1].std())]
            
            legend_ax_list = self.ax_list[0:4]
            if self.plot_tipper == True:
                legend_ax_list += [self.ax_list[-4], self.ax_list[-2]]
                
            for aa, ax in enumerate(legend_ax_list):
                ax.legend(line_list[aa],
                          label_list[aa],
                          loc=self.plot_settings.legend_loc,
                          bbox_to_anchor=self.plot_settings.legend_pos,
                          markerscale=self.plot_settings.legend_marker_scale,
                          borderaxespad=self.plot_settings.legend_border_axes_pad,
                          labelspacing=self.plot_settings.legend_label_spacing,
                          handletextpad=self.plot_settings.legend_handle_text_pad,
                          borderpad=self.plot_settings.legend_border_pad,
                          prop={'size':max([self.plot_settings.fs, 5])})
        
        self.mpl_widget.draw()
Пример #3
0
    #                              color=(0, 0.85, 0),
    #                              marker='s',
    #                              ms=5)
    #    l4 = mtplt.plot_errorbar(ax,
    #                              1./b_arr['freq'],
    #                              sps.medfilt(b_arr['azimuth']-p_arr['azimuth'],
    #                                          ks),
    #                              y_error=b_arr['azimuth_err']+p_arr['azimuth_err'],
    #                              color=(0.85, 0.85, 0),
    #                              marker='s',
    #                              ms=5)
    l1 = mtplt.plot_errorbar(
        ax,
        1.0 / b_arr["freq"],
        b_arr["phimin"],
        y_error=b_arr["phimin_err"],
        color="k",
        marker="s",
        ms=5,
    )
    l2 = mtplt.plot_errorbar(
        ax,
        1.0 / p_arr["freq"],
        p_arr["phimin"],
        y_error=p_arr["phimin_err"],
        color=(0, 0, 0.85),
        marker="v",
        ms=5,
    )

    l3 = mtplt.plot_errorbar(
    def plot(self):
        """
        plot the data
        """

        if self.station is None:
            return

        z_obj = self.modem_data.mt_dict[self.station].Z
        t_obj = self.modem_data.mt_dict[self.station].Tipper
        period = self.modem_data.period_list

        plt.rcParams["font.size"] = self.fs

        fontdict = {"size": self.fs + 2, "weight": "bold"}

        # --> make key word dictionaries for plotting
        kw_xx = {
            "color": self.cted,
            "marker": self.mted,
            "ms": self.ms,
            "ls": ":",
            "lw": self.lw,
            "e_capsize": self.e_capsize,
            "e_capthick": self.e_capthick,
        }

        kw_yy = {
            "color": self.ctmd,
            "marker": self.mtmd,
            "ms": self.ms,
            "ls": ":",
            "lw": self.lw,
            "e_capsize": self.e_capsize,
            "e_capthick": self.e_capthick,
        }

        kw_tr = {
            "color": self.ctrd,
            "marker": self.mtmd,
            "ms": self.ms,
            "ls": ":",
            "lw": self.lw,
            "e_capsize": self.e_capsize,
            "e_capthick": self.e_capthick,
        }

        kw_ti = {
            "color": self.ctid,
            "marker": self.mtmd,
            "ms": self.ms,
            "ls": ":",
            "lw": self.lw,
            "e_capsize": self.e_capsize,
            "e_capthick": self.e_capthick,
        }

        # convert to apparent resistivity and phase
        rp = mtplottools.ResPhase(z_object=z_obj)

        # find locations where points have been masked
        nzxx = np.nonzero(z_obj.z[:, 0, 0])[0]
        nzxy = np.nonzero(z_obj.z[:, 0, 1])[0]
        nzyx = np.nonzero(z_obj.z[:, 1, 0])[0]
        nzyy = np.nonzero(z_obj.z[:, 1, 1])[0]
        ntx = np.nonzero(t_obj.tipper[:, 0, 0])[0]
        nty = np.nonzero(t_obj.tipper[:, 0, 1])[0]

        self.figure.clf()
        self.figure.suptitle(str(self.station), fontdict=fontdict)

        # set the grid of subplots
        gs = gridspec.GridSpec(
            3,
            2,
            wspace=self.subplot_wspace,
            left=self.subplot_left,
            top=self.subplot_top,
            bottom=self.subplot_bottom,
            right=self.subplot_right,
            hspace=self.subplot_hspace,
            height_ratios=[1, 1, 0.4],
        )

        # od for off diagonal components, d for diagonal
        axrod = self.figure.add_subplot(gs[0, 0])
        axrd = self.figure.add_subplot(gs[0, 1], sharex=axrod)

        axpod = self.figure.add_subplot(gs[1, 0])
        axpd = self.figure.add_subplot(gs[1, 1], sharex=axrod)

        axtx = self.figure.add_subplot(gs[2, 0], sharex=axrod)
        axty = self.figure.add_subplot(gs[2, 1], sharex=axrod)

        if self.plot_z == False:
            # plot resistivity
            erxx = mtplottools.plot_errorbar(axrd, period[nzxx], rp.resxx[nzxx], rp.resxx_err[nzxx], **kw_xx)
            erxy = mtplottools.plot_errorbar(axrod, period[nzxy], rp.resxy[nzxy], rp.resxy_err[nzxy], **kw_xx)
            eryx = mtplottools.plot_errorbar(axrod, period[nzyx], rp.resyx[nzyx], rp.resyx_err[nzyx], **kw_yy)
            eryy = mtplottools.plot_errorbar(axrd, period[nzyy], rp.resyy[nzyy], rp.resyy_err[nzyy], **kw_yy)
            # plot phase
            erxx = mtplottools.plot_errorbar(axpd, period[nzxx], rp.phasexx[nzxx], rp.phasexx_err[nzxx], **kw_xx)
            erxy = mtplottools.plot_errorbar(axpod, period[nzxy], rp.phasexy[nzxy], rp.phasexy_err[nzxy], **kw_xx)
            eryx = mtplottools.plot_errorbar(axpod, period[nzyx], rp.phaseyx[nzyx], rp.phaseyx_err[nzyx], **kw_yy)
            eryy = mtplottools.plot_errorbar(axpd, period[nzyy], rp.phaseyy[nzyy], rp.phaseyy_err[nzyy], **kw_yy)
        elif self.plot_z == True:
            # plot real
            erxx = mtplottools.plot_errorbar(
                axrd, period[nzxx], z_obj.z[nzxx, 0, 0].real, z_obj.z_err[nzxx, 0, 0].real, **kw_xx
            )
            erxy = mtplottools.plot_errorbar(
                axrod, period[nzxy], z_obj.z[nzxy, 0, 1].real, z_obj.z_err[nzxy, 0, 1].real, **kw_xx
            )
            eryx = mtplottools.plot_errorbar(
                axrod, period[nzyx], z_obj.z[nzyx, 1, 0].real, z_obj.z_err[nzyx, 1, 0].real, **kw_yy
            )
            eryy = mtplottools.plot_errorbar(
                axrd, period[nzyy], z_obj.z[nzyy, 1, 1].real, z_obj.z_err[nzyy, 1, 1].real, **kw_yy
            )
            # plot phase
            erxx = mtplottools.plot_errorbar(
                axpd, period[nzxx], z_obj.z[nzxx, 0, 0].imag, z_obj.z_err[nzxx, 0, 0].real, **kw_xx
            )
            erxy = mtplottools.plot_errorbar(
                axpod, period[nzxy], z_obj.z[nzxy, 0, 1].imag, z_obj.z_err[nzxy, 0, 1].real, **kw_xx
            )
            eryx = mtplottools.plot_errorbar(
                axpod, period[nzyx], z_obj.z[nzyx, 1, 0].imag, z_obj.z_err[nzyx, 1, 0].real, **kw_yy
            )
            eryy = mtplottools.plot_errorbar(
                axpd, period[nzyy], z_obj.z[nzyy, 1, 1].imag, z_obj.z_err[nzyy, 1, 1].real, **kw_yy
            )

        # plot tipper
        ertxr = mtplottools.plot_errorbar(
            axtx, period[ntx], t_obj.tipper[ntx, 0, 0].real, t_obj.tipper_err[ntx, 0, 0], **kw_tr
        )
        ertxi = mtplottools.plot_errorbar(
            axtx, period[ntx], t_obj.tipper[ntx, 0, 0].imag, t_obj.tipper_err[ntx, 0, 1], **kw_ti
        )
        ertyr = mtplottools.plot_errorbar(
            axty, period[nty], t_obj.tipper[nty, 0, 1].real, t_obj.tipper_err[nty, 0, 0], **kw_tr
        )

        ertyi = mtplottools.plot_errorbar(
            axty, period[nty], t_obj.tipper[nty, 0, 1].imag, t_obj.tipper_err[nty, 0, 1], **kw_ti
        )
        ax_list = [axrod, axrd, axpod, axpd, axtx, axty]

        od_line_list = [erxy[0], eryx[0], ertxr[0], ertxi[0]]
        d_line_list = [erxx[0], eryy[0], ertyr[0], ertyi[0]]

        od_label_list = ["$Z_{xy}$", "$Z_{yx}$", "Re{$T_{x}$}", "Im{$T_{x}$}"]
        d_label_list = ["$Z_{xx}$", "$Z_{yy}$", "Re{$T_{y}$}", "Im{$T_{y}$}"]

        # --> set limits if input
        if self.res_xx_limits is not None:
            axrd.set_ylim(self.res_xx_limits)
        if self.res_xy_limits is not None:
            axrod.set_ylim(self.res_xy_limits)

        if self.phase_xx_limits is not None:
            axpd.set_ylim(self.phase_xx_limits)
        if self.phase_xy_limits is not None:
            axpod.set_ylim(self.phase_xy_limits)

        #        axtx.set_ylim((-1.1, 1.1))
        #        axty.set_ylim((-1.1, 1.1))

        # set axis properties
        for aa, ax in enumerate(ax_list):
            ax.tick_params(axis="y", pad=self.ylabel_pad)
            ylabels = ax.get_yticks().tolist()
            if aa == 2 or aa == 3 or aa == 4 or aa == 5:
                ylabels[-1] = ""
                ylabels[0] = ""
                ax.set_yticklabels(ylabels)

            if aa < 2:
                if self.plot_z == False:
                    ax.set_yscale("log")

            if aa < 4:
                plt.setp(ax.get_xticklabels(), visible=False)

            else:
                ax.set_xlabel("Period (s)", fontdict=fontdict)

            # set axes labels
            if aa == 0:
                if self.plot_z == False:
                    ax.set_ylabel("App. Res. ($\mathbf{\Omega \cdot m}$)", fontdict=fontdict)
                elif self.plot_z == True:
                    ax.set_ylabel("Re[Z (mV/km nT)]", fontdict=fontdict)

                ax.legend(
                    od_line_list,
                    od_label_list,
                    loc=self.legend_loc,
                    ncol=2,
                    bbox_to_anchor=self.legend_pos,
                    markerscale=self.legend_marker_scale,
                    borderaxespad=self.legend_border_axes_pad,
                    labelspacing=self.legend_label_spacing,
                    handletextpad=self.legend_handle_text_pad,
                    borderpad=self.legend_border_pad,
                    prop={"size": max([self.fs - 1, 5])},
                )

            elif aa == 1:
                ax.legend(
                    d_line_list,
                    d_label_list,
                    loc=self.legend_loc,
                    ncol=2,
                    bbox_to_anchor=self.legend_pos,
                    markerscale=self.legend_marker_scale,
                    borderaxespad=self.legend_border_axes_pad,
                    labelspacing=self.legend_label_spacing,
                    handletextpad=self.legend_handle_text_pad,
                    borderpad=self.legend_border_pad,
                    prop={"size": max([self.fs - 1, 5])},
                )
            elif aa == 2:
                if self.plot_z == False:
                    ax.set_ylabel("Phase (deg)", fontdict=fontdict)
                elif self.plot_z == True:
                    ax.set_ylabel("Im[Z (mV/km nT)]", fontdict=fontdict)

            elif aa == 4:
                ax.set_ylabel(r"W$_x$", fontdict=fontdict)

            elif aa == 5:
                ax.set_ylabel(r"W$_y$", fontdict=fontdict)

            ax.set_xscale("log")
            ax.set_xlim(
                xmin=10 ** (np.floor(np.log10(period[0]))) * 1.01, xmax=10 ** (np.ceil(np.log10(period[-1]))) * 0.99
            )
            ax.grid(True, alpha=0.25)

        # plot model response
        if self.modem_resp is not None:
            resp_z_obj = self.modem_resp.mt_dict[self.station].Z
            resp_z_err = np.nan_to_num((z_obj.z - resp_z_obj.z) / z_obj.z_err)

            resp_t_obj = self.modem_resp.mt_dict[self.station].Tipper

            rrp = mtplottools.ResPhase(resp_z_obj)

            rms = resp_z_err.std()
            rms_xx = resp_z_err[:, 0, 0].std()
            rms_xy = resp_z_err[:, 0, 1].std()
            rms_yx = resp_z_err[:, 1, 0].std()
            rms_yy = resp_z_err[:, 1, 1].std()

            # --> make key word dictionaries for plotting
            kw_xx = {
                "color": self.ctem,
                "marker": self.mtem,
                "ms": self.ms,
                "ls": ":",
                "lw": self.lw,
                "e_capsize": self.e_capsize,
                "e_capthick": self.e_capthick,
            }

            kw_yy = {
                "color": self.ctmm,
                "marker": self.mtmm,
                "ms": self.ms,
                "ls": ":",
                "lw": self.lw,
                "e_capsize": self.e_capsize,
                "e_capthick": self.e_capthick,
            }

            kw_tr = {
                "color": self.ctrm,
                "marker": self.mtmd,
                "ms": self.ms,
                "ls": ":",
                "lw": self.lw,
                "e_capsize": self.e_capsize,
                "e_capthick": self.e_capthick,
            }

            kw_ti = {
                "color": self.ctim,
                "marker": self.mtmd,
                "ms": self.ms,
                "ls": ":",
                "lw": self.lw,
                "e_capsize": self.e_capsize,
                "e_capthick": self.e_capthick,
            }

            if self.plot_z == False:
                # plot resistivity
                rerxx = mtplottools.plot_errorbar(axrd, period[nzxx], rrp.resxx[nzxx], **kw_xx)
                rerxy = mtplottools.plot_errorbar(axrod, period[nzxy], rrp.resxy[nzxy], **kw_xx)
                reryx = mtplottools.plot_errorbar(axrod, period[nzyx], rrp.resyx[nzyx], **kw_yy)
                reryy = mtplottools.plot_errorbar(axrd, period[nzyy], rrp.resyy[nzyy], **kw_yy)
                # plot phase
                rerxx = mtplottools.plot_errorbar(axpd, period[nzxx], rrp.phasexx[nzxx], **kw_xx)
                rerxy = mtplottools.plot_errorbar(axpod, period[nzxy], rrp.phasexy[nzxy], **kw_xx)
                reryx = mtplottools.plot_errorbar(axpod, period[nzyx], rrp.phaseyx[nzyx], **kw_yy)
                reryy = mtplottools.plot_errorbar(axpd, period[nzyy], rrp.phaseyy[nzyy], **kw_yy)
            elif self.plot_z == True:
                # plot real
                rerxx = mtplottools.plot_errorbar(axrd, period[nzxx], resp_z_obj.z[nzxx, 0, 0].real, **kw_xx)
                rerxy = mtplottools.plot_errorbar(axrod, period[nzxy], resp_z_obj.z[nzxy, 0, 1].real, **kw_xx)
                reryx = mtplottools.plot_errorbar(axrod, period[nzyx], resp_z_obj.z[nzyx, 1, 0].real, **kw_yy)
                reryy = mtplottools.plot_errorbar(axrd, period[nzyy], resp_z_obj.z[nzyy, 1, 1].real, **kw_yy)
                # plot phase
                rerxx = mtplottools.plot_errorbar(axpd, period[nzxx], resp_z_obj.z[nzxx, 0, 0].imag, **kw_xx)
                rerxy = mtplottools.plot_errorbar(axpod, period[nzxy], resp_z_obj.z[nzxy, 0, 1].imag, **kw_xx)
                reryx = mtplottools.plot_errorbar(axpod, period[nzyx], resp_z_obj.z[nzyx, 1, 0].imag, **kw_yy)
                reryy = mtplottools.plot_errorbar(axpd, period[nzyy], resp_z_obj.z[nzyy, 1, 1].imag, **kw_yy)

            rertx = mtplottools.plot_errorbar(axtx, period[ntx], resp_t_obj.tipper[ntx, 0, 0].real, **kw_tr)
            rerty = mtplottools.plot_errorbar(axtx, period[ntx], resp_t_obj.tipper[ntx, 0, 1].imag, **kw_ti)

            rertx = mtplottools.plot_errorbar(axty, period[nty], resp_t_obj.tipper[nty, 0, 0].real, **kw_tr)
            rerty = mtplottools.plot_errorbar(axty, period[nty], resp_t_obj.tipper[nty, 0, 1].imag, **kw_ti)

            # add laines and labels
            od_line_list += [rerxy[0], reryx[0], rertx[0], rerty[0]]
            d_line_list += [rerxx[0], reryy[0], rertx[0], rerty[0]]

            od_label_list += [
                "$Z^m_{xy}$" + "rms={0:.2f}".format(rms_xy),
                "$Z^m_{yx}$" + "rms={0:.2f}".format(rms_yx),
                "Re{$T^m_{x}$}",
                "Im{$T^m_{x}$}",
            ]
            d_label_list += [
                "$Z^m_{xx}$" + "rms={0:.2f}".format(rms_xx),
                "$Z^m_{yy}$" + "rms={0:.2f}".format(rms_yy),
                "Re{$T^m_{x}$}",
                "Im{$T^m_{x}$}",
            ]

            legend_ax_list = [axrod, axrd]
            od_label_list = od_label_list[0:2] + od_label_list[4:6] + od_label_list[2:4] + od_label_list[6:8]
            d_label_list = d_label_list[0:2] + d_label_list[4:6] + d_label_list[2:4] + d_label_list[6:8]

            od_line_list = od_line_list[0:2] + od_line_list[4:6] + od_line_list[2:4] + od_line_list[6:8]
            d_line_list = d_line_list[0:2] + d_line_list[4:6] + d_line_list[2:4] + d_line_list[6:8]

            legend_ll = [od_line_list, d_line_list]
            legend_tl = [od_label_list, d_label_list]

            for ax, ll, tl in zip(legend_ax_list, legend_ll, legend_tl):
                ax.legend(
                    ll,
                    tl,
                    loc=self.legend_loc,
                    ncol=4,
                    bbox_to_anchor=self.legend_pos,
                    markerscale=self.legend_marker_scale,
                    borderaxespad=self.legend_border_axes_pad,
                    labelspacing=self.legend_label_spacing,
                    handletextpad=self.legend_handle_text_pad,
                    borderpad=self.legend_border_pad,
                    prop={"size": max([self.fs - 1, 5])},
                )

        self.mpl_widget.draw()
Пример #5
0
    #                                                  ks),
    #                              color=(0, 0.85, 0),
    #                              marker='s',
    #                              ms=5)
    #    l4 = mtplt.plot_errorbar(ax,
    #                              1./b_arr['freq'],
    #                              sps.medfilt(b_arr['azimuth']-p_arr['azimuth'],
    #                                          ks),
    #                              y_error=b_arr['azimuth_err']+p_arr['azimuth_err'],
    #                              color=(0.85, 0.85, 0),
    #                              marker='s',
    #                              ms=5)
    l1 = mtplt.plot_errorbar(ax,
                             1. / b_arr['freq'],
                             b_arr['phimin'],
                             y_error=b_arr['phimin_err'],
                             color='k',
                             marker='s',
                             ms=5)
    l2 = mtplt.plot_errorbar(ax,
                             1. / p_arr['freq'],
                             p_arr['phimin'],
                             y_error=p_arr['phimin_err'],
                             color=(0, 0, .85),
                             marker='v',
                             ms=5)

    l3 = mtplt.plot_errorbar(ax,
                             1. / b_arr['freq'],
                             b_arr['phimax'],
                             y_error=b_arr['phimax_err'],