mth5.io.usgs_ascii.usgs_ascii_collection

Collection of TXT files combined into runs

Created on Wed Aug 31 10:32:44 2022

@author: jpeacock

Classes

USGSasciiCollection

Collection of USGS ASCII files.

Module Contents

class mth5.io.usgs_ascii.usgs_ascii_collection.USGSasciiCollection(file_path=None, **kwargs)[source]

Bases: mth5.io.collection.Collection

Collection of USGS ASCII files.

>>> from mth5.io.usgs_ascii import USGSasciiCollection
>>> lc = USGSasciiCollection(r"/path/to/ascii/files")
>>> run_dict = lc.get_runs(1)
file_ext = 'asc'[source]
to_dataframe(sample_rates=[4], run_name_zeros=4, calibration_path=None)[source]

Create a data frame of each TXT file in a given directory.

Note

If a run name is already present it will not be overwritten

Parameters:
  • sample_rates (int or list, optional) – sample rate to get, defaults to [4]

  • run_name_zeros (int, optional) – number of zeros to assing to the run name, defaults to 4

  • calibration_path (string or Path, optional) – path to calibration files, defaults to None

Returns:

Dataframe with information of each TXT file in the given directory.

Return type:

pandas.DataFrame

Example:
>>> from mth5.io.usgs_ascii import USGSasciiCollection
>>> lc = USGSasciiCollection("/path/to/ascii/files")
>>> ascii_df = lc.to_dataframe()
assign_run_names(df, zeros=4)[source]

Assign run names based on start and end times, checks if a file has the same start time as the last end time.

Run names are assigned as sr{sample_rate}_{run_number:0{zeros}}. Only if the run name is not assigned already.

Parameters:
  • df (pandas.DataFrame) – Dataframe with the appropriate columns

  • zeros (int, optional) – number of zeros in run name, defaults to 4

Returns:

Dataframe with run names

Return type:

pandas.DataFrame