-
Notifications
You must be signed in to change notification settings - Fork 5
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
SWIFT_BAT_GRB_POS_ACK conversion #36
base: main
Are you sure you want to change the base?
Changes from 8 commits
22ad490
eb667a4
812852a
995b03e
1f3a946
d1309c5
10e0d80
fa2b436
81fb379
8c6e5e2
9a3c48f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,78 @@ | ||
import numpy as np | ||
|
||
from ... import utils | ||
|
||
flag_descriptions = { | ||
0: "A point source was found.", | ||
1: "It is a GRB.", | ||
2: "It is an interesting src.", | ||
3: "It is in the flight catalog.", | ||
5: "It is definitely not a GRB.", | ||
6: "It is probably not a GRB or Transient(hi bkg level).", | ||
7: "It is probably not a GRB or Transient(low image significance; < 7).", | ||
8: "It is in the ground catalog.", | ||
9: "It is probably not a GRB or Transient(negative bkg slop).", | ||
10: "StraTracker not locked so trigger porbably bogus.", | ||
11: "It is probably not a GRB or Transient(very low image significance; < 6.5).", | ||
12: "It is the catalog of sources to be blocked.", | ||
13: "There is a bright star nearby.", | ||
14: "This was orginally a SubTresh, but it is now converted to a real BAT_POS.", | ||
15: "This is a source that has purposefully been removed from on-board catalog.", | ||
16: "This matched a Nearby_Galaxy in the on-board catalog.", | ||
28: "There was a temporal coincidence with another event.", | ||
29: "There was a spatial coincidence with another event.", | ||
30: "This is a test submission", | ||
} | ||
|
||
|
||
def parse(bin): | ||
bin[15] # Unused. According to docs: '4 bytes for the future' | ||
bin[19] # Unused. Flags are either internal or equivalent to bin[18] | ||
bin[26:36] # Unused. According to docs: '40 bytes for the future' | ||
bin[36] # Unused. Flags Equivalent to bin[18] | ||
bin[38] # Intentionally omitted. Sun/Moon parameters | ||
|
||
integ_time = bin[14] * 16 / 1000 | ||
|
||
lat, lon = bin[16:17].view(">i2") | ||
|
||
soln_status_bits = np.flip(np.unpackbits(bin[18:19].view(dtype="u1"))) | ||
|
||
comments = "\n".join( | ||
[val for (key, val) in flag_descriptions.items() if (soln_status_bits[key])] | ||
) | ||
|
||
calalog_num = bin[25] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo on catalog |
||
|
||
energy_ranges = [[15, 25], [15, 50], [25, 100], [50, 350]] | ||
athish-thiru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
energy_range_idx = np.flip(bin[37:38].view(dtype="i1"))[0] | ||
energy_range = energy_ranges[energy_range_idx] | ||
|
||
return { | ||
"mission": "SWIFT", | ||
"instrument": "BAT", | ||
"id": [bin[4]], | ||
"trigger_time": utils.datetime_to_iso8601(bin[5], bin[6]), | ||
"trigger_type": "image" if soln_status_bits[4] else "rate", | ||
"image_duration": integ_time if soln_status_bits[4] else None, | ||
"image_energy_range": energy_range if soln_status_bits[4] else None, | ||
"rate_duration": integ_time if not soln_status_bits[4] else None, | ||
"rate_energy_range": integ_time if not soln_status_bits[4] else None, | ||
"ra": 1e-4 * bin[7], | ||
"dec": 1e-4 * bin[8], | ||
"ra_dec_error": 1e-4 * bin[11], | ||
"instrument_phi": 1e-2 * bin[12], | ||
"instrument_theta": 1e-2 * bin[13], | ||
"latitude": lat * 1e-2, | ||
"longitude": lon * 1e-2, | ||
"rate_snr": bin[21] * 1e-2, | ||
"image_snr": bin[20] * 1e-2, | ||
"n_events": bin[9], | ||
"image_peak": bin[10], | ||
"background_events": bin[22], | ||
"background_start_time": utils.datetime_to_iso8601(bin[5], bin[23]), | ||
"backgroun_duration": bin[24] * 1e-2, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: should be "background_duration" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @bob-wiegand! Could you link the package that you used for spell-checking? I think it would be easier for me to run this on my end and correct it for each notice type instead of you having to manually list each error. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: I am not sure it would be simpler since it was still somewhat manual. The silliest aspect is that I was unable to find a way to get typos to exclude times (e.g., 1987-01-02T03:04:05.6); although extend-ignore-re will exclude the times from the misspelling list, I could not figure out how to get it to exclude them from the word/identifier list. |
||
"trigger_index": bin[17], | ||
"catalog_number": calalog_num if soln_status_bits[3] else None, | ||
"additional_info": comments if comments else None, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
{ | ||
"mission": "SWIFT", | ||
"instrument": "BAT", | ||
"id": [ | ||
1227767 | ||
], | ||
"trigger_time": "2024-05-11T18:06:53.220Z", | ||
"trigger_type": "rate", | ||
"image_duration": null, | ||
"image_energy_range": null, | ||
"rate_duration": 8.192, | ||
"rate_energy_range": 8.192, | ||
"ra": 336.66450000000003, | ||
"dec": 8.5135, | ||
"ra_dec_error": 0.05 | ||
"ra_dec_error": 0.05, | ||
"instrument_phi": -173.54, | ||
"instrument_theta": 28.38, | ||
"latitude": -11.14, | ||
"longitude": 151.31, | ||
"rate_snr": 14.89, | ||
"image_snr": 8.52, | ||
"n_events": 7538, | ||
"image_peak": 281, | ||
"background_events": 74677, | ||
"background_start_time": "2024-05-11T18:06:22.570Z", | ||
"backgroun_duration": 24.0, | ||
"trigger_index": 262, | ||
"catalog_number": null, | ||
"additional_info": "A point source was found.\nIt is a GRB.\nThere was a spatial coincidence with another event." | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please capture these flags in a machine-readable way, not as comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use additional_info to capture the data stored in the
COMMENTS:
fields in the text notices. Some of these are redundant with the data in the notices and can be removed(I've mainly added them for completeness). However, some of the these comments I think may be too complex to easily translate into a field like "StarTracker not locked so trigger probably bogus" or "This was orginally a SubTresh, but it is now converted to a real BAT_POS.".