mt_metadata.transfer_functions package

Subpackages

Submodules

mt_metadata.transfer_functions.core module

class mt_metadata.transfer_functions.core.TF(fn=None, **kwargs)[source]

Bases: object

Generic container to hold information about an electromagnetic transfer funtion

The thought here is to have a central container TF.dataset which is an xarray.Dataset that contains the impedance, tipper, errors and covariance values. There are helper functions to get and set these from the TF.dataset. Cause most of the time the user will want just the impedance or the tipper and associated errors. We are accommodating EMTF style covariances to accurately rotated data errors.

When reading and writing edi files this information will be lost.

property channel_nomenclature
copy()[source]
property dataset

This will return an xarray dataset with proper metadata

Returns:

DESCRIPTION

Return type:

TYPE

property elevation

Elevation

property fn

reference to original data file

property frequency
from_avg(avg_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • avg_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.zonge.ZongeMTAvg) – path to .avg file or ZongeMTAvg object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for ZongeMTAvg object

from_edi(edi_obj, get_elevation=False, **kwargs)[source]

Read in an EDI file or a mt_metadata.transfer_functions.io.edi.EDI ojbect

Parameters:
  • edi_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.edi.EDI) – path to edi file or EDI object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Key word arguments for an EDI object

Raises:

TypeError – If input is incorrect

