spacetelescope / astrocut

Tools for making image cutouts from sets of TESS full frame images
https://astrocut.readthedocs.io
25 stars 12 forks source link

Update cube and cutout unittests #90

Closed hmlewis-astro closed 1 year ago

hmlewis-astro commented 1 year ago

Updates to existing unit tests and adding new tests to account for changes in CutoutFactory (made in #88). Tests verify that cutouts are being made correctly from the new TICA cubes (without error arrays) and verify known differences in TICA vs. SPOC FFIs, cubes, and cutouts.

Note, there is a placeholder unittest (test_cube_cut.py::test_tica_cutout_error) to remind us to go back to look at whether we can/should point the test to an existing TICA cube (one that does have the error array and will be among the last cubes to me re-built, e.g., Sector 27) that will be re-built later, to verify that cutouts can still be made from cubes with error array.

codecov[bot] commented 1 year ago

Codecov Report

Patch and project coverage have no change.

Comparison is base (fe56d85) 94.45% compared to head (92a65ed) 94.45%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #90 +/- ## ======================================= Coverage 94.45% 94.45% ======================================= Files 8 8 Lines 1443 1443 ======================================= Hits 1363 1363 Misses 80 80 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jaymedina commented 1 year ago

Thanks for this PR - I thought about it a bit more about testing the new CutoutFactory changes against an older TICA cube (still with the error array) and I think you can just use a SPOC cube with the TICA header keywords superimposed. Before the removal of the error arrays, the TICA cubes were structurally identical to the SPOC ones, just with different header keywords. If we go this route, your code will look like this:

def test_tica_cutout_error():
     tica_cube_error = CubeFactory() # this is actually a SPOC cube but we're gonna update the headers with TICA 
     tica_cube_no_error = TicaCubeFactory()

     with fits.open(tica_cube_error, mode='u') as hdulist:
           tica_cube_error[0].header = fits.getheader(tica_cube_no_error, 0)
           tica_cube_error[1].header = fits.getheader(tica_cube_no_error, 1)

           etc...
     # now do the actual testing 
     out_file = CutoutFactory(tica_cube_error)

The logic here isn't exact, I would verify with the astropy documentation the best way to replace one HDU lists headers with another, but this is more or less the concept of what I think will be the easiest path forward for this unit test in particular. And we don't need to be accurate with the WCS since this unit test is just to make sure the old TICA cube HDU list structure still works.