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

GECAM_FLT and GECAM_GND conversions #35

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
39 changes: 39 additions & 0 deletions gcn_classic_to_json/notices/GECAM_FLT/__init__.py
lpsinger marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jracusin, would you please help @athish-thiru find the integer to class name mapping for this field?

bin[
18
] # Temporarily Unused. Should have a bit->flag mapping but incomplete documenation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jracusin, we need help with interpreting this field too.

bin[21] # Temporarily Unused. How is it different from burst_dur?
lpsinger marked this conversation as resolved.
Show resolved Hide resolved
bin[22:24] # Unused. Equivalent to rate_energy_range
bin[
26
] # Temporarily Unused. Presumably which detectors activated but incomplete documenation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jracusin, we need help with this field.

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),
lpsinger marked this conversation as resolved.
Show resolved Hide resolved
"trigger_type": "rate",
"rate_energy_range": [bin[24], bin[25]],
"rate_snr": bin[20] * 1e-2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is called trig_signif. Do we know that this is equivalent to SNR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't documented, so we can't be completely certain. I was mainly going of the text notices which had the following:
TRIGGER_SIGNIF: 5.1 [sigma] (Signif of the Trigger)
Linked here

Copy link
Member

@lpsinger lpsinger Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not documented, but we do have the source code. Also we can contact the GECAM mission.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the source code: "Height of the triggering peak"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could mean SNR if it is the height of an SNR time series, but it could equally well be the height of the the count rate time series. @Vidushi-GitHub, @jracusin, some help here please.

Copy link
Member

@Vidushi-GitHub Vidushi-GitHub Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks a best match with rate_snr in Statistics schema. Most likely height of the peak value from the light curve i.e. counts/s or rate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't sound like we reached a definite answer on this yet. @Vidushi-GitHub, how would you like to resolve this?

"net_count_rate": int(bin[9]),
lpsinger marked this conversation as resolved.
Show resolved Hide resolved
"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,
lpsinger marked this conversation as resolved.
Show resolved Hide resolved
"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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields are unused by GECAM_GND, but some of them are used by GECAM_FLT. This line here will defeat the coverage tests for GECAM_FLT. Please refactor the common parsing code for both GECAM_FLT and GECAM_GND into a single function that is reused by both parsers.

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),
lpsinger marked this conversation as resolved.
Show resolved Hide resolved
"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
}
Loading