コード例 #1
0
ファイル: plot_depth_slice.py プロジェクト: zy911k24/mtpy
    def read_files(self):
        """
        read in the files to get appropriate information
        """
        # --> read in model file
        if self.model_fn is not None:
            if os.path.isfile(self.model_fn) == True:
                md_model = Model()
                md_model.read_model_file(self.model_fn)
                self.res_model = md_model.res_model
                self.grid_east = md_model.grid_east / self.dscale
                self.grid_north = md_model.grid_north / self.dscale
                self.grid_z = md_model.grid_z / self.dscale
                self.nodes_east = md_model.nodes_east / self.dscale
                self.nodes_north = md_model.nodes_north / self.dscale
                self.nodes_z = md_model.nodes_z / self.dscale
            else:
                raise mtex.MTpyError_file_handling(
                    '{0} does not exist, check path'.format(self.model_fn))

        # --> read in data file to get station locations
        if self.data_fn is not None:
            if os.path.isfile(self.data_fn) == True:
                md_data = Data()
                md_data.read_data_file(self.data_fn)
                self.station_east = md_data.station_locations.rel_east / self.dscale
                self.station_north = md_data.station_locations.rel_north / self.dscale
                self.station_elev = md_data.station_locations.elev / self.dscale
                self.station_names = md_data.station_locations.station
            else:
                print 'Could not find data file {0}'.format(self.data_fn)
コード例 #2
0
ファイル: mt.py プロジェクト: schoolhui/mtpy
 def _set_fn(self, filename):
     """
     set filename, currently only support .edi files
     """
     
     self._fn = filename
     if self._fn[-3:] == 'edi':
         self._read_edi_file()
     else:
         not_fn = self._fn[os.path.basename(self._fn).find['.']:]
         raise MTex.MTpyError_file_handling('File '+\
                           'type {0} not supported yet.'.format(not_fn))
コード例 #3
0
    def read_control_file(self, control_fn=None):
        """
        read in a control file
        """

        if control_fn is not None:
            self.control_fn = control_fn

        if self.control_fn is None:
            raise mtex.MTpyError_file_handling('control_fn is None, input '
                                               'control file')

        if os.path.isfile(self.control_fn) is False:
            raise mtex.MTpyError_file_handling('Could not find {0}'.format(
                self.control_fn))

        self.save_path = os.path.dirname(self.control_fn)
        self.fn_basename = os.path.basename(self.control_fn)

        cfid = file(self.control_fn, 'r')
        clines = cfid.readlines()
        cfid.close()
        for cline in clines:
            clist = cline.strip().split(':')
            if len(clist) == 2:

                try:
                    self._control_dict[clist[0].strip()] = float(clist[1])
                except ValueError:
                    self._control_dict[clist[0].strip()] = clist[1]

        # set attributes
        attr_list = ['output_fn', 'lambda_initial', 'lambda_step',
                     'model_search_step', 'rms_reset_search', 'rms_target',
                     'lambda_exit', 'max_iterations']
        for key, kattr in zip(self._control_keys, attr_list):
            setattr(self, kattr, self._control_dict[key])
コード例 #4
0
ファイル: control_fwd.py プロジェクト: zy911k24/mtpy
    def read_control_file(self, control_fn=None):
        """
        read in a control file
        """

        if control_fn is not None:
            self.control_fn = control_fn

        if self.control_fn is None:
            raise mtex.MTpyError_file_handling('control_fn is None, input '
                                               'control file')

        if os.path.isfile(self.control_fn) is False:
            raise mtex.MTpyError_file_handling('Could not find {0}'.format(
                self.control_fn))

        self.save_path = os.path.dirname(self.control_fn)
        self.fn_basename = os.path.basename(self.control_fn)

        cfid = file(self.control_fn, 'r')
        clines = cfid.readlines()
        cfid.close()
        for cline in clines:
            clist = cline.strip().split(':')
            if len(clist) == 2:

                try:
                    self._control_dict[clist[0].strip()] = float(clist[1])
                except ValueError:
                    self._control_dict[clist[0].strip()] = clist[1]

        # set attributes
        attr_list = ['num_qmr_iter', 'max_num_div_calls', 'max_num_div_iters',
                     'misfit_tol_fwd', 'misfit_tol_adj', 'misfit_tol_div']
        for key, kattr in zip(self._control_keys, attr_list):
            setattr(self, kattr, self._control_dict[key])
コード例 #5
0
ファイル: mt.py プロジェクト: schoolhui/mtpy
    def __init__(self, fn=None, **kwargs):
        
        self._fn = fn
        self.station = kwargs.pop('station', None)
        self._lat = kwargs.pop('lat', None)
        self._lon = kwargs.pop('lon', None)
        self._elev = kwargs.pop('elev', None)
        self._Z = kwargs.pop('Z', MTz.Z())
        self._Tipper = kwargs.pop('Tipper', MTz.Tipper())
        self._utm_zone = kwargs.pop('utm_zone', None)
        self._east = kwargs.pop('east', None)
        self._north = kwargs.pop('north', None)
        self._rotation_angle = kwargs.pop('rotation_angle', 0)
        self._data_type = kwargs.pop('data_type', 'z')
        
        #provide key words to fill values if an edi file does not exist
        if 'z_object' in kwargs:
            self._Z = kwargs['z_object']
            
        if 'z_array' in kwargs:
            self._Z.z = kwargs['z_array']
        
        if 'zerr_array' in kwargs:
            self._Z.zerr = kwargs['zerr_array']
        
        if 'freq' in kwargs:
            self._Z.freq = kwargs['freq']
            self._Tipper.freq = kwargs['freq']
            
        if 'tipper_object' in kwargs:
            self._Tipper = kwargs['tipper_object']
            
        if 'tipper' in kwargs:
            self._Tipper.tipper = kwargs['tipper']
        
        if 'tippererr' in kwargs:
            self._Tipper.tippererr = kwargs['tippererr']
            
        if 'resisitivity' in kwargs:
            self._Z.resistivity = kwargs['resistivity']
        
        if 'resisitivity_err' in kwargs:
            self._Z.resistivity_err = kwargs['resistivity_err']
        
        if 'phase' in kwargs:
            self._Z.phase = kwargs['phase']
            
        if 'phase_err' in kwargs:
            self._Z.phase = kwargs['phase_err']
        
        
        self.edi_object = MTedi.Edi()
        self.pt = None
        self.zinv = None
        self._utm_ellipsoid = 23

        #--> read in the edi file if its given
        if self._fn is not None:
            if self._fn[-3:] == 'edi':
                self._read_edi_file()
            else:
                not_fn = self._fn[os.path.basename(self._fn).find['.']:]
                raise MTex.MTpyError_file_handling('File '+\
                          'type {0} not supported yet.'.format(not_fn))