aurora.sandbox.io_helpers package

Submodules

aurora.sandbox.io_helpers.emtf_band_setup module

In this module is a class that emulates the old EMTF Band Setup File

class aurora.sandbox.io_helpers.emtf_band_setup.EMTFBandSetupFile(filepath: str | Path | None = None, sample_rate: float | None = None)[source]

Bases: object

Attributes:
decimation_levels

Return the decimation level names (they are integers) in an array

num_bands

return the number of bands in the band setup file

num_decimation_levels

Return the number of decimation levels

Methods

compute_band_edges(decimation_factors, ...)

Adds columns to df defining the upper and lower bounds of the frequency bands in Hz.

get_decimation_level(decimation_level[, order])

Return a sub-dataframe with only the rows that correspond to the requested decimation level

load([filepath])

Loads an EMTF band setup file and casts it to a dataframe.

compute_band_edges(decimation_factors: list, num_samples_window: int) dict[source]

Adds columns to df defining the upper and lower bounds of the frequency bands in Hz.

Parameters:
  • decimation_factors (list) – The decimation factors

  • num_samples_window (int) – The window size

Returns:

band_edges – Keys are decimation level ids and values are numpy arrays with shape num_bands x 2.

Return type:

dict

property decimation_levels: ndarray

Return the decimation level names (they are integers) in an array

get_decimation_level(decimation_level: int, order: str = 'ascending_frequency') DataFrame[source]

Return a sub-dataframe with only the rows that correspond to the requested decimation level

Parameters:
  • decimation_level (int) – The id of the decimation level

  • order (str) –

Returns:

decimation_level_df – A sub-dataframe with only the rows that correspond to the requested decimation level

Return type:

pd.DataFrame

load(filepath: str | Path | None = None) None[source]

Loads an EMTF band setup file and casts it to a dataframe. - populates self.df with the EMTF band setup dataframe.

Parameters:

filepath (Optional[Union[str, pathlib.Path, None]]) – The path to the emtf band setup (.cfrg) file.

property num_bands: int

return the number of bands in the band setup file

property num_decimation_levels: int

Return the number of decimation levels

aurora.sandbox.io_helpers.fdsn_dataset module

This module contains a class that can be used to create mth5 datasets from FDSN servers

TODO: Review usages and consider replace with MTH5 FDSN class.

class aurora.sandbox.io_helpers.fdsn_dataset.FDSNDataset[source]

Bases: object

This class contains the information needed to uniquely specify a dataset that will be accessed from IRIS, NCEDC, or other FDSN client. This config will only work for single stations.

Need: -fdsn_metadata_parameters -data_parameters (how to rover, or load from local) -a way to specify station-channel, this config will only work for single stations.

Attributes:
client

Returns the client (creates if doesn’t exist)

h5_filebase

retruns an h5 filename

Methods

describe()

logs some info to terminal

get_data_via_fdsn_client()

Gets data from client

get_inventory([...])

Gets inventory object from FDSN client

initialize_client()

Initialize the client

property client

Returns the client (creates if doesn’t exist)

describe()[source]

logs some info to terminal

get_data_via_fdsn_client()[source]

Gets data from client

get_inventory(ensure_inventory_stages_are_named=True, level='response')[source]

Gets inventory object from FDSN client

property h5_filebase

retruns an h5 filename

initialize_client()[source]

Initialize the client

aurora.sandbox.io_helpers.inventory_review module

In this module are some helper functions for working with FDSN inventory objects.

aurora.sandbox.io_helpers.inventory_review.describe_inventory_stages(inventory: Inventory, assign_names: bool | None = False, verbose: bool | None = False) None[source]

Scans inventory looking for stages. Has option to assign names to stages, these names are used as keys in MTH5. Modifies inventory in place.

Parameters:
  • inventory (obspy.Inventory) – obspy representation of station XML

  • assign_names (bool) – If True, inventory stage names will be assigned

  • verbose (bool) – If True, some info logs are created.

aurora.sandbox.io_helpers.inventory_review.scan_inventory_for_nonconformity(inventory, verbose=False)[source]

One off method for dealing with issues of historical data. Checks for the following: 1. Channel Codes: Q2, Q3 –> Q1, Q2 2. Field-type code: “T” instead of “F” 3. Tesla to nT :param inventory: Object containing metadata about station and channels :type inventory: obspy.core.inventory.inventory.Inventory

Returns:

inventory – Object containing metadata about station and channels Might be modified during this function

Return type:

obspy.core.inventory.inventory.Inventory

aurora.sandbox.io_helpers.make_mth5_helpers module

This module contains helper functions for making mth5 from FDSN clients.

aurora.sandbox.io_helpers.zfile_murphy module

This module contains a class that was contributed by Ben Murphy for working with EMTF “Z-files”

class aurora.sandbox.io_helpers.zfile_murphy.ZFile(filename: str | Path)[source]

Bases: object

Methods

apparent_resistivity([angle])

compute the apparent resistivity from the impedance.

get_station_id()

get station ID from zfile

impedance([angle])

Compute the Impedance and errors from the transfer function.

load()

load Z-file and populate attributes of class

open_file()

attempt to open file

phi(mode)

Return the phase for the given mode.

read_channel_information()

read_coordinates_and_declination()

read coordinates and declination

read_number_of_channels_and_number_of_frequencies()

rho(mode)

Return the apparent resistivity for the given mode.

skip_header_lines()

Skip over the header when reading

tippers([angle])

compute the tipper from transfer function

apparent_resistivity(angle: float = 0.0)[source]

compute the apparent resistivity from the impedance.

get_station_id() None[source]

get station ID from zfile

impedance(angle: float | None = 0.0)[source]

Compute the Impedance and errors from the transfer function. - note u,v are identity matrices if angle=0

Parameters:

angle (float) – The angle about the vertical axis by which to rotate the Z tensor.

Returns:

  • z (np.ndarray) – The impedance tensor

  • error (np.ndarray) – Errors for the impedance tensor

load()[source]

load Z-file and populate attributes of class

open_file() None[source]

attempt to open file

phi(mode)[source]

Return the phase for the given mode.

Convenience function to help with streamlining synthetic tests - to be eventually replaced by functionality in mt_metadata.tf :param mode: “xy” or “yx” :type mode: str

Return type:

phi

read_channel_information()[source]
read_coordinates_and_declination() None[source]

read coordinates and declination

read_number_of_channels_and_number_of_frequencies()[source]
rho(mode)[source]

Return the apparent resistivity for the given mode.

Convenience function to help with streamlining synthetic tests - to be eventually replaced by functionality in mt_metadata.tf

Parameters:

mode (str) – “xy” or “yx”

Return type:

rho

skip_header_lines() None[source]

Skip over the header when reading

tippers(angle=0.0)[source]

compute the tipper from transfer function

aurora.sandbox.io_helpers.zfile_murphy.read_z_file(z_file_path, angle=0.0) ZFile[source]

Reads a zFile and returns a ZFile object.

Parameters:
  • z_file_path (string or pathlib.Path) – The name of the EMTF-style z-file to operate on

  • angle (float) – How much rotation to apply. This is a kludge variable used to help compare legacy SPUD results which are rotated onto a cardinal grid, vs aurora which store the TF in the coordinate system of acquisition

Returns:

z_obj – The zFile as an object.

Return type:

ZFile

Module contents