def fold(self): edi_file_list = glob.glob(os.path.join(edi_path, "*.edi")) # fold pt_obj = PlotStrike(fn_list=edi_file_list, plot_yn='n', fold=False, fig_size=(8, 6), fig_dpi=100) pt_obj.plot() plt.pause(1)
def tipper(self): edi_file_list = glob.glob(os.path.join(edi_path, "*.edi")) # plot_tipper pt_obj = PlotStrike(fn_list=edi_file_list, plot_yn='n', plot_tipper='y', fig_size=(8, 6), fig_dpi=100) pt_obj.plot() plt.pause(1)
def rotation(self): edi_file_list = glob.glob(os.path.join(edi_path, "*.edi")) # change rotation pt_obj = PlotStrike(fn_list=edi_file_list, plot_yn='n', rot_z=90, fig_size=(8, 6), fig_dpi=100) pt_obj.plot() plt.pause(1)
def default(self): edi_file_list = glob.glob(os.path.join(edi_path, "*.edi")) pt_obj = PlotStrike(fn_list=edi_file_list, plot_yn='n', save_figure_path=self._temp_dir, fig_size=(8, 6), fig_dpi=100) pt_obj.plot() plt.pause(1) save_figure_name = "{}.png".format(default.__name__) save_figure_path = os.path.join(self._temp_dir, save_figure_name) pt_obj.save_plot(save_figure_path, file_format='png', close_plot='n') assert (os.path.isfile(save_figure_path))
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\u64125\AppData\Local\Continuum\Miniconda2\envs\mtpy27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile execfile(filename, namespace) File "C:\Users\u64125\AppData\Local\Continuum\Miniconda2\envs\mtpy27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile exec(compile(scripttext, filename, 'exec'), glob, loc) File "C:/Git/mtpy/examples/tests/plot_strike.py", line 21, in <module> plotstrike = PlotStrike(fn_list=elst) File "mtpy\imaging\plotstrike.py", line 240, in __init__ self.plot() File "mtpy\imaging\plotstrike.py", line 307, in plot zinv = mt.get_Zinvariants() AttributeError: 'MTplot' object has no attribute 'get_Zinvariants' """ import os os.chdir(r'C:\Git\mtpy') from mtpy.imaging.plotstrike import PlotStrike import os.path as op import matplotlib.pyplot as plt # path to edis epath = r'C:\Git\mtpy\examples\data\edi_files' elst = [ op.join(epath, edi) for edi in os.listdir(epath) if edi.endswith('.edi') ][::4] plotstrike = PlotStrike(fn_list=elst)
strike analysis using roseplot function """ import os.path as op import os os.chdir(r'C:\mtpywin\mtpy') # change to path where mtpy is installed from mtpy.imaging.plotstrike import PlotStrike # directory containing edis edipath = r'C:\mtpywin\mtpy\examples\data\edi_files_2' # full path to file to save to savepath = r'C:\mtpywin\mtpy\examples\plots\edi_plots' # gets edi file names as a list elst = [ op.join(edipath, f) for f in os.listdir(edipath) if (f.endswith('.edi')) ] # and f.startswith('GL') strikeplot = PlotStrike( fn_list=elst, fold=False, show_ptphimin=False, plot_type=2 # 1 means divide into separate plots for different decades # 2 means combine all data into one rose plot ) #strikeplot.save_plot(savepath, # file_format='png', # fig_dpi=400 # )
strike analysis using roseplot function """ import os.path as op import os os.chdir(r'C:\mtpywin\mtpy') # change to path where mtpy is installed from mtpy.imaging.plotstrike import PlotStrike # directory containing edis edipath = r'C:\mtpywin\mtpy\examples\data\edi_files_2' # full path to file to save to savepath = r'C:\mtpywin\mtpy\examples\plots\edi_plots' # gets edi file names as a list elst = [op.join(edipath,f) for f in os.listdir(edipath) if (f.endswith('.edi'))]# and f.startswith('GL') strikeplot = PlotStrike(fn_list=elst, plot_type=1 # 1 means divide into separate plots for different decades # 2 means combine all data into one rose plot ) strikeplot.save_plot(savepath, file_format='png', fig_dpi=400 )
def analysis_edi(datadir): """ analysis """ # Define the path to your edi file edi_file = datadir + r"edifiles2\15125A.edi" savepath = datadir edi_path = datadir + 'edifiles2' # Create an MT object mt_obj = MT(edi_file) # look at the skew values as a histogram plt.hist(mt_obj.pt.beta, bins=50) plt.xlabel('Skew angle (degree)') plt.ylabel('Number of values') plt.show() # Have a look at the dimensionality dim = dimensionality(z_object=mt_obj.Z, skew_threshold=5, eccentricity_threshold=0.1) print(dim) # calculate strike strike = strike_angle(z_object=mt_obj.Z, skew_threshold=5, eccentricity_threshold=0.1) # display the median strike angle for this station # two values because of 90 degree ambiguity in strike strikemedian = np.nanmedian(strike, axis=0) print(strikemedian) # Use dimensionality to mask a file mask = dim < 3 # Apply masking. The new arrays z_array, z_err_array, and freq will # exclude values where mask is False (i.e. the 3D parts) new_Z_obj = Z(z_array=mt_obj.Z.z[mask], z_err_array=mt_obj.Z.z_err[mask], freq=mt_obj.Z.freq[mask]) new_Tipper_obj = Tipper(tipper_array=mt_obj.Tipper.tipper[mask], tipper_err_array=mt_obj.Tipper.tipper_err[mask], freq=mt_obj.Tipper.freq[mask]) # Write a new edi file mt_obj.write_mt_file(save_dir=savepath, fn_basename='Synth00_mask3d', file_type='edi', new_Z_obj=new_Z_obj, new_Tipper_obj=new_Tipper_obj, longitude_format='LONG', latlon_format='dd') # Plot strike # Get full path to all files with the extension '.edi' in edi_path edi_list = [ os.path.join(edi_path, ff) for ff in os.listdir(edi_path) if ff.endswith('.edi') ] # make a plot (try also plot_type = 1 to plot by decade) strikeplot = PlotStrike(fn_list=edi_list, plot_type=2, plot_tipper='y') # save to file # strikeplot.save_plot(savepath, # file_format='.png', # fig_dpi=400) strike = strikemedian[0] # 0 index chosen based on geological information mt_obj.Z.rotate(strike) mt_obj.Tipper.rotate(strike) # check the rotation angle print(mt_obj.Z.rotation_angle) # Write a new edi file (as before) mt_obj.write_mt_file(save_dir=savepath, fn_basename='Synth00_rotate%1i' % strike, file_type='edi', longitude_format='LONG', latlon_format='dd')