pyatoa.utils.write
For writing various output files used by Pyatoa, Specfem and Seisflows
Module Contents
Functions
|
Pyatoa requires stations to be discoverable in SEED format, i.e., in a data |
|
This function writes a text file containing event misfit. |
|
Generate the STATIONS_ADJOINT file for Specfem input by reading in the |
|
Take AdjointSource auxiliary data from a Pyasdf dataset and write out |
- pyatoa.utils.write.write_inv_seed(inv, path='./', dir_structure='{sta}.{net}', file_template='RESP.{net}.{sta}.{loc}.{cha}', components='ZNE', channel_code='HX{comp}', **kwargs)[source]
Pyatoa requires stations to be discoverable in SEED format, i.e., in a data center repository. This structure dictates that each component of each station has its own individual StationXML file, saved in a specific directory structure with a unique file naming schema.
This utility is useful for creating the necessary StationXML files for temporary or synthetic stations which are not discoverable via FDSN or through datacenters.
Note
kwargs are passed to obspy.core.inventory.channel.Channel
- Parameters:
path (str) – location to save StationXML files to
dir_structure (str) – template for directory structure, likely should not need to change from the default
file_template (str) – template for file naming, likely should not change from default template
components (str) – OPTIONAL, if inventory does not contain components (e.g., if read from a SPECFEM STATIONS file), components will be filled in automatically.
channel_code (str) – Explicitely defined default channel values for
generating channels on the fly when none are provided by the inventory
- pyatoa.utils.write.write_misfit(ds, iteration, step_count=None, path='./', fidout=None)[source]
This function writes a text file containing event misfit. This misfit value corresponds to F_S^T of Eq 6. Tape et al. (2010)
e.g. path/to/misfits/{iteration}/{event_id}
These files will then need to be read by: seisflows.workflow.write_misfit()
- Parameters:
ds (pyasdf.ASDFDataSet) – processed dataset, assumed to contain auxiliary_data.Statistics
iteration (str or int) – iteration number, e.g. “i01”. Will be formatted so int ok.
step_count (str or int) – step count e.g. “s00”. Will be formatted so int ok.
path (str) – output path to write the misfit. fid will be the event name
fidout (str) – allow user defined filename, otherwise default to name of ds note: if given, var ‘pathout’ is not used, this must be a full path
- pyatoa.utils.write.write_stations_adjoint(ds, iteration, specfem_station_file, step_count=None, pathout=None)[source]
Generate the STATIONS_ADJOINT file for Specfem input by reading in the STATIONS file and cross-checking which adjoint sources are available in the Pyasdf dataset.
- Parameters:
ds (pyasdf.ASDFDataSet) – dataset containing AdjointSources auxiliary data
iteration (str or int) – iteration number, e.g. “i01”. Will be formatted so int ok.
step_count (str or int) – step count e.g. “s00”. Will be formatted so int ok. If NoneType, final step of the iteration will be chosen automatically.
specfem_station_file (str) – path/to/specfem/DATA/STATIONS
pathout (str) – path to save file ‘STATIONS_ADJOINT’
- pyatoa.utils.write.write_adj_src_to_ascii(ds, iteration, step_count=None, pathout=None, comp_list='ZNE')[source]
Take AdjointSource auxiliary data from a Pyasdf dataset and write out the adjoint sources into ascii files with proper formatting, for input into PyASDF.
Note
Specfem dictates that if a station is given as an adjoint source, all components must be present, even if some components don’t have any misfit windows. This function writes blank adjoint sources (an array of 0’s) to satisfy this requirement.
- Parameters:
ds (pyasdf.ASDFDataSet) – dataset containing adjoint sources
iteration (str or int) – iteration number, e.g. “i00”. Will be formatted so int ok.
step_count (str or int) – step count e.g. “s00”. Will be formatted so int ok. If NoneType, final step of the iteration will be chosen automatically.
pathout (str) – path to write the adjoint sources to
comp_list (str) – component list to check when writing blank adjoint sources defaults to N, E, Z, but can also be e.g. R, T, Z