From 22ad490aa53056f950155a602fbc5fc872753f08 Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Tue, 16 Jul 2024 06:42:07 -0400 Subject: [PATCH 1/9] Note: Squashed a bunch of commits and cleaned up commit history message Explicit int conversion removed MAXI_UNKNOWN conversion Removed GECAM_FLT and GECAM_GND conversion Added documentation and changed function name reformatted file deleted files --- .../notices/CALET_GBM_FLT_LC/__init__.py | 51 +++++++++++++++++++ .../notices/CALET_GBM_FLT_LC/example.json | 28 ++++++++++ .../notices/SWIFT_BAT_GRB_POS_ACK/__init__.py | 12 +---- .../SWIFT_BAT_GRB_POS_ACK/example.json | 2 +- gcn_classic_to_json/utils.py | 28 ++++++++++ 5 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py create mode 100644 gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json create mode 100644 gcn_classic_to_json/utils.py diff --git a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py new file mode 100644 index 0000000..f7445f2 --- /dev/null +++ b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py @@ -0,0 +1,51 @@ +import numpy as np + +from ... import utils + + +def parse(bin): + if (bin[0] != 160) and (bin[39] != 10): + return + + if np.all(bin[1:4]) and bin[12] and np.all(bin[13:16]) and np.all(bin[20:29]): + pass + + lat, lon = bin[16:17].view(">i2") + + trig_id_bits = np.flip(np.unpackbits(bin[18:19].view(dtype="u1"))) + trig_id_descriptions = { + 5: "This is not a real event.\n", + 29: "There was a temporal coincidence with another event.\n", + 30: "This is a test submission.\n", + } + comments = "".join( + [val for (key, val) in trig_id_descriptions.items() if trig_id_bits[key] == 1] + ) + + detector_options = ["on", "triggered"] + detectors_bits = np.flip(np.unpackbits(bin[19:20].view(dtype="u1")))[:3] + detectors_status = [detector_options[bit] for bit in detectors_bits] + detectors = dict(zip(["HXM1", "HMX2", "SGM"], detectors_status)) + + return { + "mission": "CALET", + "instrument": "GBM", + # "alert_type" : "initial", # does not exist in the binaries + # "record_number" = 1, # does not exist in binaries + "id": [bin[4]], + "messenger": "EM", + "trigger_time": utils.datetime_to_iso8601(bin[5], bin[6]), + "trigger_type": "rate", + "rate_energy_range": np.flip(bin[17:18].view(">i2")), + "rate_snr": bin[9] * 1e-2, + "rate_duration": bin[10] * 1e-2, + "background_duration": bin[11] * 1e-2, + "ra": bin[7] * 1e-4, + "dec": bin[8] * 1e-4, + "latitude": lat * 1e-2, + "longitude": lon * 1e-2, + "detector_status": detectors, + "url": "http://cgbm.calet.jp/cgbm_trigger/flight/" + + utils.binary_to_string(bin[29:39]), + "additional_info": comments if comments else None, + } diff --git a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json new file mode 100644 index 0000000..20e08b4 --- /dev/null +++ b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json @@ -0,0 +1,28 @@ +{ + "mission": "CALET", + "instrument": "GBM", + "id": [ + 1399729386 + ], + "messenger": "EM", + "trigger_time": "2024-05-14T13:49:42.620Z", + "trigger_type": "rate", + "rate_energy_range": [ + 40, + 230 + ], + "rate_snr": 8.3, + "rate_duration": 4.0, + "background_duration": 16.0, + "ra": 193.85000000000002, + "dec": 50.359, + "latitude": 50.22, + "longitude": 113.87, + "detector_status": { + "HXM1": "on", + "HMX2": "on", + "SGM": "triggered" + }, + "url": "http://cgbm.calet.jp/cgbm_trigger/flight/index.html", + "additional_info": null +} diff --git a/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py b/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py index c63ef56..16e9129 100644 --- a/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py +++ b/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py @@ -1,17 +1,9 @@ -from astropy.time import Time - -# Zero point for Truncated Julian Day according to -# https://en.wikipedia.org/wiki/Julian_day. -TJD0 = (2440000, 0.5) +from ... import utils def parse(bin): return { - "trigger_time": Time( - bin[5] + TJD0[0], - bin[6] / 8640000 + TJD0[1], - format="jd", - ).isot, + "trigger_time": utils.tjd_to_jd(bin[5], bin[6]), "ra": 1e-4 * bin[7], "dec": 1e-4 * bin[8], "ra_dec_error": 1e-4 * bin[11], diff --git a/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json b/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json index 9202286..9421539 100644 --- a/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json +++ b/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json @@ -1,5 +1,5 @@ { - "trigger_time": "2024-05-11T18:06:53.220", + "trigger_time": "2024-05-11 18:06:53.220Z", "ra": 336.66450000000003, "dec": 8.5135, "ra_dec_error": 0.05 diff --git a/gcn_classic_to_json/utils.py b/gcn_classic_to_json/utils.py new file mode 100644 index 0000000..38c9457 --- /dev/null +++ b/gcn_classic_to_json/utils.py @@ -0,0 +1,28 @@ +from astropy.time import Time +import numpy as np + + +def datetime_to_iso8601(date, time): + """Converts time to ISO 8601 format. + + The function convert datetime into the ISO 8601 format from + Truncated Julian Date by first converting it to Julian Date. + + Parameters + ---------- + date : int + Date must be in Truncated Julian Date format. + time : int + Time of day must in Seconds of Day format. + + Returns + ------- + string + returns datetime in ISO8601 format. + + Notes + ----- + The zero point for Truncated Julian Day is given in https://en.wikipedia.org/wiki/Julian_day. + """ + TJD0 = (2440000, 0.5) + return Time(date + TJD0[0], time / 8640000 + TJD0[1], format="jd").isot + "Z" From eb667a491e9596a286a14551a2321a33107c371b Mon Sep 17 00:00:00 2001 From: Athish Thiruvengadam Date: Tue, 6 Aug 2024 14:03:55 -0400 Subject: [PATCH 2/9] reformatting --- .../notices/CALET_GBM_FLT_LC/__init__.py | 2 -- .../notices/SWIFT_BAT_GRB_POS_ACK/__init__.py | 2 +- .../SWIFT_BAT_GRB_POS_ACK/example.json | 2 +- gcn_classic_to_json/test/test_notices.py | 2 +- gcn_classic_to_json/utils.py | 31 +++++++++++++++++-- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py index f7445f2..82a8aaa 100644 --- a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py +++ b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py @@ -30,8 +30,6 @@ def parse(bin): return { "mission": "CALET", "instrument": "GBM", - # "alert_type" : "initial", # does not exist in the binaries - # "record_number" = 1, # does not exist in binaries "id": [bin[4]], "messenger": "EM", "trigger_time": utils.datetime_to_iso8601(bin[5], bin[6]), diff --git a/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py b/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py index 16e9129..a7c8b60 100644 --- a/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py +++ b/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py @@ -3,7 +3,7 @@ def parse(bin): return { - "trigger_time": utils.tjd_to_jd(bin[5], bin[6]), + "trigger_time": utils.datetime_to_iso8601(bin[5], bin[6]), "ra": 1e-4 * bin[7], "dec": 1e-4 * bin[8], "ra_dec_error": 1e-4 * bin[11], diff --git a/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json b/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json index 9421539..d493ebb 100644 --- a/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json +++ b/gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json @@ -1,5 +1,5 @@ { - "trigger_time": "2024-05-11 18:06:53.220Z", + "trigger_time": "2024-05-11T18:06:53.220Z", "ra": 336.66450000000003, "dec": 8.5135, "ra_dec_error": 0.05 diff --git a/gcn_classic_to_json/test/test_notices.py b/gcn_classic_to_json/test/test_notices.py index fb85aee..c8fa286 100644 --- a/gcn_classic_to_json/test/test_notices.py +++ b/gcn_classic_to_json/test/test_notices.py @@ -67,7 +67,7 @@ def mock_frombuffer(*args, **kwargs): if not used.all(): raise AssertionError( - f'All fields in the binary packet must be used. The fields with the following indices were unused: {' '.join(np.flatnonzero(~used).astype(str))}' + f"All fields in the binary packet must be used. The fields with the following indices were unused: {' '.join(np.flatnonzero(~used).astype(str))}" ) diff --git a/gcn_classic_to_json/utils.py b/gcn_classic_to_json/utils.py index 38c9457..362a356 100644 --- a/gcn_classic_to_json/utils.py +++ b/gcn_classic_to_json/utils.py @@ -1,11 +1,11 @@ -from astropy.time import Time import numpy as np +from astropy.time import Time def datetime_to_iso8601(date, time): """Converts time to ISO 8601 format. - The function convert datetime into the ISO 8601 format from + The function converts input into the ISO 8601 format from Truncated Julian Date by first converting it to Julian Date. Parameters @@ -26,3 +26,30 @@ def datetime_to_iso8601(date, time): """ TJD0 = (2440000, 0.5) return Time(date + TJD0[0], time / 8640000 + TJD0[1], format="jd").isot + "Z" + + +def binary_to_string(binary): + """Converts a binary array to a ASCII-string. + + The function converts each field encoded as a 4-byte integer into + four 1-byte integers and then to their corresponding ASCII value. + + Parameters + ---------- + binary : array-like + A array for binary values encoded as 4-byte integers. + + Returns + ------- + string: + returns the corresponding ASCII string. + + Notes: + ------ + The strings in the binary packets seem to encoded little-endian. + """ + bits_array = np.asarray(binary, dtype=" Date: Tue, 6 Aug 2024 17:35:30 -0400 Subject: [PATCH 3/9] Added code to ignore unused binary fields. --- .../notices/CALET_GBM_FLT_LC/__init__.py | 16 ++++++++++------ .../notices/CALET_GBM_FLT_LC/example.json | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py index 82a8aaa..5b1666d 100644 --- a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py +++ b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py @@ -4,11 +4,15 @@ def parse(bin): - if (bin[0] != 160) and (bin[39] != 10): - return - - if np.all(bin[1:4]) and bin[12] and np.all(bin[13:16]) and np.all(bin[20:29]): - pass + assert bin[12] == 0, "Unused. According to docs: 'Always 0 for FLT_LC'" + bin[ + 1 + ] # Unused. According to docs: 'serial number of the packet'. Generally set to 1. + bin[2] # Unused. According to docs: 'hopcount item is defunct'. + bin[ + 3 + ] # Unused. According to docs: 'seconds of day when packet was created'. Cannot use without date that the packet. + bin[20:29] # Unused. According to docs: '36 bytes for the future' lat, lon = bin[16:17].view(">i2") @@ -43,7 +47,7 @@ def parse(bin): "latitude": lat * 1e-2, "longitude": lon * 1e-2, "detector_status": detectors, - "url": "http://cgbm.calet.jp/cgbm_trigger/flight/" + "url": f"http://cgbm.calet.jp/cgbm_trigger/flight/{bin[4]}" + utils.binary_to_string(bin[29:39]), "additional_info": comments if comments else None, } diff --git a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json index 20e08b4..faf6ddd 100644 --- a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json +++ b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json @@ -23,6 +23,6 @@ "HMX2": "on", "SGM": "triggered" }, - "url": "http://cgbm.calet.jp/cgbm_trigger/flight/index.html", + "url": "http://cgbm.calet.jp/cgbm_trigger/flight/1399729386index.html", "additional_info": null } From 995b03ebb52b19519343f7880637311bbf4b5df9 Mon Sep 17 00:00:00 2001 From: Athish Thiruvengadam Date: Tue, 6 Aug 2024 17:46:21 -0400 Subject: [PATCH 4/9] fixed URL and refactored utils.py --- .../notices/CALET_GBM_FLT_LC/__init__.py | 11 ++++------- .../notices/CALET_GBM_FLT_LC/example.json | 2 +- gcn_classic_to_json/utils.py | 19 +++++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py index 5b1666d..5229dae 100644 --- a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py +++ b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py @@ -5,13 +5,10 @@ def parse(bin): assert bin[12] == 0, "Unused. According to docs: 'Always 0 for FLT_LC'" - bin[ - 1 - ] # Unused. According to docs: 'serial number of the packet'. Generally set to 1. + bin[1] # Unused. According to docs: 'Generally set to 1.' bin[2] # Unused. According to docs: 'hopcount item is defunct'. - bin[ - 3 - ] # Unused. According to docs: 'seconds of day when packet was created'. Cannot use without date that the packet. + bin[3] # Unused. According to docs: 'seconds of day when packet was created'. + bin[13:16] # Unused. According to docs: '12 bytes for the future' bin[20:29] # Unused. According to docs: '36 bytes for the future' lat, lon = bin[16:17].view(">i2") @@ -47,7 +44,7 @@ def parse(bin): "latitude": lat * 1e-2, "longitude": lon * 1e-2, "detector_status": detectors, - "url": f"http://cgbm.calet.jp/cgbm_trigger/flight/{bin[4]}" + "url": f"http://cgbm.calet.jp/cgbm_trigger/flight/{bin[4]}/" + utils.binary_to_string(bin[29:39]), "additional_info": comments if comments else None, } diff --git a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json index faf6ddd..2e26abf 100644 --- a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json +++ b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/example.json @@ -23,6 +23,6 @@ "HMX2": "on", "SGM": "triggered" }, - "url": "http://cgbm.calet.jp/cgbm_trigger/flight/1399729386index.html", + "url": "http://cgbm.calet.jp/cgbm_trigger/flight/1399729386/index.html", "additional_info": null } diff --git a/gcn_classic_to_json/utils.py b/gcn_classic_to_json/utils.py index 362a356..f643ed8 100644 --- a/gcn_classic_to_json/utils.py +++ b/gcn_classic_to_json/utils.py @@ -31,8 +31,9 @@ def datetime_to_iso8601(date, time): def binary_to_string(binary): """Converts a binary array to a ASCII-string. - The function converts each field encoded as a 4-byte integer into - four 1-byte integers and then to their corresponding ASCII value. + The function converts `binary` into a C-style string, + flips the position of every 4 bytes, strips excess null characters + and then converts the result into ASCII characters. Parameters ---------- @@ -46,10 +47,12 @@ def binary_to_string(binary): Notes: ------ - The strings in the binary packets seem to encoded little-endian. + The strings in the binary packets look like they were accidentally byte-swapped. """ - bits_array = np.asarray(binary, dtype=" Date: Wed, 7 Aug 2024 12:00:16 -0400 Subject: [PATCH 5/9] Moved pkt_sernum, pkt_hop_cnt and pkt_sod to notices/__init__.py --- gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py | 3 --- gcn_classic_to_json/notices/__init__.py | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py index 5229dae..a8bfd25 100644 --- a/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py +++ b/gcn_classic_to_json/notices/CALET_GBM_FLT_LC/__init__.py @@ -5,9 +5,6 @@ def parse(bin): assert bin[12] == 0, "Unused. According to docs: 'Always 0 for FLT_LC'" - bin[1] # Unused. According to docs: 'Generally set to 1.' - bin[2] # Unused. According to docs: 'hopcount item is defunct'. - bin[3] # Unused. According to docs: 'seconds of day when packet was created'. bin[13:16] # Unused. According to docs: '12 bytes for the future' bin[20:29] # Unused. According to docs: '36 bytes for the future' diff --git a/gcn_classic_to_json/notices/__init__.py b/gcn_classic_to_json/notices/__init__.py index 3185c64..a7d388b 100644 --- a/gcn_classic_to_json/notices/__init__.py +++ b/gcn_classic_to_json/notices/__init__.py @@ -20,6 +20,9 @@ def parse(key, value): ints = _frombuffer(value) assert len(ints) == 40 assert ints[0] == NoticeType[key], "Field 0 must equal the notice type" + ints[1] # Unused. According to docs: 'Generally set to 1.' + ints[2] # Unused. According to docs: 'hopcount item is defunct'. + ints[3] # Unused. According to docs: 'seconds of day when packet was created'. assert ( ints[-1] == np.asarray("\0\0\0\n", dtype="c").view(">i4")[0] ), "Field 39 must be a newline" From 471e72759f1fdeb18a6c8d8c4a5a94e919a6beee Mon Sep 17 00:00:00 2001 From: Athish Thiruvengadam Date: Wed, 14 Aug 2024 17:03:33 -0400 Subject: [PATCH 6/9] initial commit --- gcn_classic_to_json/notices/SK_SN/__init__.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 gcn_classic_to_json/notices/SK_SN/__init__.py diff --git a/gcn_classic_to_json/notices/SK_SN/__init__.py b/gcn_classic_to_json/notices/SK_SN/__init__.py new file mode 100644 index 0000000..77f391b --- /dev/null +++ b/gcn_classic_to_json/notices/SK_SN/__init__.py @@ -0,0 +1,37 @@ +import numpy as np + +from ... import utils + +# Will have to rename schema after the location is decided +# Distance is given in a range instead of a value, need to store it as Mpc, it's in kpc in file +# energy limit is only minumum; energy has to be in kev, it's in Mev in the file +# There is a duration in notices but not in the packets + + +def parse(bin_arr): + output = { + "$schema": "", + "mission": "Super-Kamiokande", + "alert_type": "initial", + "messenger": "Neutrino", + "id": [int(bin_arr[4])], + "trigger_time": utils.tjd_to_jd(bin_arr[5], bin_arr[6]), + "ra": bin_arr[7] * 1e-4, + "dec": bin_arr[8] * 1e-4, + "ra_dec_error": bin_arr[16] * 1e-4, + "containment_probability": 0.95, + # new event + "n_events": int(bin_arr[9]), + "distance_range": [bin_arr[13] * 1e-3, bin_arr[14] * 1e-3], + } + + trig_id_bits = np.flip(np.unpackbits(bin_arr[18:19].view(dtype="u1"))) + + # check if the notice is real or test + if trig_id_bits[1] == 1: + output["alert_tense"] = "test" + output["additional_info"] = "This is a test notice.\n" + else: + output["additional_info"] = "This is a real event.\n" + + return output From a585f0853552f4c7da98d6bc9bcff4b47993cc03 Mon Sep 17 00:00:00 2001 From: Athish Thiruvengadam Date: Tue, 20 Aug 2024 15:14:11 -0400 Subject: [PATCH 7/9] SK_SN binary conversion --- gcn_classic_to_json/notices/SK_SN/__init__.py | 53 +++++++++---------- .../notices/SK_SN/example.json | 23 ++++++++ 2 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 gcn_classic_to_json/notices/SK_SN/example.json diff --git a/gcn_classic_to_json/notices/SK_SN/__init__.py b/gcn_classic_to_json/notices/SK_SN/__init__.py index 77f391b..e9f7583 100644 --- a/gcn_classic_to_json/notices/SK_SN/__init__.py +++ b/gcn_classic_to_json/notices/SK_SN/__init__.py @@ -2,36 +2,35 @@ from ... import utils -# Will have to rename schema after the location is decided -# Distance is given in a range instead of a value, need to store it as Mpc, it's in kpc in file -# energy limit is only minumum; energy has to be in kev, it's in Mev in the file -# There is a duration in notices but not in the packets +def parse(bin): + bin[10] # Unused. According to Docs:'4 bytes for the future'. + bin[12] # Unused. According to Docs:'4 bytes for the future'. + bin[17] # Unused. According to Docs:'4 bytes for the future'. + bin[ + 19 + ] # Intentionally Omitted. Defined as miscellaneous bits, but does not have any information. + bin[22:39] # Unused. According to Docs:'68 bytes for the future'. -def parse(bin_arr): - output = { - "$schema": "", + trig_id_bits = np.flip(np.unpackbits(bin[18:19].view(dtype="u1"))) + + return { "mission": "Super-Kamiokande", "alert_type": "initial", + "alert_tense": "test" if trig_id_bits[1] else "current", "messenger": "Neutrino", - "id": [int(bin_arr[4])], - "trigger_time": utils.tjd_to_jd(bin_arr[5], bin_arr[6]), - "ra": bin_arr[7] * 1e-4, - "dec": bin_arr[8] * 1e-4, - "ra_dec_error": bin_arr[16] * 1e-4, - "containment_probability": 0.95, - # new event - "n_events": int(bin_arr[9]), - "distance_range": [bin_arr[13] * 1e-3, bin_arr[14] * 1e-3], + "id": [bin[4]], + "trigger_time": utils.datetime_to_iso8601(bin[5], bin[6]), + "ra": bin[7] * 1e-4, + "dec": bin[8] * 1e-4, + "ra_dec_error_68": bin[11] * 1e-4, + "ra_dec_error_90": bin[15] * 1e-4, + "ra_dec_error_95": bin[16] * 1e-4, + "n_events": bin[9], + "collection_duration": bin[21] * 1e-4, + "energy_limit": bin[20] * 1e-1, + "distance_range": [bin[13] * 1e-5, bin[14] * 1e-5], + "additional_info": ( + "This is a test notice." if trig_id_bits[1] else "This is a real notice." + ), } - - trig_id_bits = np.flip(np.unpackbits(bin_arr[18:19].view(dtype="u1"))) - - # check if the notice is real or test - if trig_id_bits[1] == 1: - output["alert_tense"] = "test" - output["additional_info"] = "This is a test notice.\n" - else: - output["additional_info"] = "This is a real event.\n" - - return output diff --git a/gcn_classic_to_json/notices/SK_SN/example.json b/gcn_classic_to_json/notices/SK_SN/example.json new file mode 100644 index 0000000..ec13170 --- /dev/null +++ b/gcn_classic_to_json/notices/SK_SN/example.json @@ -0,0 +1,23 @@ +{ + "mission": "Super-Kamiokande", + "alert_type": "initial", + "alert_tense": "test", + "messenger": "Neutrino", + "id": [ + 10063 + ], + "trigger_time": "2024-05-31T23:05:35.570Z", + "ra": 270.8199, + "dec": 31.46, + "ra_dec_error_68": 0.64, + "ra_dec_error_90": 0.91, + "ra_dec_error_95": 1.04, + "n_events": 64176, + "collection_duration": 10.0, + "energy_limit": 7000.0, + "distance_range": [ + 0.00216, + 0.0029500000000000004 + ], + "additional_info": "This is a test notice." +} From 9445f6c47f3a8c34cd6bc79072a886543a44bf5e Mon Sep 17 00:00:00 2001 From: Athish Thiruvengadam Date: Tue, 20 Aug 2024 16:00:35 -0400 Subject: [PATCH 8/9] changed ra_dec_error_90 to ra_dec_error --- gcn_classic_to_json/notices/SK_SN/__init__.py | 2 +- gcn_classic_to_json/notices/SK_SN/example.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcn_classic_to_json/notices/SK_SN/__init__.py b/gcn_classic_to_json/notices/SK_SN/__init__.py index e9f7583..06266dd 100644 --- a/gcn_classic_to_json/notices/SK_SN/__init__.py +++ b/gcn_classic_to_json/notices/SK_SN/__init__.py @@ -23,8 +23,8 @@ def parse(bin): "trigger_time": utils.datetime_to_iso8601(bin[5], bin[6]), "ra": bin[7] * 1e-4, "dec": bin[8] * 1e-4, + "ra_dec_error": bin[15] * 1e-4, "ra_dec_error_68": bin[11] * 1e-4, - "ra_dec_error_90": bin[15] * 1e-4, "ra_dec_error_95": bin[16] * 1e-4, "n_events": bin[9], "collection_duration": bin[21] * 1e-4, diff --git a/gcn_classic_to_json/notices/SK_SN/example.json b/gcn_classic_to_json/notices/SK_SN/example.json index ec13170..7b3fb3d 100644 --- a/gcn_classic_to_json/notices/SK_SN/example.json +++ b/gcn_classic_to_json/notices/SK_SN/example.json @@ -9,8 +9,8 @@ "trigger_time": "2024-05-31T23:05:35.570Z", "ra": 270.8199, "dec": 31.46, + "ra_dec_error": 0.91, "ra_dec_error_68": 0.64, - "ra_dec_error_90": 0.91, "ra_dec_error_95": 1.04, "n_events": 64176, "collection_duration": 10.0, From 0c6bc9d2fa1fe6461725efccf74a003036aacbeb Mon Sep 17 00:00:00 2001 From: Athish Thiruvengadam Date: Thu, 5 Sep 2024 20:51:55 -0500 Subject: [PATCH 9/9] removed additional_info --- gcn_classic_to_json/notices/SK_SN/__init__.py | 3 --- gcn_classic_to_json/notices/SK_SN/example.json | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/gcn_classic_to_json/notices/SK_SN/__init__.py b/gcn_classic_to_json/notices/SK_SN/__init__.py index 06266dd..f61de46 100644 --- a/gcn_classic_to_json/notices/SK_SN/__init__.py +++ b/gcn_classic_to_json/notices/SK_SN/__init__.py @@ -30,7 +30,4 @@ def parse(bin): "collection_duration": bin[21] * 1e-4, "energy_limit": bin[20] * 1e-1, "distance_range": [bin[13] * 1e-5, bin[14] * 1e-5], - "additional_info": ( - "This is a test notice." if trig_id_bits[1] else "This is a real notice." - ), } diff --git a/gcn_classic_to_json/notices/SK_SN/example.json b/gcn_classic_to_json/notices/SK_SN/example.json index 7b3fb3d..15c3efd 100644 --- a/gcn_classic_to_json/notices/SK_SN/example.json +++ b/gcn_classic_to_json/notices/SK_SN/example.json @@ -18,6 +18,5 @@ "distance_range": [ 0.00216, 0.0029500000000000004 - ], - "additional_info": "This is a test notice." + ] }