mt_metadata.transfer_functions.io package

Subpackages

Submodules

mt_metadata.transfer_functions.io.tools module

Created on Sat Dec 4 17:44:51 2021

@author: jpeacock

mt_metadata.transfer_functions.io.tools.get_nm_elev(latitude, longitude)[source]

Get national map elevation for a given lat and lon.

Queries the national map website for the elevation value.

Parameters:
  • lat (float) – latitude in decimal degrees

  • lon (float) – longitude in decimal degrees

Returns:

elevation (meters)

Return type:

float

Example:
>>> import mtpy.usgs.usgs_archive as archive
>>> archive.get_nm_elev(35.467, -115.3355)
>>> 809.12

Note

Needs an internet connection to work.

class mt_metadata.transfer_functions.io.tools.index_locator(component_list)[source]

Bases: object

property has_electric
property has_tipper
property input_channels
property n_channels
property n_inputs
property n_outputs
property output_channels

Module contents

class mt_metadata.transfer_functions.io.EDI(fn=None, **kwargs)[source]

Bases: object

This class is for .edi files, mainly reading and writing. Has been tested on Winglink and Phoenix output .edi’s, which are meant to follow the archaic EDI format put forward by SEG. Can read impedance, Tipper and/or spectra data.

The Edi class contains a class for each major section of the .edi file.

Frequency and components are ordered from highest to lowest frequency.

Parameters:

fn (string or pathlib.Path) – full path to .edi file to be read in. default is None. If an .edi file is input, it is automatically read in and attributes of Edi are filled

Change Latitude:
>>> from mt_metadata.transfer_functions.io.edi import EDI
>>> edi_obj = EDI(fn=r"/home/mt/mt01.edi")
>>> # change the latitude
>>> edi_obj.lat = 45.7869
>>> new_edi_fn = edi_obj.write()
property elev

Elevation in elevation units

property ex_metadata
property ey_metadata
property fn
property hx_metadata
property hy_metadata
property hz_metadata
property lat

latitude in decimal degrees

property lon

longitude in decimal degrees

property period
read(fn=None, get_elevation=False)[source]

Read in an edi file and fill attributes of each section’s classes. Including:

  • Header

  • Info

  • Measurement

  • Data

  • z, z_err

  • t, t_err

Note

Automatically detects if data is in spectra format. All data read in is converted to impedance and Tipper.

Parameters:

fn (string) – full path to .edi file to be read in default is None

Example:
>>> from mt_metadata.transfer_functions.io.edi import EDI
>>> edi_obj = EDI
>>> edi_obj.read(fn=r"/home/mt/mt01.edi")
property rrhx_metadata
property rrhy_metadata
property station

station name

property station_metadata
property survey_metadata
write(new_edi_fn=None, longitude_format='LON', latlon_format='dms')[source]

Write a new edi file from either an existing .edi file or from data input by the user into the attributes of Edi.

Parameters:
  • new_edi_fn (string) – full path to new edi file. default is None, which will write to the same file as the input .edi with as: r”/home/mt/mt01_1.edi”

  • longitude_format (string) – whether to write longitude as LON or LONG. options are ‘LON’ or ‘LONG’, default ‘LON’

  • latlon_format (string) – format of latitude and longitude in output edi, degrees minutes seconds (‘dms’) or decimal degrees (‘dd’)

Returns:

full path to new edi file

Return type:

string

Example:
>>> import mtpy.core.edi as mtedi
>>> edi_obj = mtedi.Edi(fn=r"/home/mt/mt01/edi")
>>> edi_obj.Header.dataid = 'mt01_rr'
>>> n_edi_fn = edi_obj.write_edi_file()
class mt_metadata.transfer_functions.io.EMTFXML(fn=None, **kwargs)[source]

Bases: EMTF

This is meant to follow Anna’s XML schema for transfer functions

property fn
read(fn=None, get_elevation=False)[source]

Read xml file

Parameters:

fn (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

property save_dir
property station_metadata
property survey_metadata
write(fn, skip_field_notes=False)[source]

Write an xml :param fn: DESCRIPTION :type fn: TYPE :return: DESCRIPTION :rtype: TYPE

class mt_metadata.transfer_functions.io.JFile(fn=None, **kwargs)[source]

Bases: object

be able to read and write a j-file

property fn
property periods
read(fn=None, get_elevation=False)[source]

Read data from a j file

Parameters:

fn (string or pathlib.Path, optional) – full path to j-file to read, defaults to None

property station_metadata
property survey_metadata
class mt_metadata.transfer_functions.io.ZMM(fn=None, **kwargs)[source]

Bases: ZMMHeader

Container for Egberts zrr format.

calculate_impedance(angle=0.0)[source]

calculate the impedances from the transfer functions

calculate_tippers(angle=0.0)[source]

calculate induction vectors

property channel_nomenclature
property ex_metadata
property ey_metadata
property frequencies
property hx_metadata
property hy_metadata
property hz_metadata
initialize_arrays()[source]

make initial arrays based on number of frequencies and channels

read(fn=None, get_elevation=False)[source]

Read in Egbert zrr/zmm file

Parameters:

fn (string or pathlib.Path) – full path to zmm/zrr file

property survey_metadata
write(fn, decimation_levels=None)[source]

write a zmm file

decimation_levels should be a dictionary with keys

  • decimation_level

values will be a dictionary with keys

  • frequency_band, value = (min, max)

  • n_points, value = int

  • sampling_freq, value = float

class mt_metadata.transfer_functions.io.ZongeMTAvg(fn=None, **kwargs)[source]

Bases: object

deal with avg files output from mtedit

property ex_metadata
property ey_metadata
property fn
property hx_metadata
property hy_metadata
property hz_metadata
read(fn=None, get_elevation=False)[source]

Read into a pandas data frame

Parameters:

fn (TYPE, optional) – DESCRIPTION, defaults to None

Returns:

DESCRIPTION

Return type:

TYPE

property run_metadata
property station_metadata
property survey_metadata
to_amp_phase(zreal, zimag)[source]

Convert to amplitude and phase from real and imaginary

Parameters:
  • zreal (TYPE) – DESCRIPTION

  • zimag (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

to_complex(zmag, zphase)[source]

outputs of mtedit are magnitude and phase of z, convert to real and imaginary parts, phase is in milliradians

write(fn)[source]

Write an .avg file

Parameters:

fn (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE