pyatoa.core.config

Configuration of User-set parameters within the package. Contains external functions to set Config objects of Pyflex and Pyadjoint.

Module Contents

Classes

Config

The Config class is the main interaction object between the User and

class pyatoa.core.config.Config(yaml_fid=None, ds=None, path=None, iteration=None, step_count=None, event_id=None, min_period=10, max_period=100, rotate_to_rtz=False, unit_output='DISP', component_list=None, adj_src_type='cc_traveltime', observed_tag='observed', synthetic_tag=None, st_obs_type='obs', st_syn_type='syn', win_amp_ratio=0.0, pyflex_parameters=None, pyadjoint_parameters=None)[source]

The Config class is the main interaction object between the User and workflow. It is used by Manager for workflow management, and also for information sharing between Pyatoa objects and functions. The Config can be read to and written from external files and ASDFDataSets.

property pfcfg[source]

simple dictionary print of pyflex config object

property pacfg[source]

simple dictionary print of pyflex config object

property iter_tag[source]

string formatted version of iteration, e.g. ‘i00’

property step_tag[source]

string formatted version of step, e.g. ‘s00’

property eval_tag[source]

string formatted version of iter and step, e.g. ‘i01s00’

property synthetic_tag[source]

tag to be used for synthetic data, uses iteration and step count

property aux_path[source]

property to quickly get a bog-standard aux path e.g. i00/s00

__str__()[source]

String representation of the class for print statements. It separates information into similar bins for readability.

__repr__()[source]

Simple call string representation

_check()[source]

A series of sanity checks to make sure that the configuration parameters are set properly to avoid any problems throughout the workflow. Should normally be run after any parameters are changed to make sure that they are acceptable.

_get_aux_path(default='default', separator='/')[source]

Pre-formatted path to be used for tagging and identification in ASDF dataset auxiliary data. Internal function to be called by property aux_path.

Parameters:
  • default (str) – if no iteration or step information is given, path will default to this string. By default it is ‘default’.

  • separator (str) – if an iteration and step_count are available, separator will be placed between. Defaults to ‘/’, use ‘’ for no separator.

static _check_io_format(fid, fmt=None)[source]

A simple check before reading or writing the config to determine what file format to use. Currently accepted file formats are yaml, asdf and ascii.

Parameters:

fmt (str) – format specified by the User

Return type:

str

Returns:

format string to be understood by the calling function

copy()[source]

Simply convenience function to return a deep copy of the Config

write(write_to, fmt=None)[source]

Wrapper for underlying low-level write functions

Parameters:
  • fmt (str) –

    format to save parameters to. Available:

    • yaml: Write all parameters to a .yaml file which can be read later

    • ascii: Write parameters to a simple ascii file, not very smart and yaml is prefereable in most cases

    • asdf: Save the Config into an ASDFDataSet under the auxiliary data attribute

  • write_to (str or pyasdf.ASDFDataSet) – filename to save config to, or dataset to save to

read(read_from, path=None, fmt=None)[source]

Wrapper for underlying low-level read functions

Parameters:
  • read_from (str or pyasdf.asdf_data_set.ASDFDataSet) – filename to read config from, or ds to read from

  • path (str) – if fmt=’asdf’, path to the config in the aux data

  • fmt (str) – file format to read parameters from, will be guessed but can also be explicitely set (available: ‘yaml’, ‘ascii’, ‘asdf’)

_write_yaml(filename)[source]

Write config parameters to a yaml file, retain order

Parameters:

filename (str) – filename to save yaml file

_write_asdf(ds)[source]

Save the Config values as a parameter dictionary in the ASDF Data set Converts types to play nice with ASDF Auxiliary Data. Flattens dictionaries and external Config objects for easy storage.

Parameters:

ds (pyasdf.asdf_data_set.ASDFDataSet) – dataset to save the config file to

_write_ascii(filename)[source]

Write the config parameters to an ascii file

Parameters:

filename (str) – filename to write the ascii file to

_read_yaml(filename)[source]

Read config parameters from a yaml file, parse to attributes.

Parameters:

filename (str) – filename to save yaml file

Return type:

dict

Returns:

key word arguments that do not belong to Pyatoa are passed back as a dictionary object, these are expected to be arguments that are to be used in Pyflex and Pyadjoint configs

Raises:

ValueError – if unrecognized kwargs are found in the yaml file

_read_asdf(ds, path)[source]

Read and set config parameters from an ASDF Dataset, assumes that all necessary parameters are located in the auxiliary data subgroup of the dataset, which will be the case if the write_to_asdf() function was used Assumes some things about the structure of the auxiliary data.

Parameters:
  • ds (pyasdf.asdf_data_set.ASDFDataSet) – dataset with config parameter to read

  • path (str) – model number e.g. ‘m00’ or ‘default’, or ‘m00/s00’