Skip to content

Commit

Permalink
GECAM binary conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
Athish Thiruvengadam committed Aug 7, 2024
1 parent d1309c5 commit 26433a8
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
39 changes: 39 additions & 0 deletions gcn_classic_to_json/notices/GECAM_FLT/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from ... import utils


def parse(bin):
bin[15] # Unused. According to docs: '4 bytes for the future'
bin[27:39] # Unused. According to docs: '32 bytes for the future'
bin[
11
] # Temporarily Unused. Should have a int->class_type mapping but incomplete documentation
bin[
18
] # Temporarily Unused. Should have a bit->flag mapping but incomplete documenation
bin[21] # Temporarily Unused. How is it different from burst_dur?
bin[22:24] # Unused. Equivalent to rate_energy_range
bin[
26
] # Temporarily Unused. Presumably which detectors activated but incomplete documenation
return {
"mission": "GECAM",
"id": [bin[4]],
"messenger": "EM",
"mission_type": chr(bin[19] + 64), # mission type is A or B
# There is an error here; You are supposed to divide by 8640000 to get the correct value
# But it only seems to work if you divide by 864000000; I'm assuming it's some error in encoding the packets
"trigger_time": utils.datetime_to_iso8601(bin[5], bin[6] * 1e-2),
"trigger_type": "rate",
"rate_energy_range": [bin[24], bin[25]],
"rate_snr": bin[20] * 1e-2,
"net_count_rate": int(bin[9]),
"rate_duration": bin[14] * 1e-4,
"ra": bin[7] * 1e-4,
"dec": bin[8] * 1e-4,
"ra_dec_error": bin[10] * 1e-4,
"containment_probability": 0.68,
"instrument_phi": bin[12] * 1e-2,
"instrument_theta": bin[13] * 1e-2,
"latitude": bin[16] * 1e-2,
"longitude": bin[17] * 1e-2,
}
25 changes: 25 additions & 0 deletions gcn_classic_to_json/notices/GECAM_FLT/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"mission": "GECAM",
"id": [
368
],
"messenger": "EM",
"mission_type": "B",
"trigger_time": "2024-05-17T13:01:22.550Z",
"trigger_type": "rate",
"rate_energy_range": [
30,
140
],
"rate_snr": 5.09,
"net_count_rate": 550,
"rate_duration": 10.0,
"ra": 57.830000000000005,
"dec": 17.400000000000002,
"ra_dec_error": 1.4899,
"containment_probability": 0.68,
"instrument_phi": 7.46,
"instrument_theta": 51.27,
"latitude": 11.09,
"longitude": -8.55
}
32 changes: 32 additions & 0 deletions gcn_classic_to_json/notices/GECAM_GND/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from ... import utils


def parse(bin):
bin[15] # Unused. According to docs: '4 bytes for the future'
bin[20:39] # Unused. According to docs: '76 bytes for the future'
bin[
11
] # Temporarily Unused. Should have a int->class_type mapping but incomplete documentation
bin[
18
] # Temporarily Unused. Should have a bit->flag mapping but incomplete documenation
return {
"mission": "GECAM",
"id": [bin[4]],
"messenger": "EM",
"mission_type": chr(bin[19] + 64),
# There is an error here; You are supposed to divide by 8640000 to get the correct value
# But it only seems to work if you divide by 864000000; I'm assuming it's some error in encoding the packets
"trigger_time": utils.datetime_to_iso8601(bin[5], bin[6] * 1e-2),
"trigger_type": "rate",
"net_count_rate": bin[9],
"rate_duration": bin[14] * 1e-4,
"ra": bin[7] * 1e-4,
"dec": bin[8] * 1e-4,
"ra_dec_error": bin[10] * 1e-4,
"containment_probability": 0.68,
"instrument_phi": bin[12] * 1e-2,
"instrument_theta": bin[13] * 1e-2,
"latitude": bin[16] * 1e-2,
"longitude": bin[17] * 1e-2,
}
20 changes: 20 additions & 0 deletions gcn_classic_to_json/notices/GECAM_GND/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"mission": "GECAM",
"id": [
368
],
"messenger": "EM",
"mission_type": "B",
"trigger_time": "2024-05-17T13:01:22.550Z",
"trigger_type": "rate",
"net_count_rate": 1306,
"rate_duration": 27.0,
"ra": 56.25,
"dec": 16.21,
"ra_dec_error": 1.57,
"containment_probability": 0.68,
"instrument_phi": 5.98,
"instrument_theta": 52.83,
"latitude": 11.09,
"longitude": -8.55
}

0 comments on commit 26433a8

Please sign in to comment.