sot / xija

Thermal modeling framework for Chandra X-ray Observatory
https://sot.github.io/xija
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

Fix problem of dropping bad_times in spec file and y-scale divergence #130

Closed taldcroft closed 2 years ago

taldcroft commented 2 years ago

Description

This fixes the issue noted on slack that after #123, any bad times in a model spec file that were not covered by the fitting range in xija_gui_fit would be dropped from the spec file.

This PR makes self.bad_times be an unchanged copy of the original spec file value. Then after computing the indices (into the model times) of the intersecting bad times, only the indices get carried around on the object. Where the times are needed they are regenerated by indexing into model.times.

This also fixes (3f45047) an unrelated problem where each new bad time region that was plotted was expanding the y-axis limit by a multiplicative factor, leading to an exponential divergence in the y-scale with many bad regions. It isn't clear why this wasn't showing up a long time ago.

Interface impacts

None.

Testing

Unit tests

Functional tests

Dropped bad times

I made a copy of the flight aca_spec.json file and added a new bad time interval (not strictly necessary but I did it):

        [
            "2020:165:14:10:00",
            "2020:170:00:00:00"
        ]

Then using both master branch and this branch, I did:

python -m xija.gui_fit.app aca_spec.json --stop 2020:190 --days 60

In both cases:

Using the master branch I saw that all the saved bad times outside of the fit range were missing. Using this branch I saw that the saved bad times matched exactly the original bad times.

Y-axis scaling

Using the MUPS model with thousands of bad regions with the master branch shows the divergence in y-scale with each new region that gets added to the plot. Running the same with this branch now shows the expected plot with every bad region having the same Y size.

python -m xija.gui_fit.app --stop 2022:050 --days 20 pm2thv1t_spec.json --set-data="mups0=100"

I also tested manually adding an "ignore" filter and this worked OK.