from_emtfxml(emtfxml_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • emtfxml_object (str, pathlib.Path, mt_metadata.transfer_function.io.emtfxml.EMTFXML) – path to emtf xml file or EMTFXML object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for EMTFXML object

from_jfile(j_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • jfile_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.jfile.JFile) – path ot .j file or JFile object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for JFile object

from_ts_station_metadata(ts_station_metadata)[source]

need a convinience function to translate to ts station metadata for MTH5

from_zmm(zmm_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • zmm_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.zfiles.ZMM) – path ot .zmm file or ZMM object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for ZMM object

from_zrr(zrr_obj, get_elevation=False, **kwargs)[source]
Parameters:
from_zss(zss_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • zmm_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.zfiles.ZMM) – path to .zmm file or ZMM object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for ZMM object

has_impedance()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

has_inverse_signal_power()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

has_residual_covariance()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

has_tipper()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

has_transfer_function()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

property impedance

DESCRIPTION :rtype: TYPE

Type:

return

property impedance_error

DESCRIPTION :rtype: TYPE

Type:

return

property impedance_model_error

DESCRIPTION :rtype: TYPE

Type:

return

property index_tzx
property index_tzy
property index_zxx
property index_zxy
property index_zyx
property index_zyy
property inverse_channel_nomenclature
property inverse_signal_power
property latitude

Latitude

property longitude

Longitude

make_zmm_run(zmm_obj, number_dict)[source]

Helper function to provide a run for a zmm object to aid writing z-file

:param : :type : param zmm_obj: a ZMM that will be written to file, that needs a run associated :param : :type : type zmm_obj: :class: mt_metadata.transfer_functions.io.zfiles.zmm.ZMM :param : :type : param number_dict: mapping between hexy keys and integers, needed for emtf :param z-files: :type z-files: 1, “hy”: 2, “hz”: 3, “ex”: 4, “ey”: 5} :param e.g. {“hx”: :type e.g. {“hx”: 1, “hy”: 2, “hz”: 3, “ex”: 4, “ey”: 5} :param : :type : type number_dict: dictionary :param : :type : return: run :param : :type : rtype: :class:` mt_metadata.timeseries.run.Run`

merge(other, period_min=None, period_max=None, inplace=False)[source]

metadata will be assumed to be from self.

Merge transfer functions together. other can be another TF object or a tuple of TF objects

to set bounds should be of the format

[{“tf”: tf_01, “period_min”: .01, “period_max”: 100},

{“tf”: tf_02, “period_min”: 100, “period_max”: 1000}]

or to just use whats in the transfer function [tf_01, tf_02, …]

The bounds are inclusive, so if you want to merge at say 1 s choose the best one and set the other to a value lower or higher depending on the periods for that transfer function, for example

[{“tf”: tf_01, “period_min”: .01, “period_max”: 100},

{“tf”: tf_02, “period_min”: 100.1, “period_max”: 1000}]

Parameters:
  • other (TF, list of dicts, list of TF objects, dict) – other transfer functions to merge with

  • period_min (float) – minimum period for the original TF

  • period_max (float) – maximum period for the original TF

Returns:

merged TF object with metadata equal to the original (if inplace=False)

Return type:

TF

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

Read an TF response file.

Note

Currently only .edi, .xml, .j, .zmm/rr/ss, .avg files are supported

Parameters:
  • fn (string) – full path to input file

  • file_type (string) – [‘edi’ | ‘j’ | ‘xml’ | ‘avg’ | ‘zmm’ | ‘zrr’ | ‘zss’ | … ] if None, automatically detects file type by the extension.

  • get_elevation (bool) – Get elevation from US National Map DEM

Example:
>>> import mt_metadata.transfer_functions import TF
>>> tf_obj = TF()
>>> tf_obj.read(fn=r"/home/mt/mt01.xml")

Note

If your internet is slow try setting ‘get_elevation’ = False, It can get hooked in a slow loop and slow down reading.

read_tf_file(**kwargs)[source]
property residual_covariance
property run_metadata

station metadata

property station

station name

property station_metadata

station metadata

property survey

Survey ID

property survey_metadata

survey metadata

property tf_id

transfer function id

property tipper

DESCRIPTION :rtype: TYPE

Type:

return

property tipper_error

DESCRIPTION :rtype: TYPE

Type:

return

property tipper_model_error

DESCRIPTION :rtype: TYPE

Type:

return

to_avg()[source]

Translate TF object to ZongeMTAvg object.

Note

Not Implemented yet

Returns:

ZongeMTAvg object

Return type:

mt_metadata.transfer_function.io.zonge.ZongeMTAvg

to_edi()[source]

Convert the TF object to a mt_metadata.transfer_functions.io.edi.EDI object. From there attributes of an EDI object can be manipulated previous to writing to a file.

Returns:

EDI object

Return type:

mt_metadata.transfer_functions.io.edi.EDI

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> edi_object = t.to_edi()
>>> edi_object.Header.acqby = "me"
>>> edi_object.write()
to_emtfxml()[source]

Convert TF to a mt_metadata.transfer_function.io.emtfxml.EMTFXML object.

Returns:

EMTFXML object

Return type:

mt_metadata.transfer_function.io.emtfxml.EMTFXML

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> xml_object = t.to_emtfxml()
>>> xml_object.site.country = "Here"
>>> xml_object.write()
to_jfile()[source]

Translate TF object ot JFile object.

Note

Not Implemented yet

Returns:

JFile object

Return type:

mt_metadata.transfer_functions.io.jfile.JFile

to_ts_station_metadata()[source]

need a convinience function to translate to ts station metadata for MTH5

to_zmm()[source]

Translate TF object to ZMM object.

Returns:

ZMM object

Return type:

mt_metadata.transfer_function.io.zfiles.ZMM

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> zmm_object = t.to_zmm()
>>> zmm_object.processing_type = "new and fancy"
>>> zmm_object.write()
to_zrr()[source]

Translate TF object to ZMM object.

Returns:

ZMM object

Return type:

mt_metadata.transfer_function.io.zfiles.ZMM

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> zmm_object = t.to_zmm()
>>> zmm_object.processing_type = "new and fancy"
>>> zmm_object.write()
to_zss()[source]

Translate TF object to ZMM object.

Returns:

ZMM object

Return type:

mt_metadata.transfer_function.io.zfiles.ZMM

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> zmm_object = t.to_zmm()
>>> zmm_object.processing_type = "new and fancy"
>>> zmm_object.write()
property transfer_function

DESCRIPTION :rtype: TYPE

Type:

return

property transfer_function_error

DESCRIPTION :rtype: TYPE

Type:

return

property transfer_function_model_error

DESCRIPTION :rtype: TYPE

Type:

return

write(fn=None, save_dir=None, fn_basename=None, file_type='edi', **kwargs)[source]

Write an mt file, the supported file types are EDI and XML.

Parameters:
  • fn (pathlib.Path or string) – full path to file to save to

  • save_dir (string) – full path save directory

  • fn_basename (string) – name of file with or without extension

  • file_type (string) – [ ‘edi’ | ‘xml’ | “zmm” ]

keyword arguments include

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

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

Returns:

full path to file

Return type:

string

Example:
>>> tf_obj.write(file_type='xml')
write_tf_file(**kwargs)[source]
exception mt_metadata.transfer_functions.core.TFError[source]

Bases: Exception

Module contents

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

Bases: object

Generic container to hold information about an electromagnetic transfer funtion

The thought here is to have a central container TF.dataset which is an xarray.Dataset that contains the impedance, tipper, errors and covariance values. There are helper functions to get and set these from the TF.dataset. Cause most of the time the user will want just the impedance or the tipper and associated errors. We are accommodating EMTF style covariances to accurately rotated data errors.

When reading and writing edi files this information will be lost.

property channel_nomenclature
copy()[source]
property dataset

This will return an xarray dataset with proper metadata

Returns:

DESCRIPTION

Return type:

TYPE

property elevation

Elevation

property fn

reference to original data file

property frequency
from_avg(avg_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • avg_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.zonge.ZongeMTAvg) – path to .avg file or ZongeMTAvg object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for ZongeMTAvg object

from_edi(edi_obj, get_elevation=False, **kwargs)[source]

Read in an EDI file or a mt_metadata.transfer_functions.io.edi.EDI ojbect

Parameters:
  • edi_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.edi.EDI) – path to edi file or EDI object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Key word arguments for an EDI object

