How to use reader for CSK

The following example shows how to use the readerCSK class, using a acceptance tests measurement (60 seconds measurement with the DOM oriented in each of the 4 cardinal points).

from km3compass import readerCSK

Initialising a readerCSK

Initialising is a simple as this:

filename = "../tests/DOM_0801.csk"
reader = readerCSK(filename)
File loaded, 2508 rows
        1 module(s)
        - 817302522
Number of measurements after removing duplicates : 252

Access file content

File content is extracted and converted in a pandas DataFrame. You can display the content like this:

print(reader.df)
              time   AHRS_A0  ...      DOMID                datetime
0     1.624893e+09 -0.070312  ...  817302522 2021-06-28 15:13:03.400
5     1.624893e+09 -0.082031  ...  817302522 2021-06-28 15:13:03.900
15    1.624893e+09 -0.074219  ...  817302522 2021-06-28 15:13:04.900
25    1.624893e+09 -0.074219  ...  817302522 2021-06-28 15:13:05.900
35    1.624893e+09 -0.070312  ...  817302522 2021-06-28 15:13:06.900
...            ...       ...  ...        ...                     ...
2465  1.624893e+09 -0.078125  ...  817302522 2021-06-28 15:17:09.900
2475  1.624893e+09 -0.078125  ...  817302522 2021-06-28 15:17:10.900
2485  1.624893e+09 -0.070312  ...  817302522 2021-06-28 15:17:11.900
2495  1.624893e+09 -0.070312  ...  817302522 2021-06-28 15:17:12.900
2505  1.624893e+09 -0.070312  ...  817302522 2021-06-28 15:17:13.900

[252 rows x 11 columns]

To get the measured magnetic field and acceleration in numpy.array format, you can do the following:

a = reader.df[["AHRS_A0", "AHRS_A1", "AHRS_A2"]].values
h = reader.df[["AHRS_H0", "AHRS_H1", "AHRS_H2"]].values

import numpy as np

print(np.shape(a), np.shape(h))
(252, 3) (252, 3)

Draw a simple plot

The raw values can be displayed using matplolib. In this simple example, x vs y components of magnetic field are plotted. The aspect of x and y are set to equal, to get a better representation of the cartesian space.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ax.scatter(reader.df["AHRS_H0"], reader.df["AHRS_H1"])

ax.set_aspect("equal")

ax.set_xlabel("X [G]")
ax.set_ylabel("Y [G]")
ax.grid()
plt.show()
plot readerCSK

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

Gallery generated by Sphinx-Gallery