spacetelescope / pysiaf

Handling of Science Instrument Aperture Files (SIAF) for space telescopes
https://pysiaf.readthedocs.io
BSD 3-Clause "New" or "Revised" License
13 stars 28 forks source link

Update pysiaf with PRDOPSSOC-51 #250

Closed mfixstsci closed 2 years ago

mfixstsci commented 2 years ago

This PR updates pysiaf with the new PRD release PRDOPSSOC-51. SIAF data has been added to the prd_data directory and removed from the pre_delivery_data directory.

Witchblade101 commented 2 years ago

On my local copy (all recent updates, but not setup for the release process yet) I get the following:

`(pysiaf) minmei:tests dlong$ pytest -v -p no:warnings ========================================================= test session starts ========================================================== platform darwin -- Python 3.9.12, pytest-7.1.1, pluggy-1.0.0 -- /Users/dlong/miniconda3/envs/pysiaf/bin/python cachedir: .pytest_cache rootdir: /Users/dlong/pysiaf, configfile: setup.cfg collected 32 items

test_aperture.py::test_idl_to_tel PASSED [ 3%] test_aperture.py::test_hst_fgs_idl_to_tel PASSED [ 6%] test_aperture.py::test_jwst_aperture_transforms PASSED [ 9%] test_aperture.py::test_jwst_aperture_vertices PASSED [ 12%] test_aperture.py::test_raw_transformations PASSED [ 15%] test_aperture.py::test_jwst_sky_transformations PASSED [ 18%] test_hst.py::test_hst_aperture_init PASSED [ 21%] test_hst.py::test_hst_siaf PASSED [ 25%] test_hst.py::test_hst_amudotrep PASSED [ 28%] test_iando.py::test_write_jwst_siaf_xml PASSED [ 31%] test_iando.py::test_write_jwst_siaf_xlsx PASSED [ 34%] test_match_v2v3.py::test_match_v2v3 PASSED [ 37%] test_miri.py::test_against_test_data PASSED [ 40%] test_nirspec.py::test_against_test_data PASSED [ 43%] test_nirspec.py::test_nirspec_aperture_transforms PASSED [ 46%] test_nirspec.py::test_nirspec_slit_transformations PASSED [ 50%] test_nirspec.py::test_sci_det_consistency PASSED [ 53%] test_plotting.py::test_aperture_plotting PASSED [ 56%] test_polynomial.py::test_poly PASSED [ 59%] test_polynomial.py::test_RotateCoeffs PASSED [ 62%] test_polynomial.py::test_two_step PASSED [ 65%] test_polynomial.py::test_invert PASSED [ 68%] test_polynomial.py::test_ShiftCoeffs PASSED [ 71%] test_projection.py::test_tangent_plane_projection_roundtrip PASSED [ 75%] test_projection.py::test_project_to_tangent_plane PASSED [ 78%] test_projection.py::test_deproject_from_tangent_plane PASSED [ 81%] test_rotations.py::test_attitude PASSED [ 84%] test_rotations.py::test_attitude_matrix PASSED [ 87%] test_rotations.py::test_sky_to_tel PASSED [ 90%] test_rotations.py::test_axial_rotation PASSED [ 93%] test_rotations.py::test_unit_vector_from_cartesian PASSED [ 96%] test_tools.py::test_jwst_fgs_to_fgs_matrix PASSED [100%]

========================================================= 32 passed in 30.34s ==========================================================`

Did you run the tests locally after you pulled the upstream version into your copy?

mfixstsci commented 2 years ago

Hey @Witchblade101, I did pull the changes down. Let me double check, which python version are you using? I am using 3.8

mfixstsci commented 2 years ago

Here is the result when I try to pull the changes down.

$ git pull upstream master

From github.com:spacetelescope/pysiaf
 * branch            master     -> FETCH_HEAD
Already up to date.
Witchblade101 commented 2 years ago

I used 3.9, but I'll check with 3.7 and 3.8 just to be sure.

