Calibration data TXTΒΆ

An alternative to JSON calibration files is to use text/ASCII calibration files.

from pathlib import Path
import plotly
from resistics.time import ChanMetadata
from resistics.calibrate import SensorCalibrationTXT

Define the calibration data path. This is dependent on where the data is stored.

cal_data_path = Path("..", "..", "data", "calibration", "example.txt")

Inspect the contents of the calibration file

with cal_data_path.open("r") as f:
    for line_number, line in enumerate(f):
        print(line.strip("\n"))

Out:

Serial = 710
Sensor = LEMI120
Static gain = 1
Magnitude unit = mV/nT
Phase unit = degrees
Chopper = False

CALIBRATION DATA
1.1000E-4       1.000E-2        9.0000E1
1.1000E-3       1.000E-1        9.0000E1
1.1000E-2       1.000E0 8.9000E1
2.1000E-2       1.903E0 8.8583E1
3.1770E-2       2.903E0 8.8398E1
4.8062E-2       4.339E0 8.7489E1
7.2711E-2       6.565E0 8.6253E1
1.1000E-1       9.935E0 8.4364E1
1.3249E-1       1.202E1 8.3032E1
1.5959E-1       1.420E1 8.1578E1
1.9222E-1       1.724E1 8.0381E1
2.3153E-1       2.082E1 7.9044E1
2.7888E-1       2.453E1 7.6955E1
3.3590E-1       2.938E1 7.3175E1
4.0459E-1       3.421E1 7.0346E1
4.8733E-1       4.030E1 6.7041E1
5.8698E-1       4.734E1 6.2506E1
7.0702E-1       5.380E1 5.7801E1
8.5160E-1       6.110E1 5.2954E1
1.0257E0        6.805E1 4.7386E1
1.2355E0        7.500E1 4.1797E1
1.4881E0        8.045E1 3.6603E1
1.7925E0        8.540E1 3.1502E1
2.1590E0        8.925E1 2.6911E1
2.6005E0        9.220E1 2.2498E1
3.1323E0        9.440E1 1.8774E1
3.7728E0        9.620E1 1.5484E1
4.5443E0        9.730E1 1.2583E1
5.4736E0        9.810E1 1.0037E1
6.5929E0        9.865E1 7.8068E0
7.9411E0        9.905E1 5.7939E0
9.5649E0        9.935E1 3.9930E0
1.1521E1        9.975E1 2.3537E0
1.3877E1        9.975E1 7.6586E-1
1.6715E1        9.980E1 -8.7257E-1
2.0132E1        9.995E1 -2.4134E0
2.4249E1        9.995E1 -4.0900E0
2.9208E1        9.995E1 -5.9028E0
3.5181E1        1.000E2 -7.9286E0
4.2375E1        1.000E2 -1.0200E1
5.1041E1        1.002E2 -1.2555E1
6.1478E1        1.000E2 -1.6002E1
7.4050E1        1.000E2 -1.9709E1
8.9192E1        1.000E2 -2.4067E1
1.0743E2        9.980E1 -2.9307E1
1.2940E2        9.980E1 -3.5510E1
1.5586E2        9.970E1 -4.3008E1
1.8773E2        9.960E1 -5.2089E1
2.2612E2        9.930E1 -6.3076E1
2.7236E2        9.880E1 -7.6417E1
3.2806E2        9.800E1 -9.2605E1
3.9514E2        9.600E1 -1.1256E2
4.7595E2        9.270E1 -1.3661E2
5.7328E2        8.755E1 -1.6562E2
6.9050E2        8.080E1 1.5955E2
8.3171E2        7.450E1 1.1636E2
1.0018E3        7.070E1 5.1417E1

Read the data using the appropriate calibration data reader. As calibration data can be dependent on certain sensor parameters, channel metadata needs to be passed to the method.

chan_metadata = ChanMetadata(name="Hx", chan_type="magnetic", data_files=[])
cal_data = SensorCalibrationTXT().read_calibration_data(cal_data_path, chan_metadata)

Plot the calibration data.

fig = cal_data.plot(color="green")
fig.update_layout(height=700)
plotly.io.show(fig)

Total running time of the script: ( 0 minutes 0.226 seconds)

Gallery generated by Sphinx-Gallery