resistics.calibrate.io module

class resistics.calibrate.io.CalibrationIO(datafile: str = '', fileformat: str = 'induction', chopper: bool = False, extend: bool = True)[source]

Bases: resistics.common.base.ResisticsBase

Class for reading and writing calibration files

Calibration files hold impulse response data for instruments and sensors that needs to be removed from time series data.

Calibration data is stored in: project -> calData

Attributes
datafilestr

Path to calibration data file

fileformatstr

The file format of the calibration file

chopperbool

Boolean flag for reading chopper on or off or writing chopper on or off

extendbool

Boolean flag for extending (extrapolating) the calibration data

Methods

__init__(datapath, fileformat, chopper, extend)

Initialise the CalibrationIO object.

refresh(datapath, fileformat, chopper, extend)

Refresh the CalibrationIO parameters

read()

Read calibration file

readInductionData()

Read internal format calibration file for induction coils

readMetronixData()

Read metronix style calibration file for induction coils

readRSPData()

Read RSP style calibration file for induction coils

readRSPXData()

Read RSPX style calibration file for induction coils

readInternalFormat()

Read internal format calibration file

unitCalibration()

A unit calibration, used if nothing else is found

sortCalData(data)

Sort calibration data into ascending order (lower to higher)

extendCalData(data)

Extrapolate the calibration data to higher and lower frequencies

linesToArray(dataLines)

Convert a set of data lines in a calibration file into a list

writeInternalFormat()

Write internal format calibration file

writeInternalTemplate()

Write a template file for internal calibration format

printList()

Class status returned as list of strings

extendCalData(self, data: numpy.ndarray) → numpy.ndarray[source]

Extend calibration data by frequency

Add extra points at the start and end of the calibration data to ensure complete coverage with the time data.

Parameters
datanp.ndarray

Calibration data

Returns
datanp.ndarray

Extended calibration data

Notes

It is assumed that the calibration data is already sorted in ascending order (using sortCalData)

linesToArray(self, dataLines: List) → numpy.ndarray[source]

Convert data lines from a file to an array

Parameters
dataLineslist

Data lines read in from a file

Returns
datanp.ndarray

Data lines converted to a float array

printList(self) → List[str][source]

Class information as a list of strings

Returns
outList[str]

List of strings with information

read(self) → resistics.calibrate.data.CalibrationData[source]

Read data from calibration file and return CalibrationData object

Returns
CalibrationData

A calibration data object

Notes

Data for magnetic channel calibration is returned with units: F [Hz], Magnitude [mV/nT], Phase [radians]

readInductionData(self)[source]

Read data from a text based calibration file for induction coils

Text based calibration files should be used when reading of other formats appears to be failing or are not supported.

Returns
CalibrationData

A calibration data object

Notes

Data in file is assumed to be in units: F [Hz], Magnitude [mv/nT], Phase [degrees or radians] Data is returned with units: F [Hz], Magnitude [mV/nT], Phase [radians]

readInternalFormat(self)[source]

Read data from a text based calibration file for any type of instrument

Returns
CalibrationData

A calibration data object

Notes

Text based calibration files should be used when reading of other formats appears to be failing or are not supported. Nothing is assumed or promised about the data units.

readMetronixData(self) → resistics.calibrate.data.CalibrationData[source]

Read data from metronix calibration file

Returns
CalibrationData

A calibration data object

Notes

Metronix data is in units: F [Hz], Magnitude [V/nT*Hz], Phase [deg] for both chopper on and off. Data is returned with units: F [Hz], Magnitude [mV/nT], Phase [radians].

readRSPData(self) → resistics.calibrate.data.CalibrationData[source]

Read data from a RSP calibration file

Returns
CalibrationData

A calibration data object

Notes

RSP data is in units: F [Hz], Magnitude [mv/nT], Phase [deg] Data is returned with units: F [Hz], Magnitude [mV/nT], Phase [radians]

readRSPXData(self) → resistics.calibrate.data.CalibrationData[source]

Read data from calibration file

Returns
CalibrationData

A calibration data object

Notes

RSPX data is in units: F [Hz], Magnitude [mv/nT], Phase [deg] Data is returned with units: F [Hz], Magnitude [mV/nT], Phase [radians]

refresh(self, datafile: str = '', fileformat: str = 'induction', chopper: bool = False, extend: bool = True) → None[source]

Refresh the CalibrationIO parameters

Parameters
datafilestr, optional

Path to calibration data file

formatstr, optional

Calibration file format

chopperbool

Boolean flag for reading chopper on or off data, mostly used with metronix data

extendbool

Boolean flag for extrapolating the calibration data

sortCalData(self, data: numpy.ndarray) → numpy.ndarray[source]

Sort calibration data by frequency ascending (low to high)

Parameters
datanp.ndarray

Unsorted calibration data

Returns
datanp.ndarray

Sorted calibration data

unitCalibration(self) → resistics.calibrate.data.CalibrationData[source]

Return a unit calibration

Returns
CalibrationData

A calibration data object

writeInternalFormat(self, calData: resistics.calibrate.data.CalibrationData, filepath: str) → None[source]

Write out a calibration data file

Parameters
calibrationDataCalibrationData

Calibration data to write out

filepathstr

The file to write out to

writeInternalTemplate(self, filepath: str, serial: int = 1, sensor: str = '', staticgain: float = 1.0, chopper: bool = False, magnitudeUnit: str = 'mV/nT', phaseUnit: str = 'degrees') → None[source]

Write out a calibration data template file

This make it easier for the creation of a custom calibration file

Parameters
filepathstr

The file to write out to

serialint, optional

The serial number of the sensor/instrument

sensorstr, optional

The sensor type

staticgainfloat, optional

The static gain

chopperbool, optional

The chopper on or off

magnitudeUnitstr, optional

The units of the magnitude. This should be mV/nT because that is what the internal format expects

phaseUnitstr, optional

Can be either degrees or radians