resistics_readers.lemi.b423e module

Module for Lemi B423E data Lemi B423E always records channels in the following order

  • E1, E2, E3, E4

The Lemi B423E binary files are constructed from a 1024 text header followed by repeating records with the following definitions (PPS is short for deviation from PPS and PLL is short for PLL accuracy):

SECOND_TIMESTAMP, SAMPLE_NUM [0-FS], E1, E2, E3, E4, PPS, PLL

These are interpreted to have byte types

L, H, l, l, l, l, h, h

The channels labels are not that useful for magnetotelluric projects. When creating metadata it is best to map them to standard channels such as Ex or Ey

resistics_readers.lemi.b423e.make_sudbir_B423E_metadata(dir_path: pathlib.Path, fs: float, chans: Optional[List[str]] = None, dx: float = 1, dy: float = 1, folders: Optional[List[str]] = None)None[source]

Generate metadata for every subdirectory in a folder

Parameters
  • dir_path (Path) – Root directory

  • fs (float) – Sampling frequency, Hz

  • chans (Optional[List[str]], optional) – The channels, by default None

  • dx (float, optional) – Dipole distance Ex, by default 1

  • dy (float, optional) – Dipole distance Ey, by default 1

  • folders (Optional[List[str]], optional) – An optional list of subfolders, by default None. If None, all the subfolders will be processed

resistics_readers.lemi.b423e.make_B423E_metadata(dir_path: pathlib.Path, fs: float, chans: Optional[List[str]] = None, dx: float = 1, dy: float = 1)None[source]

Read a single B423E measurement directory, construct and write out metadata

Parameters
  • dir_path (Path) – Directory path

  • fs (float) – The sampling frequency, Hz

  • chans (Optional[List[str]], optional) – Optional list of chans, by default None

  • dx (float, optional) – Dipole distance Ex, by default 1

  • dy (float, optional) – Dipole distance Ey, by default 1

pydantic model resistics_readers.lemi.b423e.TimeReaderB423E[source]

Bases: resistics_readers.lemi.b423.TimeReaderB423

Data reader for Lemi B423E data

There is no separate metadata file for Lemi B423E data detailing the sampling frequency, the number of samples, the sensors etc.. Such a metadata file is a pre-requisite for resistics. There are helper methods to make one.

In situations where a Lemi B423E dataset is recorded in multiple files, it is required that the recording is continuous.

Other important notes about Lemi B423E files

  • 1024 bytes of ASCII metadata in the data file with scaling information

  • Lemi B423E raw measurement data is signed long integer format

Important points about scalings

  • Raw data is integer counts for electric channels

  • Scalings in B423E files convert electric channels to uV (microvolt)

If apply_scaling is False, data will be returned in:

  • microvolts for the electric channels

Which is equivalent to applying the scalings in the B423E headers

With apply_scaling True, the following additional scaling will be applied:

  • Electric channels converted to mV

  • Dipole length corrections are applied to electric channels

Note

For more information about Lemi B423 format, please see: http://lemisensors.com/?p=485

Show JSON schema
{
   "title": "TimeReaderB423E",
   "description": "Data reader for Lemi B423E data\n\nThere is no separate metadata file for Lemi B423E data detailing the\nsampling frequency, the number of samples, the sensors etc.. Such a\nmetadata file is a pre-requisite for resistics. There are helper methods to\nmake one.\n\nIn situations where a Lemi B423E dataset is recorded in multiple files, it\nis required that the recording is continuous.\n\nOther important notes about Lemi B423E files\n\n- 1024 bytes of ASCII metadata in the data file with scaling information\n- Lemi B423E raw measurement data is signed long integer format\n\nImportant points about scalings\n\n- Raw data is integer counts for electric channels\n- Scalings in B423E files convert electric channels to uV (microvolt)\n\nIf apply_scaling is False, data will be returned in:\n\n- microvolts for the electric channels\n\nWhich is equivalent to applying the scalings in the B423E headers\n\nWith apply_scaling True, the following additional scaling will be applied:\n\n- Electric channels converted to mV\n- Dipole length corrections are applied to electric channels\n\n.. note::\n\n    For more information about Lemi B423 format, please see:\n    http://lemisensors.com/?p=485",
   "type": "object",
   "properties": {
      "name": {
         "title": "Name",
         "type": "string"
      },
      "apply_scalings": {
         "title": "Apply Scalings",
         "default": true,
         "type": "boolean"
      },
      "extension": {
         "title": "Extension",
         "default": ".B423",
         "type": "string"
      },
      "record_bytes": {
         "title": "Record Bytes",
         "default": 26,
         "type": "integer"
      },
      "limit_chans": {
         "title": "Limit Chans",
         "type": "array",
         "items": {
            "type": "string"
         }
      }
   }
}

field record_bytes: int = 26
field limit_chans: Optional[List[str]]
read_metadata(dir_path: pathlib.Path)resistics_readers.multifile.TimeMetadataMerge[source]

Read metadata

Parameters

dir_path (Path) – The data directory

Returns

TimeMetadata with a data table

Return type

TimeMetadataMerge

Raises
  • MetadataReadError – If the number of channels is incorrect

  • TimeDataReadError – If not all data files exist

  • TimeDataReadError – If extensions do not match

read_data(dir_path: pathlib.Path, metadata: resistics.time.TimeMetadata, read_from: int, read_to: int)resistics.time.TimeData[source]

Get data from data files

Lemi B423E data always has four channels, in order E1, E2, E3, E4. When writing out the metadata, it is possible to relabel these channels, for example:

  • Ex, Ey, E3, E4

The raw data is integer counts. However, additional scalings from the B423 files are applied to give:

  • microvolts for the electric channels

  • millivolts for the magnetic with the gain applied

The scalings are as follows:

  • Channel 1 = (Channel 1 * Ke1) + Ae1

  • Channel 2 = (Channel 1 * Ke2) + Ae2

  • Channel 3 = (Channel 1 * Ke3) + Ae3

  • Channel 4 = (Channel 1 * Ke4) + Ae4

Unlike most other readers, the channels returned can be explicity selected by setting the limit_chans attribute of the class. This is because in many cases, only two of the B423Echannels are actually useful.

Parameters
  • dir_path (path) – The directory path to read from

  • metadata (TimeMetadata) – Time series data metadata

  • read_from (int) – Sample to read data from

  • read_to (int) – Sample to read data to

Returns

Time data object

Return type

TimeData

scale_data(time_data: resistics.time.TimeData)resistics.time.TimeData[source]

Get data scaled to physical values

resistics uses field units, meaning physical samples will return the following:

  • Electrical channels in mV/km

  • Magnetic channels in mV

  • To get magnetic fields in nT, calibration needs to be performed

Notes

When Lemi data is read in, scaling in the headers is applied. Therefore, the magnetic channels is in mV with gain applied and the electric channels are in uV (microvolts). To complete the scaling to field units, the below additional corrections need to be applied.

Electric channels need to divided by 1000 along with dipole length division in km (east-west spacing and north-south spacing) to return mV/km.

Magnetic channels need to be divided by the internal gain value which should be set in the metadata

Parameters

time_data (TimeData) – Input time data

Returns

Time data in field units

Return type

TimeData