def __init__(self): super(ModEM_Mesh_Window, self).__init__() self.period_list = [] self.period_dict = {} self.modem_model = modem.Model() self.ui_setup()
def __init__(self): super(MeshWidget, self).__init__() self.model_obj = modem.Model() self.mpl_widget = MeshPlot() #sys.stdout = MyStream() self.setup_ui()
def interpolate_grid(self, pad_east=None, pad_north=None, cell_size=None): """ interpolate the irregular model grid onto a regular grid. """ model_obj = modem.Model() model_obj.model_fn = self.model_fn model_obj.read_model_file() self.grid_z = model_obj.grid_z.copy() if cell_size is not None: self.cell_size_east = cell_size self.cell_size_north = cell_size else: self.cell_size_east = np.median(model_obj.nodes_east) self.cell_size_north = np.median(model_obj.nodes_north) if pad_east is not None: self.pad_east = pad_east if self.pad_east is None: self.pad_east = np.where(model_obj.nodes_east[0:10] > self.cell_size_east*1.1)[0][-1] if pad_north is not None: self.pad_north = pad_north if self.pad_north is None: self.pad_north = np.where(model_obj.nodes_north[0:10] > self.cell_size_north*1.1)[0][-1] new_east = np.arange(model_obj.grid_east[self.pad_east], model_obj.grid_east[-self.pad_east-1], self.cell_size_east) new_north = np.arange(model_obj.grid_north[self.pad_north], model_obj.grid_north[-self.pad_north-1], self.cell_size_north) model_n, model_e = np.broadcast_arrays(model_obj.grid_north[:, None], model_obj.grid_east[None, :]) new_res_arr = np.zeros((new_north.shape[0], new_east.shape[0], model_obj.grid_z.shape[0])) for z_index in range(model_obj.grid_z.shape[0]): res = model_obj.res_model[:, :, z_index] new_res_arr[:, :, z_index] = interpolate.griddata( (model_n.ravel(), model_e.ravel()), res.ravel(), (new_north[:, None], new_east[None, :])) self.res_array = new_res_arr
def _get_model(self): """ get model to put into array """ model_obj = modem.Model() model_obj.model_fn = self.model_fn model_obj.read_model_file() self.cell_size_east = np.median(model_obj.nodes_east) self.cell_size_north = np.median(model_obj.nodes_north) self.pad_east = np.where( model_obj.nodes_east[0:10] > self.cell_size_east * 1.1)[0][-1] self.pad_north = np.where( model_obj.nodes_north[0:10] > self.cell_size_north * 1.1)[0][-1] self.grid_z = model_obj.grid_z.copy() self.res_array = model_obj.res_model[self.pad_north:-self.pad_north, self.pad_east:-self.pad_east, :]
r"/home/jpeacock/Documents/ModEM/LV/sm_avg_inv2/lv_sm_avg_err07_NLCG_057.rho" ) mfn_avg_3 = r"/home/jpeacock/Documents/ModEM/LV/sm_avg_all_cov5/lv_avg_all_NLCG_069.rho" mfn_avg_sm1 = r"/home/jpeacock/Documents/ModEM/LV/sm_avg_cov5/lv_avg_cov5_NLCG_054.rho" mfn_list = [mfn_sm3, mfn_avg_2] # difference between modem and ws grids # d_east = -7500. # d_north = 500. # get all models into useable objects modem_data = modem.Data() modem_data.read_data_file(data_fn) model_obj_avg = modem.Model() model_obj_avg.read_model_file(mfn_avg_2) model_obj_sm3 = modem.Model() model_obj_sm3.read_model_file(mfn_sm3) sm3_res = interp_grid(model_obj_sm3, model_obj_avg) new_res = (model_obj_avg.res_model.copy() * sm3_res) ** (1 / 2.0) smooth_res = new_res.copy() for zz in range(model_obj_avg.grid_z.shape[0]): smooth_res[8:-8, 8:-8, zz] = ( 10 ** smooth_2d(np.log10(new_res[:, :, zz]), 11)[8:-8, 8:-8] )
data_fn = r'/home/jpeacock/Documents/ModEM/LV/sm_comb_inv2/lv_dp_err7.dat' modem_model_fn = r"/home/jpeacock/Documents/ModEM/LV/sm_comb_inv2/ModEM_Model_rw.ws" ws_init_fn = r"/home/jpeacock/Documents/wsinv3d/LV/Inv_lv_coarse_2/WSInitialModel" ws_data_fn = r"/home/jpeacock/Documents/wsinv3d/LV/Inv_lv_coarse_2/WS_data_lv_coarse_2_4_small.dat" 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
ws_init_fn = r"/home/jpeacock/Documents/wsinv3d/LV/sm_modem_inv1/WSInitialMesh" ws_data_fn = r"/home/jpeacock/Documents/wsinv3d/LV/sm_modem_inv1/WS_data_sm_modem_inv1_8_small.dat" ws_station_fn = r"/home/jpeacock/Documents/wsinv3d/LV/WS_Station_Locations.txt" ws_model_fn = r"/home/jpeacock/Documents/wsinv3d/LV/sm_modem_inv2/lv_sm_modem_inv2_fine_model.05" #difference between modem and ws grids shift_east = -7000. shift_north = 500. # --> ModEM # read in modem data file modem_data = modem.Data() modem_data.read_data_file(data_fn) # read in modem model file modem_model = modem.Model() modem_model.read_model_file(modem_model_fn) #--> WSINV3D # read in initial mesh file ws_mesh = ws.WSMesh() ws_mesh.read_initial_file(ws_init_fn) #read in data file ws_data = ws.WSData() ws_data.read_data_file(data_fn=ws_data_fn, station_fn=ws_station_fn) # read in model file ws_model = ws.WSModel(ws_model_fn) # we need to get WS and ModEM on the same modeling grid. Choose the ModEM grid
mfn_avg_1 = r"/home/jpeacock/Documents/ModEM/LV/sm_avg_cov5/lv_avg_cov5_NLCG_054.rho" mfn_comb_1 = ( r"/home/jpeacock/Documents/ModEM/LV/sm_comb_err07/lv_comb_err07_cov5_NLCG_055.rho" ) mfn_list = [mfn_sm3, mfn_avg_2] # difference between modem and ws grids # d_east = -7500. # d_north = 500. # get all models into useable objects modem_data = modem.Data() modem_data.read_data_file(data_fn) model_obj_avg = modem.Model() model_obj_avg.read_model_file(mfn_avg_2) model_obj_avg3 = modem.Model() model_obj_avg3.read_model_file(mfn_avg_3) model_obj_comb = modem.Model() model_obj_comb.read_model_file(mfn_comb_1) model_obj_sm3 = modem.Model() model_obj_sm3.read_model_file(mfn_sm3) sm3_res = interp_grid(model_obj_sm3, model_obj_avg) new_res = model_obj_avg.res_model.copy() new_res = (new_res * model_obj_avg3.res_model * model_obj_comb.res_model)**(1 / 3.0)
# -*- coding: utf-8 -*- """ Created on Fri Jul 11 12:30:32 2014 @author: jpeacock-pr """ import numpy as np import mtpy.modeling.modem_new as modem mfn = r"c:\MinGW32-xy\Peacock\ModEM\WS_StartingModel_01\Modular_NLCG_000.rho" mdm = modem.Model() mdm.read_model_file(mfn) grid_z = mdm.grid_z.copy() dscale = 1000 res_model = mdm.res_model.copy() period = 50 # ============================================================================== # ESTIMATE SKIN DEPTH FOR MODEL # ============================================================================== # def estimate_skin_depth(res_model, grid_z, period, dscale=1000): # """ # estimate the skin depth from the resistivity model assuming that # # delta_skin ~ 500 * sqrt(rho_a*T) # # Arguments: # -----------
""" gx, gy = np.mgrid[-window_len:window_len + 1, -window_len:window_len + 1] gauss = np.exp(-(gx**2 / float(window_len) + gy**2 / float(window_len))) gauss /= gauss.sum() smooth_array = sps.convolve(res_array, gauss, mode='same') return smooth_array mfn_no_tipper = r"/home/jpeacock/Documents/ModEM/LV/Inv1_dp_no_tipper/lv_no_tipper_NLCG_100.rho" mfn_tipper = r"/home/jpeacock/Documents/ModEM/LV/NAS/hs_tipper/lv_tipper_NLCG_029.rho" m_obj_t = modem.Model() m_obj_t.read_model_file(mfn_tipper) m_obj_nt = modem.Model() m_obj_nt.read_model_file(mfn_no_tipper) new_res = np.sqrt(m_obj_t.res_model * m_obj_nt.res_model) #new_res = 10**((.7*np.log10(m_obj_t.res_model)+.3*np.log10(m_obj_nt.res_model))) #new_res = .5*(m_obj_t.res_model+m_obj_nt.res_model) ## make a base model that is 1000 ohm-m #new_res = m_obj_t.res_model.copy() # ## then anywhere either model is less than 100 ohm-m set it to base model ##index_t = np.where(m_obj_t.res_model < 100)
def model_fn(self, model_fn): self._model_fn = model_fn self.model_obj = modem.Model() self.model_obj.read_model_file(self._model_fn) # set slider bar intervals # need the minus 1 cause we are using the value of the slider as # the index. self.map_slider.setMaximum(self.model_obj.grid_z.size - 1) self.east_slider.setMaximum(self.model_obj.grid_north.size - 1) self.north_slider.setMaximum(self.model_obj.grid_east.size - 1) self.east_label.setText('{0:.2f}'.format(self.model_obj.grid_east[0])) self.north_label.setText('{0:.2f}'.format( self.model_obj.grid_north[0])) ## plot the model plot_east = np.append(self.model_obj.grid_east, self.model_obj.grid_east[-1] * 1.2) / self.scale plot_north = np.append( self.model_obj.grid_north, self.model_obj.grid_north[-1] * 1.2) / self.scale plot_z = np.append(self.model_obj.grid_z, self.model_obj.grid_z[-1] * 1.2) / self.scale self.plot_east_map, self.plot_north_map = np.meshgrid(plot_east, plot_north, indexing='ij') self.plot_east_z, self.plot_z_east = np.meshgrid(plot_east, plot_z, indexing='ij') self.plot_north_z, self.plot_z_north = np.meshgrid(plot_north, plot_z, indexing='ij') self.map_ax = self.map_figure.add_subplot(1, 1, 1, aspect='equal') self.map_ax.pcolormesh( self.plot_east_map, self.plot_north_map, np.log10(self.model_obj.res_model[:, :, self.map_index].T), cmap=self.cmap, vmin=self.res_limits[0], vmax=self.res_limits[1]) self.map_ax.set_xlabel('Easting {0}'.format(self.units)) self.map_ax.set_ylabel('Northing {0}'.format(self.units)) self.map_ax.set_aspect('equal', 'box-forced') self.north_ax = self.north_figure.add_subplot(1, 1, 1, sharex=self.map_ax, aspect='equal') self.north_ax.pcolormesh( self.plot_east_z, self.plot_z_east, np.log10(self.model_obj.res_model[self.north_index, :, :]), cmap=self.cmap, vmin=self.res_limits[0], vmax=self.res_limits[1]) self.north_ax.set_xlabel('Easting {0}'.format(self.units)) self.north_ax.set_ylabel('Depth {0}'.format(self.units)) self.north_ax.set_aspect('equal', 'box-forced') z_lim = self.north_ax.get_ylim() self.north_ax.set_ylim(z_lim[1], z_lim[0]) self.east_ax = self.east_figure.add_subplot(1, 1, 1, aspect='equal', sharex=self.map_ax, sharey=self.north_ax) self.east_ax.pcolormesh( self.plot_north_z, self.plot_z_north, np.log10(self.model_obj.res_model[:, self.east_index, :]), cmap=self.cmap, vmin=self.res_limits[0], vmax=self.res_limits[1]) self.east_ax.set_xlabel('Northing {0}'.format(self.units)) self.east_ax.set_ylabel('Depth {0}'.format(self.units)) self.east_ax.set_aspect('equal', 'box-forced') ##--> plot location map self.loc_ax = self.loc_figure.add_subplot(1, 1, 1, aspect='equal', sharex=self.map_ax, sharey=self.map_ax) east_line_xlist = [] east_line_ylist = [] for xx in self.model_obj.grid_east: east_line_xlist.extend([xx / self.scale, xx / self.scale]) east_line_xlist.append(None) east_line_ylist.extend([ self.model_obj.grid_north.min() / self.scale, self.model_obj.grid_north.max() / self.scale ]) east_line_ylist.append(None) self.loc_ax.plot(east_line_xlist, east_line_ylist, lw=.25, color='k') north_line_xlist = [] north_line_ylist = [] for yy in self.model_obj.grid_north: north_line_xlist.extend([ self.model_obj.grid_east.min() / self.scale, self.model_obj.grid_east.max() / self.scale ]) north_line_xlist.append(None) north_line_ylist.extend([yy / self.scale, yy / self.scale]) north_line_ylist.append(None) self.loc_ax.plot(north_line_xlist, north_line_ylist, lw=.25, color='k') self.loc_east, = self.loc_ax.plot([ self.model_obj.grid_east.min() / self.scale, self.model_obj.grid_east.min() / self.scale ], [ self.model_obj.grid_north.min() / self.scale, self.model_obj.grid_north.max() / self.scale ], lw=2, color=(0, .6, 0)) self.loc_north, = self.loc_ax.plot([ self.model_obj.grid_east.min() / self.scale, self.model_obj.grid_east.max() / self.scale ], [ self.model_obj.grid_north.min() / self.scale, self.model_obj.grid_north.min() / self.scale ], lw=2, color=(.5, 0, .5)) self.loc_ax.set_ylabel('Northing (km)') self.loc_ax.set_xlabel('Easting (km)') self.loc_ax.set_aspect('equal', 'box-forced') if self.data_fn is not None: self.map_ax.scatter( self.data_obj.station_locations['rel_east'] / self.scale, self.data_obj.station_locations['rel_north'] / self.scale, marker='v', c='k', s=10) self.loc_ax.scatter( self.data_obj.station_locations['rel_east'] / self.scale, self.data_obj.station_locations['rel_north'] / self.scale, marker='v', c='k', s=10) self.north_canvas.draw() self.map_canvas.draw() self.east_canvas.draw() self.loc_canvas.draw() #make a rectangular selector self.map_selector = widgets.RectangleSelector(self.map_ax, self.map_on_pick, drawtype='box', useblit=True) self.east_selector = widgets.RectangleSelector(self.east_ax, self.east_on_pick, drawtype='box', useblit=True) self.north_selector = widgets.RectangleSelector(self.north_ax, self.north_on_pick, drawtype='box', useblit=True)
import mtpy.modeling.modem_new as modem import mtpy.modeling.ws3dinv as ws import scipy.interpolate as spi import numpy as np import time 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
""" import mtpy.modeling.modem_new as modem import scipy.interpolate as spi import numpy as np import time import matplotlib.pyplot as plt data_fn = r'/mnt/hgfs/ModEM/LV/Topography_test/lv_dp_23p_tip05_elev.dat' elev_model_fn = r'/mnt/hgfs/ModEM/LV/Topography_test/lv_elev_err12_cov4_NLCG_053.rho' avg_model_fn = r"/home/jpeacock/Documents/ModEM/LV/sm_comb_err03_inv2/lv_comb_err03_cov4_NLCG_061.rho" avg_elev_index = 66 elev_mod = modem.Model() elev_mod.read_model_file(elev_model_fn) avg_mod = modem.Model() avg_mod.read_model_file(avg_model_fn) data_obj = modem.Data() data_obj.read_data_file(data_fn) avg_elev = elev_mod.grid_z[avg_elev_index] elev_res = np.zeros_like(elev_mod.res_model) avg_north, avg_east = np.broadcast_arrays(avg_mod.grid_north[:, None], avg_mod.grid_east[None, :]) elev_north, elev_east = np.broadcast_arrays(elev_mod.grid_north[:, None],
mfn_mb_sm = r"/home/jpeacock/Documents/ModEM/LV/mb_starting_inv1/lv_NLCG_067.rho" mfn_sm3 = r"/home/jpeacock/Documents/ModEM/LV/hs1000_avg/lv_sm3_avg_err07_NLCG_067.rho" mfn_sm_mb_t = ( r"/home/jpeacock/Documents/ModEM/LV/sm_mb_tipper/lv_mb_tipper_NLCG_043.rho" ) mfn_sm_mb = r"/home/jpeacock/Documents/ModEM/LV/sm_mb_inv1/lv_mb_sm_err12_NLCG_071.rho" # difference between modem and ws grids d_east = -7500.0 d_north = 500.0 # get all models into useable objects modem_data = modem.Data() modem_data.read_data_file(data_fn) base_model = modem.Model() base_model.read_model_file(mfn_avg_sm1) ws_hs1 = ws.WSModel(mfn_ws_hs1) ws_sm1 = ws.WSModel(mfn_ws_sm1) ws_sm2 = ws.WSModel(mfn_ws_sm2) modem_nt = modem.Model() modem_nt.read_model_file(mfn_no_tipper) modem_tip = modem.Model() modem_tip.read_model_file(mfn_tipper) modem_sm_mb = modem.Model() modem_sm_mb.read_model_file(mfn_mb_sm)
def __init__(self): super(MeshWidget, self).__init__() self.model_obj = modem.Model() self.setup_ui()
def interpolate_grid(self, pad_east=None, pad_north=None, cell_size=None): """ interpolate the irregular model grid onto a regular grid. """ model_obj = modem.Model() model_obj.model_fn = self.model_fn model_obj.read_model_file() self.grid_z = model_obj.grid_z.copy() if cell_size is not None: self.cell_size_east = cell_size self.cell_size_north = cell_size else: self.cell_size_east = np.median(model_obj.nodes_east) self.cell_size_north = np.median(model_obj.nodes_north) if pad_east is not None: self.pad_east = pad_east else: self.pad_east = np.where( model_obj.nodes_east[0:10] > self.cell_size_east * 1.1)[0][-1] if pad_north is not None: self.pad_north = pad_north else: self.pad_north = np.where( model_obj.nodes_north[0:10] > self.cell_size_north * 1.1)[0][-1] new_east = np.arange(model_obj.grid_east[self.pad_east], model_obj.grid_east[-self.pad_east - 1], self.cell_size_east) new_north = np.arange(model_obj.grid_north[self.pad_north], model_obj.grid_north[-self.pad_north - 1], self.cell_size_north) model_n, model_e = np.broadcast_arrays(model_obj.grid_north[:, None], model_obj.grid_east[None, :]) new_res_arr = np.zeros( (new_north.shape[0], new_east.shape[0], model_obj.grid_z.shape[0])) for z_index in range(model_obj.grid_z.shape[0]): res = model_obj.res_model[:, :, z_index] new_res_arr[:, :, z_index] = interpolate.griddata( (model_n.ravel(), model_e.ravel()), res.ravel(), (new_north[:, None], new_east[None, :])) # #1) first need to make x, y, z have dimensions (nx, ny, nz), similar to res # north, east, vert = np.broadcast_arrays(model_obj.grid_north[:, None, None], # model_obj.grid_east[None, :, None], # model_obj.grid_z[None, None, :]) # # #2) next interpolate ont the new mesh # new_res = interpolate.griddata((north.ravel(), # east.ravel(), # vert.ravel()), # model_obj.res_model.ravel(), # (new_north[:, None, None], # new_east[None, :, None], # model_obj.grid_z[None, None, :]), # method='linear') self.res_array = new_res_arr
# save_path = r"c:\Users\jpeacock\Documents\ShanesBugs\Sev_MT_Final_ga" # s_edi_path = r"c:\Users\jpeacock\Documents\ShanesBugs\Sev_MT_Final_ga\inv_edi_files" # s_list = ['MT{0:03}.edi'.format(ii) for ii in range(0, 12)] save_path = r"c:\Users\jpeacock\Documents\Geothermal\Washington\MSH\inversions" edi_path = ( r"c:\Users\jpeacock\Documents\Geothermal\Washington\MSH\INV_EDI_Files\Interpolated" ) s_edi_list = [ os.path.join(edi_path, ss) for ss in os.listdir(edi_path) if ss.endswith(".edi") ] # make mesh first mod_obj = modem.Model(edi_list=s_edi_list) mod_obj.cell_size_east = 250 mod_obj.cell_size_north = 250 mod_obj.pad_east = 18 mod_obj.pad_north = 18 mod_obj.pad_stretch_h = 1.4 mod_obj.pad_z = 4 mod_obj.n_layers = 40 mod_obj.z_target_depth = 40000.0 mod_obj.make_mesh() mod_obj.plot_mesh() mod_obj.write_model_file( model_fn=os.path.join(save_path, r"mshn_modem_sm.rho"))
# ============================================================================== # interpolate all models onto the same grid # ============================================================================== dfn = r"/mnt/hgfs/jpeacock/Documents/Geothermal/TorC/torc_modem_data_ef07_edit.dat" mfn_ws = r"/home/jpeacock/Documents/wsinv3d/torc/inv_01/torc_sm.ws" mfn_tipper = ( r"/mnt/hgfs/jpeacock/Documents/Geothermal/TorC/torc_sm50_tip_cov4_NLCG_012.rho" ) modem_data = modem.Data() modem_data.read_data_file(dfn) model_ws = ws.WSModel(model_fn=mfn_ws) modem_tip = modem.Model() modem_tip.read_model_file(mfn_tipper) # interpolate onto same grid interp_res = interp_grid(model_ws, modem_tip, pad=5) # --> average all as a geometric mean avg_res = (interp_res * modem_tip.res_model)**(1.0 / 2) # avg_res = interp_res x, y = np.meshgrid(modem_tip.grid_east, modem_tip.grid_north) ws_x, ws_y = np.meshgrid(model_ws.grid_east, model_ws.grid_north) kk = 5 kwargs = {"cmap": "jet_r", "vmin": -1, "vmax": 4} fig = plt.figure(4)
# lv_model_fn = r"/home/jpeacock/Documents/wsinv3d/LV/Inv_dp/lv_dp_fine_model.04_03" lv_model_fn = r"c:\Users\jpeacock\Documents\LV\lv16_sm_geo_err05_cov3_NLCG_065.rho" # mb_model_fn = r"/home/jpeacock/Documents/ModEM/MB_MT/WS_StartingModel_03_tipper/cov3_mb_tipper_NLCG_028.rho" mb_model_fn = r"c:\Users\jpeacock\Documents\MonoBasin\cov3_mb_tipper_NLCG_028.rho" # grid already made, use it to combine the models comb_model_fn = r"c:\Users\jpeacock\Documents\LV\Inversions\sm_lv_mb.rho" # locate model centers (E, N) mb_center = (327150, 4194900) lv_center = (336800, 4167525) comb_center = (331515 + 5285, 4179690) # --> read in the model files lv_mod = modem.Model() lv_mod.read_model_file(lv_model_fn) mb_mod = modem.Model() mb_mod.read_model_file(mb_model_fn) comb_mod = modem.Model() comb_mod.read_model_file(comb_model_fn) # --> interpolate each grid onto the combined grid mb_res = interp_grid( mb_mod, comb_mod, shift_east=-comb_center[0] + mb_center[0], shift_north=-comb_center[1] + mb_center[1], pad=9,
mfn_ws_sm3 = os.path.join(dir_path, r"mshn_sm3_fine_model.04") mfn_all_sm500 = os.path.join(dir_path, r"mshn_err05_cov03_NLCG_063.rho") #difference between modem and ws grids d_east = 0. d_north = 0. # get all models into useable objects modem_data = modem.Data() modem_data.read_data_file(data_fn) ws_sm2 = ws.WSModel(mfn_ws_sm2) ws_sm3 = ws.WSModel(mfn_ws_sm2) modem_all = modem.Model() modem_all.read_model_file(mfn_all_sm500) modem_tip = modem.Model() modem_tip.read_model_file(mfn_tipper) #--> interpolate on to the base model # smooth over the ws models because their resistivities are so low and # the models are coarse. nr_ws_sm2 = interp_grid(ws_sm2, modem_all, shift_east=d_east, shift_north=d_north, smooth_kernel=None, pad=5) nr_ws_sm3 = interp_grid(ws_sm3, modem_all, shift_east=d_east, shift_north=d_north, smooth_kernel=None, pad=5) nr_tip = interp_grid(modem_tip, modem_all, pad=2)
import numpy as np import time import matplotlib.pyplot as plt # data_fn = r'/home/jpeacock/Documents/ModEM/LV/sm_avg_inv1/lv_dp_23p_err07_tip1.dat' #data_fn = r'/home/jpeacock/Documents/ModEM/MB_MT/WS_StartingModel_03_tipper/mb_data_tipper.dat' #data_fn = r'/home/jpeacock/Documents/ModEM/MB_MT/WS_StartingModel_03_tipper/mb_data_tipper.dat' new_model_fn = r'/home/jpeacock/Documents/ModEM/LV/sm_avg_inv1/lv_avg_err07_NLCG_018.rho' old_model_fn = r"/home/jpeacock/Documents/ModEM/MB_MT/WS_StartingModel_03_tipper/cov3_mb_tipper_NLCG_028.rho" interpolation_dim = '2d' new_mod = modem.Model() new_mod.read_model_file(new_model_fn) new_mod.res_model[:, :, :] = 1000 old_mod = modem.Model() old_mod.read_model_file(old_model_fn) #old_mod.res_model[np.where(old_mod.res_model) < 1.0] = 1.0 data_obj = modem.Data() data_obj.read_data_file(data_fn) new_mod.station_locations = data_obj.station_locations.copy() #caluclate an offset between grids. diff_east = old_mod.grid_east[16] - new_mod.grid_east[20] diff_north = old_mod.grid_north[16] - new_mod.grid_north[20]
#============================================================================== # interpolate all models onto the same grid #============================================================================== data_fn = r'/home/jpeacock/Documents/ModEM/LV/lv_16_inv01/lv16_err05.dat' mfn_lv_geo = r"/home/jpeacock/Documents/ModEM/LV/lv_geo_sm_avg_01/lv_geo_ws_err03_cov5_NLCG_054.rho" mfn_lv16 = r"/home/jpeacock/Documents/ModEM/LV/lv_16_inv01/lv16_err05_cov3_NLCG_072.rho" #difference between modem and ws grids d_east = -1650. d_north = 6600. # get all models into useable objects modem_data = modem.Data() modem_data.read_data_file(data_fn) base_model = modem.Model() base_model.read_model_file(mfn_lv16) modem_geo = modem.Model() modem_geo.read_model_file(mfn_lv_geo) #--> interpolate on to the base model geo_sm = interp_grid(modem_geo, base_model, pad=2, shift_east=d_east, shift_north=d_north) #--> average all as a geometric mean
edi_path = r"d:\Peacock\MTData\SanPabloBay\EDI_Files_dp" dem_fn = r"c:\Users\jpeacock\Documents\SanPabloBay\sp_10mtopo_bathy.asc" sv_path = r"c:\Users\jpeacock\Documents\SanPabloBay\Inv01_dp_elev" #edi_path = r"/mnt/hgfs/MTData/SanPabloBay/EDI_Files_dp" #dem_fn = r"/mnt/hgfs/jpeacock/Documents/SanPabloBay/sp_10mtopo_bathy.asc" #sv_path = r"/home/jpeacock/Documents/ModEM/SanPabloBay/Inv01_dp_elev" if not os.path.isdir(sv_path): os.mkdir(sv_path) edi_list = [ os.path.join(edi_path, ss) for ss in os.listdir(edi_path) if ss.find('.edi') > 0 ] m_obj = modem.Model() m_obj.edi_list = edi_list m_obj.cell_size_east = 100 m_obj.cell_size_north = 100 m_obj.z1_layer = 2 m_obj.z_target_depth = 20000 m_obj.z_bottom = 200000 m_obj.n_layers = 40 m_obj.pad_east = 15 m_obj.pad_north = 15 m_obj.pad_z = 5 m_obj.pad_stretch_h = 1.8 m_obj.pad_stretch_z = 1.5 m_obj.make_mesh() m_obj.plot_mesh() m_obj.save_path = sv_path
""" Created on Wed Sep 2 15:48:52 2015 @author: jpeacock """ import mtpy.modeling.modem_new as modem import numpy as np from interpolate_models import interpolate_model_grid m1_fn = r"/home/jpeacock/Documents/ModEM/LV/geo_err12/lv_geo_err03_cov5_NLCG_065.rho" m2_fn = r"/home/jpeacock/Documents/ModEM/LV/lv_geo_sm_wsdeep_01/lv_geo_ws_err03_cov5_NLCG_118.rho" m3_fn = r" #m1_interp_fn = interpolate_model_grid(m1_fn, m2_fn, pad=3, shift_north=5500, # shift_east=700) #m1_interp_fn = interpolate_model_grid(m1_fn, m2_fn, pad=3) m1_obj = modem.Model() m1_obj.read_model_file(m1_fn) m2_obj = modem.Model() m2_obj.read_model_file(m2_fn) res_avg = np.sqrt(m1_obj.res_model*m2_obj.res_model) m2_obj.res_model = res_avg m2_obj.write_model_file(model_fn_basename='lv_geo_sm_avg_02.rho') mm = modem.ModelManipulator(model_fn=m2_obj.model_fn, data_fn=r"/home/jpeacock/Documents/ModEM/LV/geo_err12/lv_geo_err12_tip10.dat")