Transfer Function

Plot

Regression

Base

EMTF Z File Helpers

These methods can possibly be moved under mt_metadata, or mth5

They extract info needed to setup emtf_z files.

aurora.transfer_function.emtf_z_file_helpers.clip_bands_from_z_file(z_path, n_bands_clip, output_z_path=None, n_sensors=5)[source]

This function takes a z_file and clips periods off the end of it. It can come in handy sometimes – specifically for manipulating matlab results of synthetic data.

Parameters
z_path: Path or str

path to the z_file to read in and clip periods from

n_periods_clip: integer

how many periods to clip from the end of the zfile

overwrite: bool

whether to overwrite the zfile or rename it

n_sensors
Returns
aurora.transfer_function.emtf_z_file_helpers.get_default_orientation_block(n_ch=5)[source]

Helper function used when working with matlab structs which do not have enough info to make headers

Parameters
n_ch: int

number of channels at the station

Returns
orientation_strs: list

List of text strings, one per channel

aurora.transfer_function.emtf_z_file_helpers.make_orientation_block_of_z_file(run_obj, channel_list=None)[source]

Replicates emtz z-file metadata about orientation like this: 1 0.00 0.00 tes Hx 2 90.00 0.00 tes Hy 3 0.00 0.00 tes Hz 4 0.00 0.00 tes Ex 5 90.00 0.00 tes Ey

based on this fortran snippet:

write(3, 115) k, orient(1, k), orient(2, k), stname(1: 3), chid(k)

format(i5, 1x, f8.2, 1x, f8.2, 1x, a3, 2x, a6) #Fortran Format

Parameters
run_obj: mth5.groups.master_station_run_channel.RunGroup

Container with metadata about the channels

Returns
output_strings: list (of strings)

Each element of the list corresponds to one channel, and is a block of text for the emtf z-file with the channel orientation, name and associated station

aurora.transfer_function.emtf_z_file_helpers.merge_tf_collection_to_match_z_file(aux_data, tf_collection)[source]

Currently this is only used for the synthtetic test, but maybe useful for other tests. Given data from a z_file, and a tf_collection, the tf_collection may have several TF estimates at the same frequency from multiple decimation levels. This tries to make a single array as a function of period for all rho and phi

Parameters
aux_data: merge_tf_collection_to_match_z_file

Object representing a z-file

tf_collection: aurora.transfer_function.transfer_function_collection
.TransferFunctionCollection

Object representing the transfer function returnd from the aurora processing

Returns
result: dict of dicts

Keyed by [“rho”, “phi”], below each of these is an [“xy”, “yx”,] entry. The lowest level entries are numpy arrays.

Iter Control

follows Gary’s IterControl.m in iris_mt_scratch/egbert_codes-20210121T193218Z-001/egbert_codes/matlabPrototype_10-13-20/TF/classes

class aurora.transfer_function.regression.iter_control.IterControl(max_number_of_iterations=10, max_number_of_redescending_iterations=2, **kwargs)[source]

Bases: object

Attributes
continue_redescending
correction_factor

TODO: This is an RME specific property.

Methods

converged(b, b0)

Parameters

property continue_redescending
converged(b, b0)[source]
Parameters
bcomplex-valued numpy array

the most recent regression estimate

b0complex-valued numpy array

The previous regression estimate

Returns
converged: bool

True of the regression has terminated, False otherwise

Notes:
The variable maximum_change finds the maximum amplitude component of the vector
1-b/b0. Looking at the formula, one might want to cast this instead as
1 - abs(b/b0), however, that will be insensitive to phase changes in b,
which is complex valued. The way it is coded np.max(np.abs(1 - b / b0)) is
correct as it stands.
property correction_factor

TODO: This is an RME specific property. Suggest move r0, u0 and this method into an RME-config class.

See notes on usage in transfer_function.regression.helper_functions.rme_beta

Returns
correction_factorfloat

correction factor used for scaling the residual error_variance

Transfer Function Collection

Transfer Function Header

follows Gary’s TFHeader.m iris_mt_scratch/egbert_codes-20210121T193218Z-001/egbert_codes/matlabPrototype_10-13-20/TF/classes

class aurora.transfer_function.transfer_function_header.TransferFunctionHeader(**kwargs)[source]

Bases: object

class for storing metadata for a TF estimate

This class should inherit the metadata from the remote and reference stations. As of 2021-07-20 the class functions with only the station_id and channel_id values.

<See Issue #41> </See Issue #41>

Attributes
local_channels
local_station
local_station_id
num_input_channels
num_output_channels
reference_station_id
property local_channels
property local_station
property local_station_id
property num_input_channels
property num_output_channels
property reference_station_id

TTFZ