mth5.io.lemi
Submodules
Classes
Read and process LEMI424 magnetotelluric data files. |
Functions
|
Read a LEMI 424 TXT file. |
Package Contents
- class mth5.io.lemi.LEMI424(fn: str | pathlib.Path | None = None, **kwargs: Any)[source]
Read and process LEMI424 magnetotelluric data files.
This is a placeholder until IRIS finalizes their reader.
- Parameters:
fn (str or pathlib.Path, optional) – Full path to LEMI424 file, by default None.
**kwargs (dict) – Additional keyword arguments for configuration.
- sample_rate
Sample rate of the file, default is 1.0.
- Type:
float
- chunk_size
Chunk size for pandas to use, default is 8640.
- Type:
int
- file_column_names
Column names of the LEMI424 file.
- Type:
list of str
- dtypes
Data types for each column.
- Type:
dict
- data_column_names
Same as file_column_names with an added column for date.
- Type:
list of str
- data
The loaded data.
- Type:
pd.DataFrame or None
Notes
- LEMI424 File Column Names:
year, month, day, hour, minute, second, bx, by, bz, temperature_e, temperature_h, e1, e2, e3, e4, battery, elevation, latitude, lat_hemisphere, longitude, lon_hemisphere, n_satellites, gps_fix, time_diff
- Data Column Names:
date, bx, by, bz, temperature_e, temperature_h, e1, e2, e3, e4, battery, elevation, latitude, lat_hemisphere, longitude, lon_hemisphere, n_satellites, gps_fix, time_diff
- logger
- property fn: pathlib.Path | None
Full path to LEMI424 file.
- Returns:
Path to the file or None if not set.
- Return type:
pathlib.Path or None
- sample_rate = 1.0
- chunk_size = 8640
- property data: pandas.DataFrame | None
Data represented as a pandas DataFrame with data column names.
- Returns:
The loaded data or None if no data is loaded.
- Return type:
pd.DataFrame or None
- file_column_names = ['year', 'month', 'day', 'hour', 'minute', 'second', 'bx', 'by', 'bz', 'temperature_e',...
- dtypes
- data_column_names = ['date', 'bx', 'by', 'bz', 'temperature_e', 'temperature_h', 'e1', 'e2', 'e3', 'e4', 'battery',...
- property file_size: int | None
Size of file in bytes.
- Returns:
File size in bytes or None if no file is set.
- Return type:
int or None
- property start: mt_metadata.common.mttime.MTime | None
Start time of data collection in the LEMI424 file.
- Returns:
Start time or None if no data is loaded.
- Return type:
MTime or None
- property end: mt_metadata.common.mttime.MTime | None
End time of data collection in the LEMI424 file.
- Returns:
End time or None if no data is loaded.
- Return type:
MTime or None
- property latitude: float | None
Median latitude where data have been collected.
- Returns:
Median latitude in degrees or None if no data is loaded.
- Return type:
float or None
- property longitude: float | None
Median longitude where data have been collected.
- Returns:
Median longitude in degrees or None if no data is loaded.
- Return type:
float or None
- property elevation: float | None
Median elevation where data have been collected.
- Returns:
Median elevation in meters or None if no data is loaded.
- Return type:
float or None
- property n_samples: int | None
Number of samples in the file.
- Returns:
Number of samples or None if no data/file available.
- Return type:
int or None
- property gps_lock: Any | None
GPS lock status array.
- Returns:
GPS fix values or None if no data is loaded.
- Return type:
numpy.ndarray or None
- property station_metadata: mt_metadata.timeseries.Station
Station metadata as mt_metadata.timeseries.Station object.
- Returns:
Station metadata object.
- Return type:
mt_metadata.timeseries.Station
- property run_metadata: mt_metadata.timeseries.Run
Run metadata as mt_metadata.timeseries.Run object.
- Returns:
Run metadata object.
- Return type:
mt_metadata.timeseries.Run
- read(fn: str | pathlib.Path | None = None, fast: bool = True) None[source]
Read a LEMI424 file using pandas.
The fast way will read in the first and last line to get the start and end time to make a time index. Then it will read in the data skipping parsing the date time columns. It will check to make sure the expected amount of points are correct. If not then it will read in the slower way which uses the date time parser to ensure any time gaps are respected.
- Parameters:
fn (str, pathlib.Path, or None, optional) – Full path to file. Uses LEMI424.fn if not provided, by default None.
fast (bool, optional) – Read the fast way (True) or not (False), by default True.
- Raises:
IOError – If file cannot be found.
- read_metadata() None[source]
Read only first and last rows to get important metadata.
This method is used to extract essential metadata from the collection without loading the entire dataset.
- read_calibration(fn: str | pathlib.Path) mt_metadata.timeseries.filters.FrequencyResponseTableFilter[source]
Read a LEMI424 calibration file.
Calibration files are assumed to be JSON files with the following format: {
- “Calibration”: {
“gain”: float, “Freq”: [float], “Re”: [float], “Im”: [float]
}
}
- Parameters:
fn (str or pathlib.Path) – Full path to calibration file.
- Returns:
Calibration filter object.
- Return type:
mt_metadata.timeseries.filters.FrequencyResponseTableFilter
- to_run_ts(fn: str | pathlib.Path | None = None, e_channels: list[str] = ['e1', 'e2'], calibration_dict: dict | None = None) mth5.timeseries.RunTS[source]
Create a RunTS object from the data.
- Parameters:
fn (str, pathlib.Path, or None, optional) – Full path to file. Will use LEMI424.fn if None, by default None.
e_channels (list of str, optional) – Column names for the electric channels to use, by default [“e1”, “e2”].
calibration_dict (dict, optional) – Calibration dictionary to apply to the data, by default {}. Keys are the channel names and values are the calibration file path. The file path is assumed to be in the format lemi-{component}.sr.json.
- Returns:
RunTS object containing the data.
- Return type:
- mth5.io.lemi.read_lemi424(fn: str | pathlib.Path | list[str | pathlib.Path], e_channels: list[str] = ['e1', 'e2'], fast: bool = True, calibration_dict: dict | None = None) mth5.timeseries.RunTS[source]
Read a LEMI 424 TXT file.
- Parameters:
fn (str or pathlib.Path) – Input file name.
e_channels (list of str, optional) – A list of electric channels to read, by default [“e1”, “e2”].
fast (bool, optional) – Use fast reading method, by default True.
calibration_dict (dict, optional) – Calibration dictionary to apply to the data, by default None. Keys are the channel names and values are the calibration file path.
- Returns:
A RunTS object with appropriate metadata.
- Return type: