Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
local2eq_aanet_2.7.1.py
Go to the documentation of this file.
1"""
2This script is used to generate the local2eq*.csv files.
3"""
4import ctypes
5import datetime
6import numpy as np
7import pandas as pd
8from km3net_testdata import data_path
9
10import aa, ROOT
11from ROOT import EventFile, EquatorialCoords, Det, Vec
12
13def main():
14 timespan = 3*60*60*24 # [s]
15 n_datapoints = 20
16 times = np.linspace(0, timespan, n_datapoints, dtype=int)
17 d = ROOT.Det(data_path("detx/KM3NeT_00000133_20221025.detx"))
18
19 outfile = open("local2eq_aanet_2.7.1.csv", "w")
20 outfile.write("dx,dy,dz,")
21 outfile.write("phi,theta,")
22 outfile.write("utm_easting,utm_northing,utm_z,utm_zone,utm_reference_elipsoid,")
23 outfile.write("det_latitude,det_longitude,meridian_convergence,")
24 outfile.write("year,month,day,hour,min,sec,")
25 outfile.write("eq_ra,eq_dec,gal_lon,gal_lat,")
26 outfile.write("j2000\n")
27
28 t_year = ctypes.c_uint()
29 t_month = ctypes.c_uint()
30 t_day = ctypes.c_uint()
31 t_hour = ctypes.c_uint()
32 t_minute = ctypes.c_uint()
33 t_sec = ctypes.c_uint()
34
35 month = 1
36 day = 1
37 hour = 12
38 min = 0
39 sec = 0
40
41 for v in [Vec(0, 0, -1), Vec(0, 1, 0), Vec(1, 0, 0), Vec(-1.2, 3.4, -5.6).normalize()]:
42 for year in [2000, 2010, 2025]:
43 starttime = datetime.datetime(year, month, day, hour, min, sec).replace(tzinfo=datetime.timezone.utc).timestamp()
44 for j2000 in (True, False):
45 for t in times:
46 timestamp = ROOT.TTimeStamp(int(starttime+t))
47 timestamp.GetDate(True, 0, t_year, t_month, t_day)
48 timestamp.GetTime(True, 0, t_hour, t_minute, t_sec)
49
50 coords = EquatorialCoords(d, v, timestamp, j2000)
51 gal = ROOT.sla.eqgal(coords.ra(), coords.dec())
52
53 outfile.write(f"{v.x},{v.y},{v.z},")
54 outfile.write(f"{v.phi()},{v.theta()},")
55 outfile.write(f"{d.utm_ref_easting},{d.utm_ref_northing},{d.utm_ref_z},{d.utm_zone},{d.utm_reference_elipsoid},")
56 outfile.write(f"{d.latitude},{d.longitude},{d.meridian_convergence_angle},")
57 outfile.write(f"{t_year.value},{t_month.value},{t_day.value},{t_hour.value},{t_minute.value},{t_sec.value},")
58 # we wrap the right ascension (to [0, 2pi)) due to a tiny bug in aanet that was fixed in
59 # https://git.km3net.de/common/aanet/-/merge_requests/161
60 outfile.write(f"{ROOT.wrap(coords.ra())},{coords.dec()},{gal.DL},{gal.DB},")
61 outfile.write(f"{j2000}\n")
62
63 outfile.close()
64
65if __name__ == "__main__":
66 main()
TString replace(const TString &target, const TRegexp &regexp, const T &replacement)
Replace regular expression in input by given replacement.