From 3ed8690d15b239b74867a2eecc77b19fe7f9faa9 Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Sat, 16 Sep 2023 12:11:31 -0400 Subject: [PATCH 1/3] Update pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3d846d..436e458 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: repos: - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black From 7a5576c137ec3e9cb9de538c6e1b40ae3c49799d Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Sat, 16 Sep 2023 12:14:29 -0400 Subject: [PATCH 2/3] Update to use nominal roll range 0-360 --- ska_sun/sun.py | 6 +++++- ska_sun/tests/test_sun.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ska_sun/sun.py b/ska_sun/sun.py index e36b3e7..f1bb502 100755 --- a/ska_sun/sun.py +++ b/ska_sun/sun.py @@ -377,7 +377,7 @@ def nominal_roll(ra, dec, time=None, sun_ra=None, sun_dec=None): :param sun_ra: Sun right ascension (instead of ``time``) :param sun_dec: Sun declination (instead of ``time``) - :returns: nominal roll angle (deg) + :returns: nominal roll angle (deg) in 0-360 range """ if time is not None: @@ -399,6 +399,10 @@ def _nominal_roll(ra, dec, sun_ra, sun_dec): np.sum(body_z**2) ) # shouldn't be needed but do it anyway roll = np.degrees(np.arctan2(body_y[2], body_z[2])) + + # Convert to 0-360 range (arctan2 is -pi to pi) + roll = (roll + 360) % 360 + return roll diff --git a/ska_sun/tests/test_sun.py b/ska_sun/tests/test_sun.py index d604ae0..d9006aa 100644 --- a/ska_sun/tests/test_sun.py +++ b/ska_sun/tests/test_sun.py @@ -121,6 +121,11 @@ def test_nominal_roll(): assert np.allclose(roll, 68.83020) # vs. 68.80 for obsid 12393 in JAN1711A +def test_nominal_roll_range(): + roll = nominal_roll(0, 89.9, time="2019:006:12:00:00") + assert np.allclose(roll, 287.24879) # range in 0-360 and value for sparkles test + + def test_off_nominal_roll_and_pitch(): att = (198.392135, 36.594359, 33.983322) # RA, Dec, Roll of obsid 16354 oroll = off_nominal_roll(att, "2015:335:00:00:00") # NOT the 16354 time From f144f13fa00677db700e082718d043ebe11db5dc Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Mon, 18 Sep 2023 12:18:30 -0400 Subject: [PATCH 3/3] Remove extra ' + 360' in modulo op --- ska_sun/sun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ska_sun/sun.py b/ska_sun/sun.py index f1bb502..541a7d9 100755 --- a/ska_sun/sun.py +++ b/ska_sun/sun.py @@ -401,7 +401,7 @@ def _nominal_roll(ra, dec, sun_ra, sun_dec): roll = np.degrees(np.arctan2(body_y[2], body_z[2])) # Convert to 0-360 range (arctan2 is -pi to pi) - roll = (roll + 360) % 360 + roll = roll % 360 return roll