コード例 #1
0
 def data_fn(self, data_fn):
     self._data_fn = os.path.abspath(data_fn)
     self.file_watcher_dfn.addPath(self._data_fn)
     
     # create new modem data object
     self.modem_data = modem.Data()
     self.modem_data.read_data_file(self._data_fn)
     
     # make a back up copy that will be unchanged
     # that way we can revert back
     self._modem_data_copy = modem.Data()
     self._modem_data_copy.read_data_file(self._data_fn)
     
     self.dirpath = os.path.dirname(self._data_fn)
     
     # fill list of stations
     station_list = np.array(sorted(self.modem_data.mt_dict.keys()))
     self.list_widget.clear()
     for station in station_list:
         self.list_widget.addItem(station)
         
     if self.station is None:
         self.station = station_list[0]
         
     self.plot()
コード例 #2
0
ファイル: modem_mesh_builder.py プロジェクト: DSO89/DSO
    def get_data_fn(self):
        """
        get the filename from a file dialogue
        
        """        

        fn_dialog = QtGui.QFileDialog()
        fn = str(fn_dialog.getOpenFileName(caption='Choose ModEM data file',
                                       filter='(*.dat);; (*.data)'))
                                       
        self.modem_data = modem.Data()
        self.modem_data.read_data_file(fn)
        self.modem_data_fn = fn
        
        self.dir_path = os.path.dirname(fn)
        
        self.period_list = sorted(self.modem_data.period_list)
        self.period_dict = dict([('{0:.5f}'.format(key), value) for value, key
                                 in enumerate(self.period_list)])
        
        self.list_widget.clear()
        
        #this will add the station name for each station to the qwidget list
        for period in self.period_list:
            self.list_widget.addItem('{0:.5f}'.format(period))
            
        self.plot_period = self.period_list[0]
コード例 #3
0
    def __init__(self, data_fn, resp_fn=None, read_mode=1):
        '''
        Class for loading MODEM data and plotting phase tensors.

        :param data_fn: MODEM data file name
        '''

        self._data_fn = data_fn
        self._resp_fn = resp_fn

        try:
            self._data_obj = modem.Data()
            self._data_obj.read_data_file(self._data_fn)
            self._modem_obj = modem.Data()
            self._modem_obj.read_data_file(self._data_fn)
        except Exception as err:
            print 'Failed to read %s' % (self._data_fn)
            logging.error(traceback.format_exc())
            exit(-1)

        if self._resp_fn is not None:
            try:
                self._resp_obj = modem.Data()
                self._resp_obj.read_data_file(self._resp_fn)
            except Exception as err:
                print 'Failed to read %s' % (self._resp_fn)
                logging.error(traceback.format_exc())
                exit(-1)
        else:
            self._resp_obj = None

        self._plot_period = self._data_obj.period_list.copy()
        self._mt_obj_list = [
            self._data_obj.mt_dict[key]
            for key in self._data_obj.mt_dict.keys()
        ]

        # Read data
        self._pt_dict = {}
        self._ptol = 0.05

        self.read_mode = read_mode
        if read_mode == 1:
            self.get_pt()
        else:
            self.get_pt2()
コード例 #4
0
ファイル: modem_slice.py プロジェクト: zy911k24/mtpy
    def __init__(self, model_fn, data_fn):
        '''
        Class for extracting field values at arbitrary locations from a 3D MODEM model.
        The model-mesh is centered on the centre-point of station-locations.

        :param model_fn: name of model file
        :param data_fn: name of data file
        '''

        # Read data and model files
        self._model_fn = model_fn
        self._data_fn = data_fn
        try:
            self._d = modem.Data()
            self._d.read_data_file(data_fn=self._data_fn)
        except Exception as err:
            print 'Failed to read %s' % (self._data_fn)
            logging.error(traceback.format_exc())
            exit(-1)

        try:
            self._m = modem.Model(model_fn=self._model_fn,
                                  station_object=self._d.station_locations)
            self._m.read_model_file()
        except Exception as err:
            print 'Failed to read %s' % (self._model_fn)
            logging.error(traceback.format_exc())
            exit(-1)

        # Re-orient model coordinates based on the centre of data locations
        self._mx = self._m.grid_east + self._d.center_point['east']
        self._my = self._m.grid_north + self._d.center_point['north']
        self._mz = self._m.grid_z

        # Compute cell-centre coordinates
        self._mcx = (self._mx[1:] + self._mx[:-1]) / 2.
        self._mcy = (self._my[1:] + self._my[:-1]) / 2.
        self._mcz = (self._mz[1:] + self._mz[:-1]) / 2.

        # Create mesh-grid based on cell-centre coordinates
        self._mgx, self._mgy, self._mgz = np.meshgrid(self._mcx, self._mcy,
                                                      self._mcz)

        # List of xyz coodinates of mesh-grid
        self._mgxyz = np.vstack(
            [self._mgx.flatten(),
             self._mgy.flatten(),
             self._mgz.flatten()]).T

        # Create Kd-Tree based on mesh-grid coordinates
        self._tree = cKDTree(self._mgxyz)
