Get km3compass ready to take over legacy code for compass calibration
Context
The last version of the CLB firmware is making the old compass calibration obsolete. Instead of updating it, it was decided to move the calibration with ellipsoid fit to km3compass, and enrich it with a new reader for the new data format.
To do:
-
Implement ellipsoid fit -
Export calibration to DB-compatible format -
Create a new reader for the up-coming new data format. -
Interface with the calibration environment
Implement ellipsoid fit
This commit integrate the possibility to do such a fit. It currently reads the data from the CSK data reader, but it could be any reader. The code for the fit can be found here: https://git.km3net.de/km3py/km3compass/-/blob/master/km3compass/calibration.py#L454 The code for the new calibration module can be found here: https://git.km3net.de/km3py/km3compass/-/blob/master/km3compass/calibration.py#L535
It was tested on a CSK file from Athens, taken for the calibration of compass 1101.
**Click here for details**
The test script used:
import km3compass as kc
# Print calibration from DB
db = kc.calibration_DB_agent()
print (db.get_calibration(1101))
reader = kc.readerCSK('tests/compass_3_1101_calibration.csk')
cal = kc.calibration_ellipsoid_fit(reader)
# Print calibration computed by km3compass
print (cal.calibration)
Which returns:
(venv) vpestel@vpestel-X1:~/Private/KM3NeT/Software/km3compass/km3compass$ python test.py
Starting a new calibration DB agent ...
Done in 7 seconds
----------------------------------------
Calibration for compass 1101
Type: "AHRS-CALIBRATION-v3", source: "DB"
A norm = 1.0
A xyz offsets = [ 0.0023622 -0.015801 -0.0069458]
A rotation matrix =
[[ 0.99822 -0.0094079 -0.0014184]
[-0.0094079 1.0082 -0.0055327]
[-0.0014184 -0.0055327 0.99379 ]]
H norm = 1.0
H xyz offsets = [-0.020015 -0.013085 0.046885]
H rotation matrix =
[[ 0.96773 0.011653 -0.0039455]
[ 0.011653 1.0157 -0.010991 ]
[-0.0039455 -0.010991 1.0177 ]]
----------------------------------------
File loaded, 3141 rows
1 module(s)
- 817320249
Number of measurements after removing duplicates : 315
----------------------------------------
Calibration for compass 1101
Type: "AHRS-CALIBRATION-v3", source: "km3compass-0.2.1.dev0+g7726b08.d20220216"
A norm = 1.0093407387084277
A xyz offsets = [ 0.00236272 -0.01580294 -0.0069185 ]
A rotation matrix =
[[ 0.99821321 -0.0093684 -0.00139031]
[-0.0093684 1.00815135 -0.00553579]
[-0.00139031 -0.00553579 0.99380922]]
H norm = 0.4716959487262093
H xyz offsets = [-0.02002571 -0.01306807 0.04686185]
H rotation matrix =
[[ 0.96772421 0.01165101 -0.00396049]
[ 0.01165101 1.01567039 -0.01098966]
[-0.00396049 -0.01098966 1.0176837 ]]
----------------------------------------
The fields 4 fields that should be compared are A offset and rotation matrix, as well as H offset and rotation matrix. As you can see the agreement is quite good, with no difference large than 0.4% except for one element: the element [0,2] of the rotation matrix for the acceleration rotation matrix, for which the difference is 2%. I think it's ok, but opinion are welcome !
Export calibration file
If I remember well, a text file (xml ?) is used to upload the calibration to the km3net DB. Currently, the result of the fit are stored in a kc.calibration_object
class. My idea is to implement a function to export this class directly in the proper format. Then, this interface could also be used if we develop new calibration method (e.g. sea-data based calibration).
Is there a document about the expected format by the DB for such a calibration file ?
Implement a reader for the new data-format.
It is still not clear to me how will be taken the data with the new firmware, as well as how the data would be stored. Would it be possible to have a reference ? or at least an example ?
Interface with the calibration environment
The procedure around the calibration procedure is not limited to the reading data and extracting a calibration. I'm considering a small command line tool that take the file and produce a db-ready file, but maybe I'm on a wrong way. @cbozza you're feedback could be useful in this context.
@cbozza and @dsamtleben I think you are the relevant person for this issue !