Witchblade101 commented 2 years ago

OK, with Python 3.7:

`(pysiaf37) minmei:tests dlong$ pytest -v -p no:warnings ========================================================= test session starts ========================================================== platform darwin -- Python 3.7.13, pytest-7.1.1, pluggy-1.0.0 -- /Users/dlong/miniconda3/envs/pysiaf37/bin/python cachedir: .pytest_cache rootdir: /Users/dlong/pysiaf, configfile: setup.cfg collected 32 items

test_aperture.py::test_idl_to_tel PASSED [ 3%] test_aperture.py::test_hst_fgs_idl_to_tel PASSED [ 6%] test_aperture.py::test_jwst_aperture_transforms PASSED [ 9%] test_aperture.py::test_jwst_aperture_vertices PASSED [ 12%] test_aperture.py::test_raw_transformations PASSED [ 15%] test_aperture.py::test_jwst_sky_transformations PASSED [ 18%] test_hst.py::test_hst_aperture_init PASSED [ 21%] test_hst.py::test_hst_siaf PASSED [ 25%] test_hst.py::test_hst_amudotrep PASSED [ 28%] test_iando.py::test_write_jwst_siaf_xml PASSED [ 31%] test_iando.py::test_write_jwst_siaf_xlsx PASSED [ 34%] test_match_v2v3.py::test_match_v2v3 PASSED [ 37%] test_miri.py::test_against_test_data PASSED [ 40%] test_nirspec.py::test_against_test_data PASSED [ 43%] test_nirspec.py::test_nirspec_aperture_transforms PASSED [ 46%] test_nirspec.py::test_nirspec_slit_transformations PASSED [ 50%] test_nirspec.py::test_sci_det_consistency PASSED [ 53%] test_plotting.py::test_aperture_plotting PASSED [ 56%] test_polynomial.py::test_poly PASSED [ 59%] test_polynomial.py::test_RotateCoeffs PASSED [ 62%] test_polynomial.py::test_two_step PASSED [ 65%] test_polynomial.py::test_invert PASSED [ 68%] test_polynomial.py::test_ShiftCoeffs PASSED [ 71%] test_projection.py::test_tangent_plane_projection_roundtrip PASSED [ 75%] test_projection.py::test_project_to_tangent_plane PASSED [ 78%] test_projection.py::test_deproject_from_tangent_plane PASSED [ 81%] test_rotations.py::test_attitude PASSED [ 84%] test_rotations.py::test_attitude_matrix PASSED [ 87%] test_rotations.py::test_sky_to_tel PASSED [ 90%] test_rotations.py::test_axial_rotation PASSED [ 93%] test_rotations.py::test_unit_vector_from_cartesian PASSED [ 96%] test_tools.py::test_jwst_fgs_to_fgs_matrix PASSED [100%]

========================================================= 32 passed in 31.06s ==========================================================`

But I realized I was in my fgs_aperture_threshold branch. I changed to master without pulling and tried again:

