mth5.io package

Submodules

mth5.io.miniseed module

Created on Wed Sep 30 10:20:12 2020

author

Jared Peacock

license

MIT

mth5.io.miniseed.read_miniseed(fn)[source]

Read a miniseed file into a mth5.timeseries.RunTS object

Parameters

fn (string) – full path to the miniseed file

Returns

Return type

TYPE

mth5.io.nims module

NIMS

  • deals with reading in NIMS DATA.BIN files

This is a translation from Matlab codes written and edited by:
  • Anna Kelbert

  • Paul Bedrosian

  • Esteban Bowles-Martinez

  • Possibly others.

I’ve tested it against a version, and it matches. The data/GPS gaps I still don’t understand so for now the time series is just made continuous and the number of missing seconds is clipped from the end of the time series.

Note

this only works for 8Hz data for now

copyright

Jared Peacock (jpeacock@usgs.gov)

license

MIT

class mth5.io.nims.GPS(gps_string, index=0)[source]

Bases: object

class to parse GPS stamp from the NIMS

Depending on the type of Stamp different attributes will be filled.

GPRMC has full date and time information and declination GPGGA has elevation data

Note

GPGGA date is set to 1980-01-01 so that the time can be estimated. Should use GPRMC for accurate date/time information.

property declination

geomagnetic declination in degrees from north

property elevation

elevation in meters

property fix

GPS fixed

property gps_type

GPRMC or GPGGA

property latitude

Latitude in decimal degrees, WGS84

property longitude

Latitude in decimal degrees, WGS84

parse_gps_string(gps_string)[source]

Parse a raw gps string from the NIMS and set appropriate attributes. GPS string will first be validated, then parsed.

Parameters

gps_string (string) – raw GPS string to be parsed

property time_stamp

return a datetime object of the time stamp

validate_gps_list(gps_list)[source]

check to make sure the gps stamp is the correct format, checks each element for the proper format

Parameters

gps_list (list) – a parsed gps string from a NIMS

Raises

mth5.io.nims.GPSError if anything is wrong.

validate_gps_string(gps_string)[source]

make sure the string is valid, remove any binary numbers and find the end of the string as ‘*’

Parameters

gps_string (string) – raw GPS string to be validated

Returns

validated string or None if there is something wrong

exception mth5.io.nims.GPSError[source]

Bases: Exception

class mth5.io.nims.NIMS(fn=None)[source]

Bases: mth5.io.nims.NIMSHeader

NIMS Class will read in a NIMS DATA.BIN file.

A fast way to read the binary files are to first read in the GPS strings, the third byte in each block as a character and parse that into valid GPS stamps.

Then read in the entire data set as unsigned 8 bit integers and reshape the data to be n seconds x block size. Then parse that array into the status information and data.

I only have a limited amount of .BIN files to test so this will likely break if there are issues such as data gaps. This has been tested against the matlab program loadNIMS by Anna Kelbert and the match for all the .bin files I have. If something looks weird check it against that program.

Warning

Currently Only 8 Hz data is supported

align_data(data_array, stamps)[source]

Need to match up the first good GPS stamp with the data

Do this by using the first GPS stamp and assuming that the time from the first time stamp to the start is the index value.

put the data into a pandas data frame that is indexed by time

Parameters
  • data_array (array) – structure array with columns for each component [hx, hy, hz, ex, ey]

  • stamps (list) – list of GPS stamps [[status_index, [GPRMC, GPGGA]]]

Returns

pandas DataFrame with colums of components and indexed by time initialized by the start time.

Note

Data gaps are squeezed cause not sure what a gap actually means.

property box_temperature

data logger temperature, sampled at 1 second

calibrate_data(ts)[source]

Apply calibrations to data

Note

this needs work, would not use this now.

check_timing(stamps)[source]

make sure that there are the correct number of seconds in between the first and last GPS GPRMC stamps

Parameters

stamps (list) – list of GPS stamps [[status_index, [GPRMC, GPGGA]]]

Returns

[ True | False ] if data is valid or not.

Returns

gap index locations

Note

currently it is assumed that if a data gap occurs the data can be squeezed to remove them. Probably a more elegant way of doing it.

property declination

median elevation value from all the GPS stamps in decimal degrees WGS84

Only get from the first stamp within the sets

property elevation

median elevation value from all the GPS stamps in decimal degrees WGS84

Only get from the first stamp within the sets

property end_time

start time is the first good GPS time stamp minus the seconds to the beginning of the time series.

