Fix exposure calculation to account for edge effects and GTI#24
Fix exposure calculation to account for edge effects and GTI#24israelmcmc wants to merge 5 commits intoUSRA-STI:mainfrom
Conversation
|
I like how the bounds are enforced with max and min while calculating the exposure, however it should be conditional on the keywords tstart and tstop being included in kwargs. I'm not sure how the default values for tstart and tstop would be different than the entire time range of the data object if the default arguments are used. Need more discussion on how this routine comes up with the desired answer with the fix. |
# Conflicts: # src/gdt/core/data_primitives.py
… in energy or time and stored into obj
… Adding test to check the default tstart and tstop.
|
Thanks for reviewing, @BillCleveland-USRA. I'm sorry it took me so long to come back to this. Maybe it's worth decoupling the changes to
Yeah, I think I agree. Using the entire time range would be a better default than the GTI. I thought about using the I pushed a couple extra changes:
Some other notes:
|
# Conflicts: # src/gdt/core/tte.py
|
I synced my branch with the main branch and resolved conflicts. |
|
@AdamGoldstein-USRA @israelmcmc The changes in this PR causes two tests in test_tte to fail: tests/core/test_tte.py:196 (TestPhotonList.test_to_phaii)
self = <tests.core.test_tte.TestPhotonList testMethod=test_to_phaii>
def test_to_phaii(self):
# full range
phaii = self.tte.to_phaii(bin_by_time, 1.0, phaii_class=Phaii)
self.assertTupleEqual(phaii.energy_range, self.tte.energy_range)
self.assertTupleEqual(phaii.gti.as_list()[0], self.tte.gti.as_list()[0])
self.assertEqual(phaii.num_chans, 6)
> self.assertTupleEqual(phaii.time_range, (0.706, 10.706))
E AssertionError: Tuples differ: (np.float64(0.0), np.float64(11.0)) != (0.706, 10.706)
E
E First differing element 0:
E np.float64(0.0)
E 0.706
E
E - (np.float64(0.0), np.float64(11.0))
E + (0.706, 10.706)
core/test_tte.py:202: AssertionErrorAnd: tests/core/test_tte.py:449 (TestPhotonListNoEbounds.test_to_phaii)
self = <tests.core.test_tte.TestPhotonListNoEbounds testMethod=test_to_phaii>
def test_to_phaii(self):
# full range
phaii = self.tte.to_phaii(bin_by_time, 1.0, phaii_class=Phaii)
assert phaii.energy_range is None
self.assertTupleEqual(phaii.gti.as_list()[0], self.tte.gti.as_list()[0])
self.assertEqual(phaii.num_chans, 6)
> self.assertTupleEqual(phaii.time_range, (0.706, 10.706))
E AssertionError: Tuples differ: (np.float64(0.0), np.float64(11.0)) != (0.706, 10.706)
E
E First differing element 0:
E np.float64(0.0)
E 0.706
E
E - (np.float64(0.0), np.float64(11.0))
E + (0.706, 10.706)
core/test_tte.py:455: AssertionError |
The first and last time bins didn't have a correct exposure due to edge effects and not accounting for the GTI. There were 2 issues:
time_ref, the first/last edge could go before/beyond the beginning/end of the TTE time range. This is time for which there is no data but it was still counted as part of the exposure.e.g.
Before this change would return
Where the rate of the first bin is artificially too small
And after:
I know I need to write a test for this and the other open PR. However since these are changes that we'll use for the Burstcube pipeline (we're using the fork https://github.com/BurstCube/gdt-core), I thought it would be better the open the PR sooner than later so people are aware.