`(pysiaf37) minmei:tests dlong$ pytest -v -p no:warnings ========================================================= test session starts ========================================================== platform darwin -- Python 3.7.13, pytest-7.1.1, pluggy-1.0.0 -- /Users/dlong/miniconda3/envs/pysiaf37/bin/python cachedir: .pytest_cache rootdir: /Users/dlong/pysiaf, configfile: setup.cfg collected 32 items

test_aperture.py::test_idl_to_tel PASSED [ 3%] test_aperture.py::test_hst_fgs_idl_to_tel PASSED [ 6%] test_aperture.py::test_jwst_aperture_transforms PASSED [ 9%] test_aperture.py::test_jwst_aperture_vertices PASSED [ 12%] test_aperture.py::test_raw_transformations PASSED [ 15%] test_aperture.py::test_jwst_sky_transformations FAILED [ 18%] test_hst.py::test_hst_aperture_init PASSED [ 21%] test_hst.py::test_hst_siaf PASSED [ 25%] test_hst.py::test_hst_amudotrep PASSED [ 28%] test_iando.py::test_write_jwst_siaf_xml PASSED [ 31%] test_iando.py::test_write_jwst_siaf_xlsx PASSED [ 34%] test_match_v2v3.py::test_match_v2v3 PASSED [ 37%] test_miri.py::test_against_test_data PASSED [ 40%] test_nirspec.py::test_against_test_data PASSED [ 43%] test_nirspec.py::test_nirspec_aperture_transforms PASSED [ 46%] test_nirspec.py::test_nirspec_slit_transformations PASSED [ 50%] test_nirspec.py::test_sci_det_consistency PASSED [ 53%] test_plotting.py::test_aperture_plotting PASSED [ 56%] test_polynomial.py::test_poly PASSED [ 59%] test_polynomial.py::test_RotateCoeffs PASSED [ 62%] test_polynomial.py::test_two_step PASSED [ 65%] test_polynomial.py::test_invert PASSED [ 68%] test_polynomial.py::test_ShiftCoeffs PASSED [ 71%] test_projection.py::test_tangent_plane_projection_roundtrip PASSED [ 75%] test_projection.py::test_project_to_tangent_plane PASSED [ 78%] test_projection.py::test_deproject_from_tangent_plane PASSED [ 81%] test_rotations.py::test_attitude PASSED [ 84%] test_rotations.py::test_attitude_matrix PASSED [ 87%] test_rotations.py::test_sky_to_tel PASSED [ 90%] test_rotations.py::test_axial_rotation PASSED [ 93%] test_rotations.py::test_unit_vector_from_cartesian PASSED [ 96%] test_tools.py::test_jwst_fgs_to_fgs_matrix PASSED [100%]

=============================================================== FAILURES =============================================================== ____ test_jwst_skytransformations ____

verbose = False

def test_jwst_sky_transformations(verbose=False):
    """ Test tel_to_sky and sky_to_tel transformations, using an attitude matrix
    """
    from ..utils import rotations
    from . import test_rotations as tr
    import astropy.units as u

    # let's borrow the attitude matrix set up code from test_rotations/test_attitude_matrix:
    ra = tr.ra_deg * u.deg
    dec = tr.dec_deg * u.deg
    pa = tr.pa_deg * u.deg
    v2 = tr.v2_arcsec * u.arcsec
    v3 = tr.v3_arcsec * u.arcsec
    attitude_matrix = rotations.attitude_matrix(v2, v3, ra, dec, pa)

    # Load an aperture and set it to that attitude matrix
    fgs_aperture = Siaf('FGS').apertures['FGS1_FULL']

    fgs_aperture.set_attitude_matrix(attitude_matrix)

    # Test that, with that attitude matrix, sky<->tel transforms at the reference point work as expected
    assert np.allclose( fgs_aperture.sky_to_tel(ra, dec), (tr.v2_arcsec, tr.v3_arcsec)), "Unexpected result for Tel coords"
    assert np.allclose( fgs_aperture.tel_to_sky(tr.v2_arcsec, tr.v3_arcsec), (tr.ra_deg, tr.dec_deg)), "Unexpected result for Sky coords"

    # test on some arbitrary points that sky_to_tel and tel_to_sky are inverses
    t1 = 123
    t2 = -456
    assert np.allclose(fgs_aperture.sky_to_tel(*fgs_aperture.tel_to_sky(t1,t2)), (t1,t2)), "sky_to_tel(tel_to_sky) was not an identity"

    s1 = 0.1
    s2 = -0.3
    assert np.allclose(fgs_aperture.tel_to_sky(*fgs_aperture.sky_to_tel(s1,s2)), (s1,s2)), "tel_to_sky(sky_to_tel) was not an identity"

    d1 = 512
    d2 = 1024
    # test to/from detector coords, to test all the intermediate transforms too
  assert np.allclose(fgs_aperture.sky_to_det(*fgs_aperture.det_to_sky(d1,d2)), (d1,d2)), "sky_to_det(det_to_sky) was not an identity"

E AssertionError: sky_to_det(det_to_sky) was not an identity E assert False E + where False = <function allclose at 0x7fdbd84c1320>((511.97856151561746, 1023.9582616987781), (512, 1024)) E + where <function allclose at 0x7fdbd84c1320> = np.allclose E + and (511.97856151561746, 1023.9582616987781) = <bound method Aperture.sky_to_det of >(*(19.770854248747433, 69.73418978861316)) E + where <bound method Aperture.sky_to_det of > = .sky_to_det E + and (19.770854248747433, 69.73418978861316) = <bound method Aperture.det_to_sky of >(512, 1024) E + where <bound method Aperture.det_to_sky of > = .det_to_sky

test_aperture.py:278: AssertionError ======================================================= short test summary info ======================================================== FAILED test_aperture.py::test_jwst_sky_transformations - AssertionError: sky_to_det(det_to_sky) was not an identity ==================================================== 1 failed, 31 passed in 31.10s =====================================================`

