def _test_func(self): if not os.path.isdir(edi_path): # input file does not exist, skip test after remove the output dir os.rmdir(self._output_dir) self.skipTest("edi path does not exist: {}".format(edi_path)) # generate data edi_list = glob.glob(edi_path + '/*.edi') period_list = EdiCollection(edi_list).select_periods() datob = Data(edi_list=edi_list, inv_mode='1', period_list=period_list, epsg=epsg_code, error_type_tipper='abs', error_type_z='egbert', comp_error_type=None, error_floor=10) datob.write_data_file(save_path=self._output_dir) # create mesh grid model object model = Model( stations_object=datob.station_locations, Data=datob, epsg=epsg_code, cell_size_east=10000, cell_size_north=10000, # GA_VIC pad_north= 8, # number of padding cells in each of the north and south directions pad_east=8, # number of east and west padding cells pad_z=8, # number of vertical padding cells pad_stretch_v= 1.5, # factor to increase by in padding cells (vertical) pad_stretch_h= 1.5, # factor to increase by in padding cells (horizontal) n_air_layers= 0, # number of air layers 0, 10, 20, depend on topo elev height res_model= 100, # halfspace resistivity value for initial reference model n_layers=50, # total number of z layers, including air and pad_z z1_layer=50, # first layer thickness metres, depend z_target_depth=500000) model.make_mesh( ) # the data file will be re-write in this method. No topo elev file used yet model.plot_mesh() model.plot_mesh_xy() model.plot_mesh_xz() # write a model file and initialise a resistivity model model.write_model_file(save_path=self._output_dir)
pad_z=6, # number of vertical padding cells pad_stretch_v=1.6, # factor to increase by in padding cells (vertical) pad_stretch_h=1.4, # factor to increase by in padding cells (horizontal) n_air_layers=10, #number of air layers res_model=100, # halfspace resistivity value for reference model n_layers=100, # total number of z layers, including air z1_layer=10, # first layer thickness pad_method='stretch', # method for calculating padding z_mesh_method='new', z_target_depth= 120000, # depth to bottom of core model (padding after this depth) # rotation_angle = -45 ) mo.make_mesh() mo.write_model_file(save_path=workdir) mo.plot_mesh() ## add topography to res model #mo.add_topography_to_model2(r'C:\mtpywin\mtpy\examples\data\AussieContinent_etopo1.asc') #mo.write_model_file(save_path=workdir) # update data elevations do.project_stations_on_topography(mo) co = Covariance() co.smoothing_east = 0.4 co.smoothing_north = 0.4 co.smoothing_z = 0.4 co.write_covariance_file(model_fn=mo.model_fn)
8, # number of padding cells in each of the north and south directions pad_east=8, # number of east and west padding cells pad_z=8, # number of vertical padding cells pad_stretch_v=1.5, # factor to increase by in padding cells (vertical) pad_stretch_h=1.5, # factor to increase by in padding cells (horizontal) n_airlayers= 10, # number of air layers 0, 10, 20, depend on topo elev height res_model=100, # halfspace resistivity value for initial reference model n_layers=55, # total number of z layers, including air and pad_z z1_layer=50, # first layer thickness metres, depend z_target_depth=500000) model.make_mesh( ) # the data file will be re-write in this method. No topo elev file used yet model.plot_mesh() model.plot_mesh_xy() model.plot_mesh_xz() # write a model file and initialise a resistivity model model.write_model_file(save_path=outputdir) #=========== now add topo data, with or without air layers? # 1) the data file will be changed in 3 columns sxi, syi and szi meters # 2) The covariance file will be written. # 3) the model file not changed?? No air layers can be seen in the .ws file. # add topography, define an initial resistivity model, modify and re-write the data file, define covariance mask # dat file will be changed and rewritten, # grid centre is used as the new origin of coordinate system, topo data used in the elev column.
def run(self): # monkey patch plt.show() so the plot is not displayed in worker thread true_plt_show = plt.show plt.show = _fake_plt_show self._figures = [] try: if not os.path.exists(self.output_dir): os.mkdir(self.output_dir) # get period_list list self.status_updated.emit("Selecting Periods...") period_list = EdiCollection(self._edi_list).select_periods(**self._select_period_kwargs) # save period plot for reference figure = plt.gcf() figure.savefig(os.path.join(self.output_dir, self._period_image_name)) if self.show: self.figure_updated.emit('Period Distribution', figure) # data object self.status_updated.emit("Creating ModEM Data Object...") self._data_kwargs['period_list'] = period_list data = Data(edi_list=self._edi_list, **self._data_kwargs) # write data file self.status_updated.emit("Writing Initial ModEM Data File...") data.write_data_file() # create model self.status_updated.emit("Creating Mesh Model...") model = Model(data_object=data, **self._mesh_kwagrs) model.make_mesh() # plot mesh model.plot_mesh(fig_num=plt.gcf().number + 1) figure = plt.gcf() figure.savefig(os.path.join(self.output_dir, self._mesh_image_name)) if self.show: self.figure_updated.emit("Mesh", figure) # model.plot_mesh_xy() # self.figure_updated.emit("Mesh XY", plt.gcf()) # model.plot_mesh_xz() # self.figure_updated.emit("Mesh XZ", plt.gcf()) model.write_model_file() # add topography self.status_updated.emit("Adding Topography...") model.add_topography_to_mesh(**self._topo_args) if self.show: model.plot_topograph() # this is too slow so only plot and save image when asked figure = plt.gcf() figure.savefig(os.path.join(self.output_dir, self._topo_image_name)) self.figure_updated.emit("Topography", figure) self.status_updated.emit("Updating Mesh Model...") model.write_model_file() # covariance self.status_updated.emit("Creating Covariance File...") self._covariance_kwargs['mask_arr'] = model.covariance_mask cov = Covariance(**self._covariance_kwargs) self.status_updated.emit("Writing Covariance File...") cov.write_covariance_file(model_fn=model.model_fn, sea_water=self._topo_args['sea_resistivity'], air=self._topo_args['air_resistivity']) self.status_updated.emit("Creating README File...") self.write_readme(os.path.join(self.output_dir, self._readme_name)) # done self.status_updated.emit("Finishing...") except Exception as e: frm = inspect.trace()[-1] mod = inspect.getmodule(frm[0]) self.export_error.emit("{}: {}".format(mod.__name__, e.message)) # restore plt.show() plt.show = true_plt_show