property ex

EX

property ey

EY

find_sequence(data_array, block_sequence=None)[source]

find a sequence in a given array

Parameters
  • data_array (array) – array of the data with shape [n, m] where n is the number of seconds recorded m is the block length for a given sampling rate.

  • block_sequence (list) – sequence pattern to locate default is [1, 131] the start of a data block.

Returns

array of index locations where the sequence is found.

get_stamps(nims_string)[source]

get a list of valid GPS strings and match synchronous GPRMC with GPGGA stamps if possible.

Parameters

nims_string (str) – raw GPS string output by NIMS

property hx

HX

property hy

HY

property hz

HZ

property latitude

median latitude value from all the GPS stamps in decimal degrees WGS84

Only get from the GPRMC stamp as they should be duplicates

property longitude

median longitude value from all the GPS stamps in decimal degrees WGS84

Only get from the first stamp within the sets

make_dt_index(start_time, sample_rate, stop_time=None, n_samples=None)[source]

make time index array

Note

date-time format should be YYYY-M-DDThh:mm:ss.ms UTC

Parameters
  • start_time (string) – start time

  • end_time (string) – end time

  • sample_rate (float) – sample_rate in samples/second

match_status_with_gps_stamps(status_array, gps_list)[source]

Match the index values from the status array with the index values of the GPS stamps. There appears to be a bit of wiggle room between when the lock is recorded and the stamp was actually recorded. This is typically 1 second and sometimes 2.

Parameters
  • status_array (array) – array of status values from each data block

  • gps_list (list) – list of valid GPS stamps [[GPRMC, GPGGA], …]

Note

I think there is a 2 second gap between the lock and the first stamp character.

read_nims(fn=None)[source]

Read NIMS DATA.BIN file.

  1. Read in the header information and stores those as attributes with the same names as in the header file.

  2. Locate the beginning of the data blocks by looking for the first [1, 131, …] combo. Anything before that is cut out.

  3. Make sure the data is a multiple of the block length, if the data is longer the extra bits are cut off.

  4. Read in the GPS data (3rd byte of each block) as characters. Parses those into valid GPS stamps with appropriate index locations of where the ‘$’ was found.

  5. Read in the data as unsigned 8-bit integers and reshape the array into [N, data_block_length]. Parse this array into the status information and the data.

  6. Remove duplicate blocks, by removing the first of the duplicates as suggested by Anna and Paul.

  7. Match the GPS locks from the status with valid GPS stamps.

  8. Check to make sure that there is the correct number of seconds between the first and last GPS stamp. The extra seconds are cut off from the end of the time series. Not sure if this is the best way to accommodate gaps in the data.

Note

The data and information array returned have the duplicates removed and the sequence reset to be monotonic.

Parameters

fn (str) – full path to DATA.BIN file

Example

>>> from mth5.io import nims
>>> n = nims.NIMS(r"/home/mt_data/nims/mt001.bin")
remove_duplicates(info_array, data_array)[source]

remove duplicate blocks, removing the first duplicate as suggested by Paul and Anna. Checks to make sure that the mag data are identical for the duplicate blocks. Removes the blocks from the information and data arrays and returns the reduced arrays. This should sync up the timing of GPS stamps and index values.

Parameters
  • info_array (np.array) – structured array of block information

  • data_array (np.array) – structured array of the data

Returns

reduced information array

Returns

reduced data array

Returns

index of duplicates in raw data

property run_metadata

Run metadata

property start_time

start time is the first good GPS time stamp minus the seconds to the beginning of the time series.

property station_metadata

Station metadata from nims file

to_runts()[source]

Get xarray for run

unwrap_sequence(sequence)[source]

unwrap the sequence to be sequential numbers instead of modulated by 256. sets the first number to 0

Parameters

sequence (list) – sequence of bytes numbers

Returns

unwrapped number of counts

exception mth5.io.nims.NIMSError[source]

Bases: Exception

class mth5.io.nims.NIMSHeader(fn=None)[source]

Bases: object

class to hold the NIMS header information.