After pulling in upstream changes to master:

`(pysiaf37) minmei:tests dlong$ pytest -v -p no:warnings ========================================================= test session starts ========================================================== platform darwin -- Python 3.7.13, pytest-7.1.1, pluggy-1.0.0 -- /Users/dlong/miniconda3/envs/pysiaf37/bin/python cachedir: .pytest_cache rootdir: /Users/dlong/pysiaf, configfile: setup.cfg collected 32 items

test_aperture.py::test_idl_to_tel PASSED [ 3%] test_aperture.py::test_hst_fgs_idl_to_tel PASSED [ 6%] test_aperture.py::test_jwst_aperture_transforms PASSED [ 9%] test_aperture.py::test_jwst_aperture_vertices PASSED [ 12%] test_aperture.py::test_raw_transformations PASSED [ 15%] test_aperture.py::test_jwst_sky_transformations PASSED [ 18%] test_hst.py::test_hst_aperture_init PASSED [ 21%] test_hst.py::test_hst_siaf PASSED [ 25%] test_hst.py::test_hst_amudotrep PASSED [ 28%] test_iando.py::test_write_jwst_siaf_xml PASSED [ 31%] test_iando.py::test_write_jwst_siaf_xlsx PASSED [ 34%] test_match_v2v3.py::test_match_v2v3 PASSED [ 37%] test_miri.py::test_against_test_data PASSED [ 40%] test_nirspec.py::test_against_test_data PASSED [ 43%] test_nirspec.py::test_nirspec_aperture_transforms PASSED [ 46%] test_nirspec.py::test_nirspec_slit_transformations PASSED [ 50%] test_nirspec.py::test_sci_det_consistency PASSED [ 53%] test_plotting.py::test_aperture_plotting PASSED [ 56%] test_polynomial.py::test_poly PASSED [ 59%] test_polynomial.py::test_RotateCoeffs PASSED [ 62%] test_polynomial.py::test_two_step PASSED [ 65%] test_polynomial.py::test_invert PASSED [ 68%] test_polynomial.py::test_ShiftCoeffs PASSED [ 71%] test_projection.py::test_tangent_plane_projection_roundtrip PASSED [ 75%] test_projection.py::test_project_to_tangent_plane PASSED [ 78%] test_projection.py::test_deproject_from_tangent_plane PASSED [ 81%] test_rotations.py::test_attitude PASSED [ 84%] test_rotations.py::test_attitude_matrix PASSED [ 87%] test_rotations.py::test_sky_to_tel PASSED [ 90%] test_rotations.py::test_axial_rotation PASSED [ 93%] test_rotations.py::test_unit_vector_from_cartesian PASSED [ 96%] test_tools.py::test_jwst_fgs_to_fgs_matrix PASSED [100%]

========================================================= 32 passed in 31.11s ==========================================================`

Witchblade101 commented 2 years ago

Not posting the gory details, but with python 3.8 all 32 tests passed, as well.