コード例 #5
0
ファイル: modem_mesh_builder.py プロジェクト: DSO89/DSO
    def get_data_fn(self):
        """
        get the filename from a file dialogue
        
        """        

        fn_dialog = QtGui.QFileDialog()
        fn = str(fn_dialog.getOpenFileName(caption='Choose ModEM data file',
                                       filter='(*.dat);; (*.data)'))
                                       
        self.mesh_widget.modem_data = modem.Data()
        self.mesh_widget.modem_data.read_data_file(fn)
        self.mesh_widget.modem_data_fn = fn
        
        self.mesh_widget.dir_path = os.path.dirname(fn)
コード例 #6
0
ファイル: convert_model_to_vtk.py プロジェクト: DSO89/DSO
    def make_vtk_files(self):
        if self.model_type == 'ModEM':
            m_obj = modem.Model()
            m_obj.read_model_file(os.path.join(self.cwd, self.model_fn))
            m_obj.write_vtk_file(vtk_save_path=self.cwd,
                                 vtk_fn_basename=self.vtk_model_fn)

            d_obj = modem.Data()
            d_obj.read_data_file(self.resp_fn)
            d_obj.write_vtk_station_file(vtk_save_path=self.cwd,
                                         vtk_fn_basename=self.vtk_station_fn)
            program = 'modem2vtk'
        elif self.model_type == 'WS':
            program = 'ws2vtk'

            subprocess.call([
                program, self.model_fn, self.resp_fn, self.vtk_model_fn,
                self.vtk_station_fn
            ])
コード例 #7
0
dem_cell_size = 200.
bathym_cell_size = 900
res_air = 1e12
elev_cell = 30

#starting model resistivity
sm_res = 100

##==============================================================================
##  Do all the work
##==============================================================================

m_obj = modem.Model()
m_obj.read_model_file(model_fn)

d_obj = modem.Data()
d_obj.read_data_file(data_fn)
mont_model_center = (d_obj.center_point.east + 1200,
                     d_obj.center_point.north + 2900)

m_obj.add_topography_to_model(dem_fn,
                              model_center=mont_model_center,
                              cell_size=dem_cell_size,
                              elev_cell=30)

#### 1.) read in the dem and center it onto the resistivity model
#e_east, e_north, elevation = modem.read_dem_ascii(dem_fn, cell_size=dem_cell_size,
#                                        model_center=mont_model_center,
#                                        rot_90=0)
#
#### 1b) need to remove the non data points and set them to the minimum value
コード例 #8
0
                                        grid=True)
    for ax in ax_list:
        ax.set_axisbelow(True)
        ax.set_yticks(np.arange(ylim[0], ylim[1]))
        ax.set_title('')
        ax.legend(loc='upper right')
    
    return ax_list
# =============================================================================
# run things
# =============================================================================
#res_fn = r"c:\Users\jpeacock\OneDrive - DOI\Geysers\modem_inv\inv03\gz_err03_cov02_NLCG_057.res"
#res_fn = r"c:\Users\jpeacock\OneDrive - DOI\Geysers\modem_inv\inv04\gz_rm50_z03_c02_104.res"
res_fn = r"c:\Users\jpeacock\OneDrive - DOI\Geysers\gz_z03_c02_074.res"
rms_thresh = 5.0

res_obj = modem.Data()
res_obj.read_data_file(res_fn)

summary_df = get_rms_summary_df(res_obj)
period_df = get_rms_by_period_df(res_obj)

ax1 = plot_rms_summary(res_obj, keys=['z', 'zxx', 'zxy', 'zyx', 'zyy'])
ax2 = plot_rms_by_period(res_obj, keys=['z', 'zxx', 'zxy', 'zyx', 'zyy'])    
        
    




コード例 #9
0
    inv_edi_list = []
    for edi in s_edi_list:
        mt_obj = mt.MT(edi)
        if mt_obj.lon >= inv_box[0].min() and mt_obj.lon <= inv_box[0].max():
            if mt_obj.lat >= inv_box[1].min() and mt_obj.lat <= inv_box[1].max(
            ):
                inv_edi_list.append(edi)

    pickle.dump(inv_edi_list, open(edi_list_fn, 'w'))

#==============================================================================
# Make the data file
#==============================================================================
inv_period_list = np.logspace(-np.log10(300), np.log10(1024), num=23)
data_obj = modem.Data(edi_list=inv_edi_list, period_list=inv_period_list)
data_obj.error_type_z = 'eigen_floor'
data_obj.error_type_tipper = 'absolute_floor'
data_obj.error_value_z = 3.0
data_obj.error_value_tipper = .02

#--> here is where you can rotate the data
data_obj.write_data_file(
    save_path=save_path,
    fn_basename="shz_modem_data_err{0:02.0f}_tip{1:02.0f}.dat".format(
        data_obj.error_value_z, data_obj.error_value_tipper))

#==============================================================================
# First make the mesh
#==============================================================================
mod_obj = modem.Model(station_object=data_obj.station_locations)
コード例 #10
0
Created on Wed Mar  3 18:11:42 2021