A typical header looks like

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>user field>>>>>>>>>>>>>>>>>>>>>>>>>>>>
SITE NAME: Budwieser Spring
STATE/PROVINCE: CA
COUNTRY: USA
>>> The following code in double quotes is REQUIRED to start the NIMS <<
>>> The next 3 lines contain values required for processing <<<<<<<<<<<<
>>> The lines after that are optional <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"300b"  <-- 2CHAR EXPERIMENT CODE + 3 CHAR SITE CODE + RUN LETTER
1105-3; 1305-3  <-- SYSTEM BOX I.D.; MAG HEAD ID (if different)
106  0 <-- N-S Ex WIRE LENGTH (m); HEADING (deg E mag N)
109  90 <-- E-W Ey WIRE LENGTH (m); HEADING (deg E mag N)
1         <-- N ELECTRODE ID
3          <-- E ELECTRODE ID
2          <-- S ELECTRODE ID
4          <-- W ELECTRODE ID
Cu          <-- GROUND ELECTRODE INFO
GPS INFO: 01/10/19 16:16:42 1616.7000 3443.6088 115.7350 W 946.6
OPERATOR: KP
COMMENT: N/S CRS: .95/.96 DCV: 3.5 ACV:1
E/W CRS: .85/.86 DCV: 1.5 ACV: 1
Redeployed site for run b b/c possible animal disturbance
parse_header_dict(header_dict=None)[source]

parse the header dictionary into something useful

read_header(fn=None)[source]

read header information

Parameters

fn (string or pathlib.Path) – full path to file to read

Raises

mth5.io.nims.NIMSError if something is not right.

class mth5.io.nims.Response(system_id=None, **kwargs)[source]

Bases: object

class for instrument response functions.

property ex_filter
property ey_filter
get_electric_high_pass(hardware='pc')[source]

get the electric high pass filter based on the hardware

property hx_filter

HX filter

property hy_filter

HY Filter

property hz_filter
exception mth5.io.nims.ResponseError[source]

Bases: Exception

mth5.io.nims.read_nims(fn)[source]
Parameters

fn (TYPE) – DESCRIPTION

Returns

DESCRIPTION

Return type

TYPE

mth5.io.reader module

This is a utility function to get the appropriate reader for a given file type and return the appropriate object of mth5.timeseries

This setup to be like plugins but a hack cause I did not find the time to set this up properly as a true plugin.

If you are writing your own reader you need the following structure:

  • Class object that will read the given file

  • a reader function that is read_{file_type}, for instance read_nims

  • the return value is a mth5.timeseries.MTTS or

mth5.timeseries.RunTS object and any extra metadata in the form of a dictionary with keys as {level.attribute}.

rubric
class NewFile
def __init__(self, fn):

self.fn = fn

def read_header(self):

return header_information

def read_newfile(self):

ex, ey, hx, hy, hz = read_in_channels_as_MTTS return RunTS([ex, ey, hx, hy, hz])

def read_newfile(fn):

new_file_obj = NewFile(fn) run_obj = new_file_obj.read_newfile()

return run_obj, extra_metadata

Then add your reader to the reader dictionary so that those files can be read.

See also

Existing readers for some guidance.

Created on Wed Aug 26 10:32:45 2020

author

Jared Peacock

license

MIT

mth5.io.reader.get_reader(extension)[source]

get the proper reader for file extension

Parameters

extension (string) – file extension

Returns

the correct function to read the file

Return type

function

mth5.io.reader.read_file(fn, file_type=None)[source]
Parameters
  • fn (string or pathlib.Path) – full path to file

  • file_type (string) – a specific file time if the extension is ambiguous.

Returns

MT time series object

Return type

mth5.timeseries.MTTS

mth5.io.tools module

Created on Thu Aug 6 15:18:50 2020

author

Jared Peacock

license

MIT

mth5.io.usgs_ascii module

Created on Thu Aug 27 16:54:09 2020

author

Jared Peacock

license

MIT

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

Bases: object

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

Attributes

Description

SurveyID

Survey name

SiteID

Site name

RunID

Run number

SiteLatitude

Site latitude in decimal degrees WGS84

SiteLongitude

Site longitude in decimal degrees WGS84

SiteElevation

Site elevation according to national map meters

AcqStartTime

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

AcqStopTime

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

AcqSmpFreq

Sampling rate samples/second

AcqNumSmp

Number of samples

Nchan

Number of channels

CoordinateSystem

[ Geographic North | Geomagnetic North ]

ChnSettings

Channel settings, see below

MissingDataFlag

Missing data value

ChnSettings

Keys

Description

ChnNum

SiteID+channel number

ChnID

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

InstrumentID

Data logger + sensor number

Azimuth

Setup angle of componet in degrees relative to CoordinateSystem

Dipole_Length

Dipole length in meters