Raises:

TypeError – If input is incorrect

from_emtfxml(emtfxml_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • emtfxml_object (str, pathlib.Path, mt_metadata.transfer_function.io.emtfxml.EMTFXML) – path to emtf xml file or EMTFXML object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for EMTFXML object

from_jfile(j_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • jfile_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.jfile.JFile) – path ot .j file or JFile object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for JFile object

from_ts_station_metadata(ts_station_metadata)[source]

need a convinience function to translate to ts station metadata for MTH5

from_zmm(zmm_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • zmm_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.zfiles.ZMM) – path ot .zmm file or ZMM object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for ZMM object

from_zrr(zrr_obj, get_elevation=False, **kwargs)[source]
Parameters:
from_zss(zss_obj, get_elevation=False, **kwargs)[source]
Parameters:
  • zmm_obj (str, pathlib.Path, mt_metadata.transfer_functions.io.zfiles.ZMM) – path to .zmm file or ZMM object

  • get_elevation (bool) – Try to get elevation from US National Map, defaults to True

  • kwargs (dictionary) – Keyword arguments for ZMM object

has_impedance()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

has_inverse_signal_power()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

has_residual_covariance()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

has_tipper()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

has_transfer_function()[source]

Check to see if the transfer function is not 0 and has transfer function components

Returns:

DESCRIPTION

Return type:

TYPE

property impedance

DESCRIPTION :rtype: TYPE

Type:

return

property impedance_error

DESCRIPTION :rtype: TYPE

Type:

return

property impedance_model_error

DESCRIPTION :rtype: TYPE

Type:

return

property index_tzx
property index_tzy
property index_zxx
property index_zxy
property index_zyx
property index_zyy
property inverse_channel_nomenclature
property inverse_signal_power
property latitude

Latitude

property longitude

Longitude

make_zmm_run(zmm_obj, number_dict)[source]

Helper function to provide a run for a zmm object to aid writing z-file

:param : :type : param zmm_obj: a ZMM that will be written to file, that needs a run associated :param : :type : type zmm_obj: :class: mt_metadata.transfer_functions.io.zfiles.zmm.ZMM :param : :type : param number_dict: mapping between hexy keys and integers, needed for emtf :param z-files: :type z-files: 1, “hy”: 2, “hz”: 3, “ex”: 4, “ey”: 5} :param e.g. {“hx”: :type e.g. {“hx”: 1, “hy”: 2, “hz”: 3, “ex”: 4, “ey”: 5} :param : :type : type number_dict: dictionary :param : :type : return: run :param : :type : rtype: :class:` mt_metadata.timeseries.run.Run`

merge(other, period_min=None, period_max=None, inplace=False)[source]

metadata will be assumed to be from self.

Merge transfer functions together. other can be another TF object or a tuple of TF objects

to set bounds should be of the format

[{“tf”: tf_01, “period_min”: .01, “period_max”: 100},

{“tf”: tf_02, “period_min”: 100, “period_max”: 1000}]

or to just use whats in the transfer function [tf_01, tf_02, …]

The bounds are inclusive, so if you want to merge at say 1 s choose the best one and set the other to a value lower or higher depending on the periods for that transfer function, for example

[{“tf”: tf_01, “period_min”: .01, “period_max”: 100},

{“tf”: tf_02, “period_min”: 100.1, “period_max”: 1000}]

Parameters:
  • other (TF, list of dicts, list of TF objects, dict) – other transfer functions to merge with

  • period_min (float) – minimum period for the original TF

  • period_max (float) – maximum period for the original TF

Returns:

merged TF object with metadata equal to the original (if inplace=False)

Return type:

TF

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

Read an TF response file.

Note

Currently only .edi, .xml, .j, .zmm/rr/ss, .avg files are supported

Parameters:
  • fn (string) – full path to input file

  • file_type (string) – [‘edi’ | ‘j’ | ‘xml’ | ‘avg’ | ‘zmm’ | ‘zrr’ | ‘zss’ | … ] if None, automatically detects file type by the extension.

  • get_elevation (bool) – Get elevation from US National Map DEM

Example:
>>> import mt_metadata.transfer_functions import TF
>>> tf_obj = TF()
>>> tf_obj.read(fn=r"/home/mt/mt01.xml")

Note

If your internet is slow try setting ‘get_elevation’ = False, It can get hooked in a slow loop and slow down reading.

read_tf_file(**kwargs)[source]
property residual_covariance
property run_metadata

station metadata

property station

station name

property station_metadata

station metadata

property survey

Survey ID

property survey_metadata

survey metadata

property tf_id

transfer function id

property tipper

DESCRIPTION :rtype: TYPE

Type:

return

property tipper_error

DESCRIPTION :rtype: TYPE

Type:

return

property tipper_model_error

DESCRIPTION :rtype: TYPE

Type:

return

to_avg()[source]

Translate TF object to ZongeMTAvg object.

Note

Not Implemented yet

Returns:

ZongeMTAvg object

Return type:

mt_metadata.transfer_function.io.zonge.ZongeMTAvg

to_edi()[source]

Convert the TF object to a mt_metadata.transfer_functions.io.edi.EDI object. From there attributes of an EDI object can be manipulated previous to writing to a file.

Returns:

EDI object

Return type:

mt_metadata.transfer_functions.io.edi.EDI

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> edi_object = t.to_edi()
>>> edi_object.Header.acqby = "me"
>>> edi_object.write()
to_emtfxml()[source]

Convert TF to a mt_metadata.transfer_function.io.emtfxml.EMTFXML object.

Returns:

EMTFXML object

Return type:

mt_metadata.transfer_function.io.emtfxml.EMTFXML

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> xml_object = t.to_emtfxml()
>>> xml_object.site.country = "Here"
>>> xml_object.write()
to_jfile()[source]

Translate TF object ot JFile object.

Note

Not Implemented yet

Returns:

JFile object

Return type:

mt_metadata.transfer_functions.io.jfile.JFile

to_ts_station_metadata()[source]

need a convinience function to translate to ts station metadata for MTH5

to_zmm()[source]

Translate TF object to ZMM object.

Returns:

ZMM object

Return type:

mt_metadata.transfer_function.io.zfiles.ZMM

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> zmm_object = t.to_zmm()
>>> zmm_object.processing_type = "new and fancy"
>>> zmm_object.write()
to_zrr()[source]

Translate TF object to ZMM object.

Returns:

ZMM object

Return type:

mt_metadata.transfer_function.io.zfiles.ZMM

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> zmm_object = t.to_zmm()
>>> zmm_object.processing_type = "new and fancy"
>>> zmm_object.write()
to_zss()[source]

Translate TF object to ZMM object.

Returns:

ZMM object

Return type:

mt_metadata.transfer_function.io.zfiles.ZMM

>>> from mt_metadata.transfer_functions import TF
>>> from mt_metadata import TF_XML
>>> t = TF(TF_XML)
>>> t.read()
>>> zmm_object = t.to_zmm()
>>> zmm_object.processing_type = "new and fancy"
>>> zmm_object.write()
property transfer_function

DESCRIPTION :rtype: TYPE

Type:

return

property transfer_function_error

DESCRIPTION :rtype: TYPE

Type:

return

property transfer_function_model_error

DESCRIPTION :rtype: TYPE

Type:

return

write(fn=None, save_dir=None, fn_basename=None, file_type='edi', **kwargs)[source]

Write an mt file, the supported file types are EDI and XML.

Parameters:
  • fn (pathlib.Path or string) – full path to file to save to

  • save_dir (string) – full path save directory

  • fn_basename (string) – name of file with or without extension

  • file_type (string) – [ ‘edi’ | ‘xml’ | “zmm” ]

keyword arguments include

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

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

Returns:

full path to file

Return type:

string

Example:
>>> tf_obj.write(file_type='xml')
write_tf_file(**kwargs)[source]