Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRB Counterpart Binary Conversion #46

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions gcn_classic_to_json/notices/GRB_CNTRPART/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import numpy as np

from ... import utils


def parse(bin):
bin[5:7] # Intentionally Omitted. Datetime of original trigger
bin[
12
] # Intentionally Omitted. According to Docs: 'filter if optical or exponent of band if radio or other'
# However in practise these notices seem to be created only for Swift-XRT and the energy is 0.3-10 keV for all text notices.
bin[13] # Intentionally Omitted. According to Docs: 'Seeing during the observation'

misc_bits = np.flip(np.unpackbits(bin[19:20].view(dtype="u1")))

spectrum = None
unit = None
if (misc_bits[5] == 1) and (misc_bits[6] == 0):
spectrum = "wavelength"
unit = "nm"
elif (misc_bits[5] == 0) and (misc_bits[6] == 1):
spectrum = "frequency"
unit = "Hz"
elif (misc_bits[5] == 1) and (misc_bits[6] == 1):
spectrum = "energy"
unit = "keV"

expo_factor = np.float_power(
10, np.packbits(np.flip(misc_bits[24:])).view(dtype="i1")
)[0]

trig_id = np.flip(np.unpackbits(bin[18:19].view(dtype="u1")))

return {
"ref_ID": [bin[4]],
"messenger": "EM",
"ref_type": "GRB",
"trigger_time": utils.datetime_to_iso8601(bin[14], bin[15]),
"ra": bin[7] * 1e-4,
"dec": bin[8] * 1e-4,
"ra_dec_error": bin[11] * 1e-4,
"systematic_included": True,
"spectrum": spectrum,
"units": unit,
"energy_flux": bin[9] * 1e-2 * expo_factor,
"energy_flux_error": bin[10] * 1e-2 * expo_factor,
"flux_energy_range": [0.3, 10] if spectrum == "energy" else None,
"duration": bin[16] * 1e-2,
"confidence_level": bin[17] * 1e-4,
"ref_instrument": utils.binary_to_string(bin[20:24]),
"submitter_name": utils.binary_to_string(bin[24:39]),
"additional_info": "We cannot confirm whether this is the GRB or serendipitous"
if trig_id[1]
else "This is definitely related to GRB",
}
25 changes: 25 additions & 0 deletions gcn_classic_to_json/notices/GRB_CNTRPART/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"ref_ID": [
21694
],
"messenger": "EM",
"ref_type": "GRB",
"trigger_time": "2024-05-27T21:38:36.000Z",
"ra": 128.2194,
"dec": -14.349400000000001,
"ra_dec_error": 0.0019,
"systematic_included": true,
"spectrum": "energy",
"units": "keV",
"energy_flux": 1.5e-13,
"energy_flux_error": 6e-14,
"flux_energy_range": [
0.3,
10
],
"duration": 2512.31,
"confidence_level": 0.15,
"ref_instrument": "Swift-XRT",
"submitter_name": "Phil_Evans",
"additional_info": "We cannot confirm whether this is the GRB or serendipitous"
}
Loading