property AcqNumSmp
property AcqSmpFreq
property AcqStartTime
property AcqStopTime
property Nchan
property SiteElevation

get elevation from national map

property SiteID
property SiteLatitude
property SiteLongitude
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.USGSasc(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

Methods

Description

get_z3d_db

Get Pandas dataframe for schedule block

locate_mtft24_cfg_fn

Look for a mtft24.cfg file in station_dir

get_metadata_from_mtft24

Get metadata from mtft24.cfg file

get_metadata_from_survey_csv

Get metadata from survey csv file

fill_metadata

Fill Metadata container from a meta_array

read_asc_file

Read in USGS ascii file

convert_electrics

Convert electric channels to mV/km

write_asc_file

Write an USGS ascii file

write_station_info_metadata

Write metadata to a .cfg file

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()
property electric_channels
property ex
property ey
fill_metadata(meta_arr)[source]

Fill in metadata from time array made by Z3DCollection.check_time_series.

Parameters

meta_arr (np.ndarray) – structured array of metadata for the Z3D files to be combined.

property hx

HX

property hy
property hz
property magnetic_channels
read_asc_file(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

property run_xarray

Get xarray for run

write_asc_file(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

mth5.io.zen module

Zen

  • Tools for reading and writing files for Zen and processing software

  • Tools for copying data from SD cards

  • Tools for copying schedules to SD cards

Created on Tue Jun 11 10:53:23 2013 Updated August 2020 (JP)

copyright

Jared Peacock (jpeacock@usgs.gov)

license

MIT

class mth5.io.zen.Z3D(fn=None, **kwargs)[source]

Bases: object

Deals with the raw Z3D files output by zen. :param **fn**: full path to .Z3D file to be read in :type **fn**: string

Attributes

Description

Default Value

_block_len

length of data block to read in as chunks faster reading

65536

_counts_to_mv_conversion

conversion factor to convert counts to mv

9.53674316406e-10

_gps_bytes

number of bytes for a gps stamp

16

_gps_dtype

data type for a gps stamp

see below

_gps_epoch

starting date of GPS time format is a tuple

(1980, 1, 6, 0,

0, 0, -1, -1, 0)

_gps_f0

first gps flag in raw binary

_gps_f1

second gps flag in raw binary

_gps_flag_0

first gps flag as an int32

2147483647

_gps_flag_1

second gps flag as an int32

-2147483648

_gps_stamp_length

bit length of gps stamp

64

_leap_seconds

leap seconds, difference between UTC time and GPS time. GPS time is ahead by this much

16

_week_len

week length in seconds

604800

df

sampling rate of the data

256

fn

Z3D file name

None

gps_flag

full gps flag

_gps_f0+_gps_f1

gps_stamps

np.ndarray of gps stamps

None

header

Z3DHeader object

Z3DHeader

metadata

Z3DMetadata

Z3DMetadata

schedule

Z3DSchedule

Z3DSchedule

time_series

np.ndarra(len_data)

None

units

units in which the data is in

counts

zen_schedule

time when zen was set to run

None

  • gps_dtype is formated as np.dtype([(‘flag0’, np.int32),

    (‘flag1’, np.int32), (‘time’, np.int32), (‘lat’, np.float64), (‘lon’, np.float64), (‘num_sat’, np.int32), (‘gps_sens’, np.int32), (‘temperature’, np.float32), (‘voltage’, np.float32), (‘num_fpga’, np.int32), (‘num_adc’, np.int32), (‘pps_count’, np.int32), (‘dac_tune’, np.int32), (‘block_len’, np.int32)])

Example
>>> import mtpy.usgs.zen as zen
>>> zt = zen.Zen3D(r"/home/mt/mt00/mt00_20150522_080000_256_EX.Z3D")
>>> zt.read_z3d()
>>> ------- Reading /home/mt/mt00/mt00_20150522_080000_256_EX.Z3D -----
    --> Reading data took: 0.322 seconds
    Scheduled time was 2015-05-22,08:00:16 (GPS time)
    1st good stamp was 2015-05-22,08:00:18 (GPS time)
    difference of 2.00 seconds
    found 6418 GPS time stamps
    found 1642752 data points
>>> zt.plot_time_series()
property azimuth

azimuth of instrument setup

property channel_metadata

Channel metadata

property channel_number
property channel_response
check_start_time()[source]

check to make sure the scheduled start time is similar to the first good gps stamp

property coil_num

coil number

property coil_response

Make the coile response into a FAP filter

property component

channel

convert_counts_to_mv(data)[source]

convert the time series from counts to millivolts

convert_gps_time()[source]

convert gps time integer to relative seconds from gps_week

convert_mv_to_counts(data)[source]

convert millivolts to counts assuming no other scaling has been applied

property counts2mv_filter

Create a counts2mv coefficient filter

property dipole_filter
property dipole_length

dipole length

property elevation

elevation in meters

property end
property filter_metadata

Filter metadata

get_UTC_date_time(gps_week, gps_time)[source]

get the actual date and time of measurement as UTC.

Parameters
  • gps_week (int) – integer value of gps_week that the data was collected

  • gps_time (int) – number of seconds from beginning of gps_week

Returns

mth5.utils.mttime.MTime

get_gps_stamp_index(ts_data, old_version=False)[source]

locate the time stamps in a given time series.

Looks for gps_flag_0 first, if the file is newer, then makes sure the next value is gps_flag_1

Returns

list of gps stamps indicies

get_gps_time(gps_int, gps_week=0)[source]

from the gps integer get the time in seconds.

Parameters
  • gps_int (int) – integer from the gps time stamp line

  • gps_week (int) – relative gps week, if the number of seconds is larger than a week then a week is subtracted from the seconds and computed from gps_week += 1

Returns

gps_time as number of seconds from the beginning of the relative gps week.

property latitude

latitude in decimal degrees

property longitude

longitude in decimal degrees

read_all_info()[source]

Read header, schedule, and metadata

read_z3d(Z3Dfn=None)[source]

read in z3d file and populate attributes accordingly

  1. Read in the entire file as chunks as np.int32.

  2. Extract the gps stamps and convert accordingly. Check to make sure gps time stamps are 1 second apart and incrementing as well as checking the number of data points between stamps is the same as the sampling rate.

  3. Converts gps_stamps[‘time’] to seconds relative to header.gps_week

    Note we skip the first two gps stamps because there is something wrong with the data there due to some type of buffering. Therefore the first GPS time is when the time series starts, so you will notice that gps_stamps[0][‘block_len’] = 0, this is because there is nothing previous to this time stamp and so the ‘block_len’ measures backwards from the corresponding time index.

  4. Put the data chunks into Pandas data frame that is indexed by time

Example

>>> from mth5.io import zen
>>> z_obj = zen.Z3D(r"home/mt_data/zen/mt001.z3d")
>>> z_obj.read_z3d()
property run_metadata

Run metadata

property sample_rate

sampling rate

property start
property station

station name

property station_metadata

station metadta

to_channelts()[source]

fill time series object

trim_data()[source]

apparently need to skip the first 2 seconds of data because of something to do with the SD buffer

This method will be deprecated after field testing

validate_gps_time()[source]

make sure each time stamp is 1 second apart

validate_time_blocks()[source]

validate gps time stamps and make sure each block is the proper length

property zen_response
property zen_schedule

zen schedule data and time

class mth5.io.zen.Z3DHeader(fn=None, fid=None, **kwargs)[source]

Bases: object

Read in the header information of a Z3D file and make each metadata entry an attirbute.

Parameters
  • fn (string or pathlib.Path) – full path to Z3D file

  • fid (file) – file object ex. open(Z3Dfile, ‘rb’)

Attributes

Definition

_header_len

lenght of header in bits (512)

ad_gain

gain of channel

ad_rate

sampling rate in Hz

alt

altitude of the station (not reliable)

attenchannelsmask

not sure

box_number

ZEN box number

box_serial

ZEN box serial number

channel

channel number of the file

channelserial

serial number of the channel board

duty

duty cycle of the transmitter

fpga_buildnum

build number of one of the boards

gpsweek

GPS week

header_str

full header string

lat

latitude of station

logterminal

not sure

long

longitude of the station

main_hex_buildnum

build number of the ZEN box in hexidecimal

numsats

number of gps satelites

period

period of the transmitter

tx_duty

transmitter duty cycle

tx_freq

transmitter frequency

version

version of the firmware

Example
>>> import mtpy.usgs.zen as zen
>>> Z3Dfn = r"/home/mt/mt01/mt01_20150522_080000_256_EX.Z3D"
>>> header_obj = zen.Z3DHeader()
>>> header_obj.read_header()
convert_value(key_string, value_string)[source]

convert the value to the appropriate units given the key

property data_logger

Data logger name as ZEN{box_number}

read_header(fn=None, fid=None)[source]

Read the header information into appropriate attributes

Parameters
  • fn (string or pathlib.Path) – full path to Z3D file

  • fid (file) – file object ex. open(Z3Dfile, ‘rb’)

Example

>>> import mtpy.usgs.zen as zen
>>> Z3Dfn = r"/home/mt/mt01/mt01_20150522_080000_256_EX.Z3D"
>>> header_obj = zen.Z3DHeader()
>>> header_obj.read_header()
class mth5.io.zen.Z3DMetadata(fn=None, fid=None, **kwargs)[source]

Bases: object

Will read in the metadata information of a Z3D file and make each metadata entry an attirbute.The attributes are left in capitalization of the Z3D file.

Parameters
  • fn (string or pathlib.Path) – full path to Z3D file

  • fid (file) – file object ex. open(Z3Dfile, ‘rb’)

Attributes

Definition

_header_length

length of header in bits (512)

_metadata_length

length of metadata blocks (512)

_schedule_metadata_len

length of schedule meta data (512)

board_cal

board calibration np.ndarray()

cal_ant

antenna calibration

cal_board

board calibration

cal_ver

calibration version

ch_azimuth

channel azimuth

ch_cmp

channel component

ch_length

channel length (or # of coil)

ch_number

channel number on the ZEN board

ch_xyz1

channel xyz location (not sure)

ch_xyz2

channel xyz location (not sure)

coil_cal

coil calibration np.ndarray (freq, amp, phase)

fid

file object

find_metadata

boolean of finding metadata

fn

full path to Z3D file

gdp_operator

operater of the survey

gdp_progver

program version

job_by

job preformed by

job_for

job for

job_name

job name

job_number

job number

m_tell

location in the file where the last metadata block was found.

rx_aspace

electrode spacing

rx_sspace

not sure

rx_xazimuth

x azimuth of electrode

rx_xyz0

not sure

rx_yazimuth

y azimuth of electrode

survey_type

type of survey

unit_length

length units (m)

Example
>>> import mtpy.usgs.zen as zen
>>> Z3Dfn = r"/home/mt/mt01/mt01_20150522_080000_256_EX.Z3D"
>>> header_obj = zen.Z3DMetadata()
>>> header_obj.read_metadata()
read_metadata(fn=None, fid=None)[source]

read meta data

Parameters
  • fn (string) – full path to file, optional if already initialized.

  • fid (file) – open file object, optional if already initialized.

class mth5.io.zen.Z3DSchedule(fn=None, fid=None, **kwargs)[source]

Bases: object

Will read in the schedule information of a Z3D file and make each metadata entry an attirbute. The attributes are left in capitalization of the Z3D file.

Parameters
  • fn (string or pathlib.Path) – full path to Z3D file

  • fid (file) – file object ex. open(Z3Dfile, ‘rb’)

Attributes

Definition

AutoGain

Auto gain for the channel

Comment

Any comments for the schedule

Date

Date of when the schedule action was started YYYY-MM-DD

Duty

Duty cycle of the transmitter

FFTStacks

FFT stacks from the transmitter

Filename

Name of the file that the ZEN gives it

Gain

Gain of the channel

Log

Log the data [ Y | N ]

NewFile

Create a new file [ Y | N ]

Period

Period of the transmitter

RadioOn

Turn on the radio [ Y | N ]

SR

Sampling Rate in Hz

SamplesPerAcq

Samples per aquisition for transmitter

Sleep

Set the box to sleep [ Y | N ]

Sync

Sync with GPS [ Y | N ]

Time

Time the schedule action started HH:MM:SS (GPS time)

_header_len

length of header in bits (512)

_schedule_metadata_len

length of schedule metadata in bits (512)

fid

file object of the file

fn

file name to read in

meta_string

string of the schedule

Example
>>> import mtpy.usgs.zen as zen
>>> Z3Dfn = r"/home/mt/mt01/mt01_20150522_080000_256_EX.Z3D"
>>> header_obj = zen.Z3DSchedule()
>>> header_obj.read_schedule()
read_schedule(fn=None, fid=None)[source]

read meta data string

exception mth5.io.zen.ZenGPSError[source]

Bases: Exception

error for gps timing

exception mth5.io.zen.ZenInputFileError[source]

Bases: Exception

error for input files

exception mth5.io.zen.ZenSamplingRateError[source]

Bases: Exception

error for different sampling rates

mth5.io.zen.read_z3d(fn, logger_file_handler=None)[source]

generic tool to read z3d file

Module contents