def data_fn(self, data_fn): self._data_fn = data_fn # create new modem data object self.ws_data = ws.WSData() self.ws_data.read_data_file(self._data_fn, station_fn=self.station_fn) # make a back up copy that will be unchanged # that way we can revert back self._ws_data_copy = ws.WSData() self._ws_data_copy.read_data_file(self._data_fn) self.dirpath = os.path.dirname(self._data_fn) # fill list of stations station_list = sorted(self.ws_data.data['station']) self.list_widget.clear() for station in station_list: self.list_widget.addItem(station) self.station = station_list[0] self.plot()
ws_mesh.plot_mesh() ws_mesh.write_initial_file(initial_fn=os.path.join(save_path, 'WSInitialMesh'), res_list=[100]) #ws_mesh = ws.WSMesh() #ws_mesh.read_initial_file(r"/home/jpeacock/Documents/wsinv3d/LV/WSInitialModel_small") #ws_mesh.station_fn = r"/home/jpeacock/Documents/wsinv3d/LV/WS_Station_Locations_small.txt" #ws_stations = ws.WSStation() #ws_stations.read_station_file(ws_mesh.station_fn) #ws_mesh.station_locations = ws_stations.station_locations.copy() #ws_mesh.plot_mesh() #--> make data files folder = 'sm_modem_inv1' ws_data = ws.WSData(edi_list=edi_list, period_list=inv_periods, station_fn=ws_mesh.station_fn) ws_data.n_z = 8 ws_data.z_err = .07 ws_data.z_err_map = [10, 1, 1, 10] ws_data.z_err_floor = .07 sv_path = os.path.join(save_path, '{0}'.format(folder)) if not os.path.isdir(sv_path): os.mkdir(sv_path) ws_data.write_data_file(save_path=sv_path, data_basename='WS_data_{0}_8_small.dat'.format(folder)) ws_data_fn = os.path.join(save_path, 'Inv1_{0}'.format(folder), 'WS_data_{0}_8_small.dat'.format(folder)) ws_startup = ws.WSStartup(data_fn=os.path.basename(ws_data_fn), initial_fn=os.path.basename(ws_mesh.initial_fn))
ws_model_fn = r"c:\MinGW32-xy\Peacock\wsinv3d\MB_MT\Coarse2Fine_Inv2\mb_model.09" ws_data_fn = r"c:\MinGW32-xy\Peacock\wsinv3d\MB_MT\Coarse2Fine_Inv2\WSDataFile.dat" model_fn = r"c:\MinGW32-xy\Peacock\ModEM\WS_StartingModel_03b\Modular_NLCG_012.rho" data_fn = r"c:\MinGW32-xy\Peacock\ModEM\WS_StartingModel_03b\mb_data.dat" md = modem.Data() md.read_data_file(data_fn) mod_model = modem.Model() mod_model.read_model_file(model_fn) new_mod_model = modem.Model() wsd = ws.WSData() wsd.read_data_file(ws_data_fn) wsm = ws.WSModel() wsm.model_fn = ws_model_fn wsm.read_model_file() new_mod_model.station_locations = md.coord_array.copy() new_mod_model.cell_size_east = 500 new_mod_model.cell_size_north = 500 new_mod_model.n_layers = 43 new_mod_model.z1_layer = 10 new_mod_model.pad_east = 12 new_mod_model.pad_north = 12 new_mod_model.pad_stretch_h = 1.5 new_mod_model.z_bottom = 200000
ws_station_fn = r"/home/jpeacock/Documents/wsinv3d/LV/Inv_lv_coarse_2/WS_Station_Locations.txt" #difference between modem and ws grids shift_east = -7000. shift_north = 500. modem_data = modem.Data() modem_data.read_data_file(data_fn) modem_mod = modem.Model() modem_mod.read_model_file(modem_model_fn) ws_mesh = ws.WSMesh() ws_mesh.read_initial_file(ws_init_fn) ws_data = ws.WSData() ws_data.read_data_file(data_fn=ws_data_fn, station_fn=ws_station_fn) print 'Start Time = {0}'.format(time.ctime()) pad = 1 north, east = np.broadcast_arrays(modem_mod.grid_north[:, None], modem_mod.grid_east[None, :]) #2) do a 2D interpolation for each layer, much faster new_res = np.zeros((ws_mesh.grid_north.shape[0], ws_mesh.grid_east.shape[0], ws_mesh.grid_z.shape[0])) for zz in range(ws_mesh.grid_z.shape[0]): try: old_zz = np.where(modem_mod.grid_z >= ws_mesh.grid_z[zz])[0][0]
save_path = r"c:\Users\jrpeacock\Documents\kates_data\Inv_01" # 2) make a grid from the stations themselves with 200m cell spacing wsmesh = ws.WSMesh(edi_list=edi_list, cell_size_east=12500, cell_size_north=12500) wsmesh.save_path = save_path wsmesh.make_mesh() # check to see if the mesh is what you think it should be # wsmesh.plot_mesh() # all is good write the mesh file wsmesh.res_list = np.logspace(-1, 3, 8) wsmesh.write_initial_file(save_path=save_path) # note this will write a file with relative station locations # change the starting model to be different than a halfspace mm = ws.WSModelManipulator(initial_fn=wsmesh.initial_fn) # an interactive gui will pop up to change the resistivity model # once finished write a new initial file mm.rewrite_initial_file() # 3) write data file wsdata = ws.WSData(edi_list=edi_list, period_list=p_list, station_fn=wsmesh.station_fn) wsdata.save_path = save_path wsdata.write_data_file() # 4) plot mt response to make sure everything looks ok # rp = ws.PlotResponse(data_fn=wsdata.data_fn) # 5) make startup file sws = ws.WSStartup(data_fn=wsdata.data_fn, initial_fn=mm.initial_fn) sws.save_path = save_path sws.error_tol = 5 sws.write_startup_file()