Advanced usage of sea data

import km3compass as kc
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

Initialising a readerOnline

Downloading run 9000 from ORCA6. This run is 10 minutes long, perfect for an example !

reader = kc.readerOnline("D_ORCA006", minrun=9000, maxrun=9000)
Loading data from DB ...
        detoid = D_ORCA006
        minrun = 9000
        maxrun = 9000
        Getting run 9000... - Done in 1 seconds

Calibrate data

The calibration module is made to calibrate only one DOM. Therefore, we need to loop over the available module and calibrate them independantly. To limit the number of DB request, a db_agent is created beforehand. It will copy locally the tables needed from the DB, removing the need to contact the DB later.

df_calib = None
df_ahrscalibtable = None

db_agent = kc.calibration_DB_agent()

for modID in reader.module_IDs:
    try:
        calib = kc.calib_DB(reader, modID, db_agent=db_agent, verbosity=False)
        df_calib = pd.concat((df_calib, calib.df))
    except:
        print("failed for : {}".format(modID))
No calibration expected, 808469948 is a base module.
No calibration expected, 808476701 is a base module.
Impossible to find calibration:
        DOM mac address = 08:00:30:30:90:36
        CLB UPI = 3.4.3.2/V2-2-1/2.452
        Compass SN = 452
No calibration expected, 808967761 is a base module.
No calibration expected, 808981515 is a base module.
No calibration expected, 808981528 is a base module.
Impossible to find calibration:
        DOM mac address = 08:00:30:38:16:02
        CLB UPI = 3.4.3.2/V2-2-1/2.558
        Compass SN = 558
Impossible to find compass:
        DOM mac address = 08:00:30:b2:1a:8b
        CLB UPI = 3.4.3.2/V2-2-1/2.646
No calibration expected, 816978571 is a base module.

Plot before and after per DU

Now we can do a quick before/after calibration plot, DU per DU. In this example, the break limit the display to the first line, already enough for the example.

for duid in np.unique(reader.df.DUID):
    before_calib = reader.df[reader.df["DUID"] == duid]
    after_calib = df_calib[df_calib["DUID"] == duid]

    print("DU {}".format(duid))
    print(
        "\tDOMs before calibration : {}".format(len(np.unique(before_calib["DOMID"])))
    )
    print("\tDOMs after calibration : {}".format(len(np.unique(after_calib["DOMID"]))))

    # In order to display the 0, cheating a bit and adding a measurement in (0,0,0)

    zero = pd.DataFrame(
        {
            "datetime": [before_calib["datetime"].min()],
            "AHRS_H0": [0],
            "AHRS_H1": [0],
            "AHRS_H2": [0],
            "DOMID": [0],
        }
    )
    after_calib = pd.concat((after_calib, zero))
    kc.plot_raw_results(before_calib, title="DU {}, Before calibration".format(duid))

    kc.plot_raw_results(after_calib, title="DU {}, After calibration".format(duid))
    break

plt.show()
  • DU 1, Before calibration
  • DU 1, After calibration
DU 1
        DOMs before calibration : 17
        DOMs after calibration : 17

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

Gallery generated by Sphinx-Gallery