:copyright: 
    Jared Peacock ([email protected])

:license: MIT

"""
from pathlib import Path
import numpy as np
from matplotlib import pyplot as plt
from mtpy.modeling import modem
from mtpy.utils import array2raster

dfn = r"c:\Users\jpeacock\OneDrive - DOI\Geothermal\GreatBasin\modem_inv\canv_01\canv_modem_data_z10_t03.dat"
d = modem.Data()
d.read_data_file(dfn)

# mfn = r"c:\Users\jpeacock\OneDrive - DOI\Geothermal\GreatBasin\modem_inv\canv_01\canv_t03_c04_084.rho"
mfn = r"c:\Users\jpeacock\OneDrive - DOI\Geothermal\GreatBasin\modem_inv\canv_01\canv_z10_c06_150.rho"
# mfn = r"c:\Users\jpeacock\OneDrive - DOI\Geothermal\Umatilla\modem_inv\inv_06\um_z05_c03_083.rho"
# model_center = (-118.704435 + .03, 45.597757000000001 + .02)

model_center = (-119.015192, 38.615252)
lower_left = (-124.2937861, 32.5799747)

z_dict = {
    "surface": np.array((0, 5000)),
    "middle_crust": np.array((12000, 17000)),
    "lower_crust": np.array((17000, 35000)),
}
コード例 #11
0
@author: jpeacock-pr
"""

import mtpy.modeling.modem as modem
import os
import matplotlib.pyplot as plt

plt.rcParams["svg.fonttype"] = "none"
plt.rcParams["pdf.fonttype"] = 42
plt.rcParams["font.family"] = "Tahoma"

dfn = r"c:\Users\jpeacock\OneDrive - DOI\Geysers\gz_modem_data_z03_topo.dat"
rfn = r"c:\Users\jpeacock\OneDrive - DOI\Geysers\gz_z03_c02_074.dat"
sv_path = r"c:\Users\jpeacock\OneDrive - DOI\Geysers\jvgr\figures"

data_obj = modem.Data()
data_obj.read_data_file(dfn)

station_list = data_obj.station_locations.station.copy()
plot_type = "maps"
file_fmt = "pdf"

plot_list = [
    {
        "label": r"$Z_{xx}$",
        "index": (0, 0),
        "plot_num": 1
    },
    {
        "label": r"$Z_{xy}$",
        "index": (0, 1),
コード例 #12
0
    def resp_fn(self, resp_fn):
        self._resp_fn = os.path.abspath(resp_fn)
        self.modem_resp = modem.Data()

        self.modem_resp.read_data_file(self._resp_fn)
        self.plot() 
コード例 #13
0
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 28 11:56:04 2017

@author: jpeacock
"""

import mtpy.modeling.modem as modem

dfn_07 = r"c:\Users\jpeacock\Documents\ClearLake\modem_inv\inv02_dr\gz_data_err07_elev_c_dr.dat"
dfn_03 = r"C:\Users\jpeacock\Documents\ClearLake\modem_inv\inv04\geysers_modem_data_err03.dat"
# dfn_03 = r"C:\Users\jpeacock\Documents\ClearLake\modem_inv\inv02_dr\geysers_modem_data_err03.dat"


d_07 = modem.Data()
d_07.read_data_file(dfn_07)

d_03 = modem.Data()
d_03.read_data_file(dfn_03)

d_03.station_locations = d_07.station_locations

d_03.write_data_file(
    fn_basename="gz_data_err03_ec_dr.dat",
    fill=False,
    compute_error=False,
    elevation=True,
)
コード例 #14
0
            ),
            method="linear",
        )

    print "Shape of new res = {0}".format(new_res.shape)
    return new_res


# ==============================================================================
#  interpolate all models onto the same grid
# ==============================================================================
dfn = r"C:\Users\jpeacock\Documents\iMush\modem_inv\shz_inv_02\shz_modem_data_err03_tip02_edit.dat"
mfn_imush = r"c:\Users\jpeacock\Documents\iMush\modem_inv\paul_final_model\Z4T3_cov0p2x2_L1E2_NLCG_061.rho"
mfn_shz = r"c:\Users\jpeacock\Documents\iMush\modem_inv\shz_inv_02\shz_smt_z04_t03_c02_NLCG_070.rho"

modem_data = modem.Data()
modem_data.read_data_file(dfn)

modem_imush = modem.Model()
modem_imush.read_model_file(mfn_imush)

modem_shz = modem.Model()
modem_shz.read_model_file(mfn_shz)

imush_center = (46.450149, -122.032858)
shz_center = (46.310461, -122.194629)

imush_east, imush_north, zone = gis_tools.project_point_ll2utm(
    imush_center[0], imush_center[1]
)
shz_east, shz_north, zone = gis_tools.project_point_ll2utm(shz_center[0], shz_center[1])
コード例 #15
0
ファイル: modem_plot_response_v2.py プロジェクト: DSO89/DSO
    def resp_fn(self, resp_fn):
        self._resp_fn = resp_fn
        self.modem_resp = modem.Data()

        self.modem_resp.read_data_file(self._resp_fn)
        self.plot()