-
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
Open
athish-thiru
wants to merge
11
commits into
nasa-gcn:main
Choose a base branch
from
athish-thiru:swift_bat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
22ad490
Note: Squashed a bunch of commits and cleaned up commit history message
lpsinger eb667a4
reformatting
812852a
Added code to ignore unused binary fields.
995b03e
fixed URL and refactored utils.py
1f3a946
Moved pkt_sernum, pkt_hop_cnt and pkt_sod to notices/__init__.py
d1309c5
merge branch with main
10e0d80
swift bat conversion initial commit
fa2b436
removed xfail test, moved dict outside of function and removed unnces…
81fb379
lifted energy range
8c6e5e2
coverted comments into fields
9a3c48f
Added all other SWIFT_BAT notices
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,79 @@ | ||
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", | ||
} | ||
|
||
energy_ranges = [[15, 25], [15, 50], [25, 100], [50, 350]] | ||
|
||
|
||
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] | ||
|
||
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, | ||
"trigger_index": bin[17], | ||
"catalog_number": calalog_num if soln_status_bits[3] else None, | ||
"additional_info": comments if comments else None, | ||
} |
26 changes: 25 additions & 1 deletion
26
gcn_classic_to_json/notices/SWIFT_BAT_GRB_POS_ACK/example.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.".