mth5.io.usgs_ascii

Submodules

Classes

AsciiMetadata

Container for all the important metadata in a USGS ascii file.

USGSascii

Read and write USGS ascii formatted time series.

Functions

read_ascii(fn)

read USGS ASCII formatted file

Package Contents

class mth5.io.usgs_ascii.AsciiMetadata(fn=None, **kwargs)[source]

Container for all the important metadata in a USGS ascii file.

Attributes

Description

survey_id

Survey name

site_id

Site name

run_id

Run number

site_latitude

Site latitude in decimal degrees WGS84

site_longitude

Site longitude in decimal degrees WGS84

site_elevation

Site elevation according to national map meters

start

Start time of station YYYY-MM-DDThh:mm:ss UTC

end

Stop time of station YYYY-MM-DDThh:mm:ss UTC

sample_rate

Sampling rate samples/second

n_samples

Number of samples

n_channels

Number of channels

coordinate_system

[ Geographic North | Geomagnetic North ]

chn_settings

Channel settings, see below

missing_data_flag

Missing data value

Chn_settings:

Keys

Description

ChnNum

site_id+channel number

ChnID

Component [ ex | ey | hx | hy | hz ]

InstrumentID

Data logger + sensor number

Azimuth

Setup angle of componet in degrees relative to coordinate_system

Dipole_Length

Dipole length in meters

logger
property fn
missing_data_flag
coordinate_system = None
ex_metadata
ey_metadata
hx_metadata
hy_metadata
hz_metadata
channel_order = ['hx', 'ex', 'hy', 'ey', 'hz']
national_map_url = 'https://epqs.nationalmap.gov/v1/json?x={0:.5f}&y={1:.5f}&units=Meters&wkid=4326&includeDate=False'
property file_size
property survey_id
property run_id
property site_id
property latitude
property longitude
property elevation

get elevation from national map

property start
property end
property n_channels
property sample_rate
property n_samples
property survey_metadata
property station_metadata
property run_metadata
get_component_info(comp)[source]
Parameters:

comp (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

read_metadata(fn=None, meta_lines=None)[source]

Read in a meta from the raw string or file. Populate all metadata as attributes.

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

  • meta_lines (list) – lines of metadata to read

write_metadata(chn_list=['Ex', 'Ey', 'Hx', 'Hy', 'Hz'])[source]

Write out metadata in the format of USGS ascii.

return:

list of metadate lines.

Note

meant to use ‘

‘.join(lines) to write out in a file.

class mth5.io.usgs_ascii.USGSascii(fn=None, **kwargs)[source]

Bases: mth5.io.usgs_ascii.AsciiMetadata

Read and write USGS ascii formatted time series.

Attributes

Description

ts

Pandas dataframe holding the time series data

fn

Full path to .asc file

station_dir

Full path to station directory

meta_notes

Notes of how the station was collected

Example:
>>> zc = Z3DCollection()
>>> fn_list = zc.get_time_blocks(z3d_path)
>>> zm = USGSasc()
>>> zm.SurveyID = 'iMUSH'
>>> zm.get_z3d_db(fn_list[0])
>>> zm.read_mtft24_cfg()
>>> zm.CoordinateSystem = 'Geomagnetic North'
>>> zm.SurveyID = 'MT'
>>> zm.write_asc_file(str_fmt='%15.7e')
>>> zm.write_station_info_metadata()
ts = None
station_dir
meta_notes = None
property hx

HX

property hy

hy

property hz

hz

property ex

ex

property ey

ey

to_run_ts()[source]

Get xarray for run

read(fn=None)[source]

Read in a USGS ascii file and fill attributes accordingly.

Parameters:

fn (string) – full path to .asc file to be read in

write(save_fn=None, chunk_size=1024, str_fmt='%15.7e', full=True, compress=False, save_dir=None, compress_type='zip', convert_electrics=True)[source]

Write an ascii file in the USGS ascii format.

Parameters:
  • save_fn (string) – full path to file name to save the merged ascii to

  • chunck_size (int) – chunck size to write file in blocks, larger numbers are typically slower.

  • str_fmt (string) – format of the data as written

  • full (boolean [ True | False ]) – write out the complete file, mostly for testing.

  • compress (boolean [ True | False ]) – compress file

  • compress_type (boolean [ zip | gzip ]) – compress file using zip or gzip

mth5.io.usgs_ascii.read_ascii(fn)[source]

read USGS ASCII formatted file

Parameters:

fn (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE