Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add drift_pars kwarg to get_aca_offsets and get_fid_offset #189

Merged
merged 2 commits into from
Mar 19, 2025

Conversation

taldcroft
Copy link
Member

@taldcroft taldcroft commented Mar 5, 2025

Description

This adds a new optional kwarg drift_parsto the get_aca_offsets and get_fid_offset functions. This makes it easier to develop and functionally test a new drift model without having to put that model into branch of chandra_models.

Interface impacts

New kwarg.

Testing

Unit tests

  • Mac (new tests)

Flight chandra_models:

(ska3) ➜  chandra_aca git:(add-drift-pars-kwargs) git rev-parse --short HEAD
df74975
(ska3) ➜  chandra_aca git:(add-drift-pars-kwargs) pytest -s                 
=================================================================== test session starts ===================================================================
platform darwin -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /Volumes/git
configfile: pytest.ini
plugins: anyio-4.7.0, timeout-2.3.1
collected 250 items                                                                                                                                       

chandra_aca/tests/test_aca_image.py ..................
chandra_aca/tests/test_all.py .testing 625 row/col pairs match to 0.05 arcsec
..testing 622 yang/zang pairs match to 0.05 pixels
.....................
chandra_aca/tests/test_attitude.py .............................................................
chandra_aca/tests/test_dark_model.py ............
chandra_aca/tests/test_dark_subtract.py ........
chandra_aca/tests/test_drift.py 
.repo_path='/Users/aldcroft/ska/data/chandra_models' version='3.63' md5='ac8ca75533be18643359d2e0889019ca'
   ...
.repo_path='/Users/aldcroft/ska/data/chandra_models' version='3.63' md5='ac8ca75533be18643359d2e0889019ca'
..............................
chandra_aca/tests/test_maude_decom.py .........................
chandra_aca/tests/test_planets.py ...............
chandra_aca/tests/test_psf.py ...
chandra_aca/tests/test_residuals.py .....
chandra_aca/tests/test_star_probs.py .................................

================================================================== 250 passed in 40.05s ===================================================================

Test chandra_models

With $HOME/git/chandra_models including the branch for sot/chandra_models#146:

(ska3) ➜  chandra_aca git:(add-drift-pars-kwargs) env CHANDRA_MODELS_REPO_DIR=${HOME}/git/chandra_models \        
  CHANDRA_MODELS_DEFAULT_VERSION=aimpoint-drift-update \
  pytest -s
=================================================================== test session starts ===================================================================
platform darwin -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /Volumes/git
configfile: pytest.ini
plugins: anyio-4.7.0, timeout-2.3.1
collected 250 items                                                                                                                                       

chandra_aca/tests/test_aca_image.py ..................
chandra_aca/tests/test_all.py .testing 625 row/col pairs match to 0.05 arcsec
..testing 622 yang/zang pairs match to 0.05 pixels
.....................
chandra_aca/tests/test_attitude.py .............................................................
chandra_aca/tests/test_dark_model.py ............
chandra_aca/tests/test_dark_subtract.py ........
chandra_aca/tests/test_drift.py 
.repo_path='/Users/aldcroft/git/chandra_models' version='aimpoint-drift-update' md5='918ed8df7b6358a1c1bdf6b03edac669'
  ...
.repo_path='/Users/aldcroft/git/chandra_models' version='aimpoint-drift-update' md5='918ed8df7b6358a1c1bdf6b03edac669'
..............................
chandra_aca/tests/test_maude_decom.py .........................
chandra_aca/tests/test_planets.py ...............
chandra_aca/tests/test_psf.py ...
chandra_aca/tests/test_residuals.py .....
chandra_aca/tests/test_star_probs.py .................................

================================================================== 250 passed in 32.09s ===================================================================

MD5 sum of model file in aimpoint_mon:

 md5 ~/git/aimpoint_mon/aca_drift_model.json 
MD5 (/Users/aldcroft/git/aimpoint_mon/aca_drift_model.json) = 918ed8df7b6358a1c1bdf6b03edac669

Independent check of unit tests by Jean

  • Mac
(ska3) flame:chandra_aca jean$ pytest
===================================================================================== test session starts ======================================================================================
platform darwin -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/jean/git
configfile: pytest.ini
plugins: anyio-4.7.0, timeout-2.3.1
collected 250 items                                                                                                                                                                            

chandra_aca/tests/test_aca_image.py ..................                                                                                                                                   [  7%]
chandra_aca/tests/test_all.py ........................                                                                                                                                   [ 16%]
chandra_aca/tests/test_attitude.py .............................................................                                                                                         [ 41%]
chandra_aca/tests/test_dark_model.py ............                                                                                                                                        [ 46%]
chandra_aca/tests/test_dark_subtract.py ........                                                                                                                                         [ 49%]
chandra_aca/tests/test_drift.py ..............................................                                                                                                           [ 67%]
chandra_aca/tests/test_maude_decom.py .........................                                                                                                                          [ 77%]
chandra_aca/tests/test_planets.py ...............                                                                                                                                        [ 83%]
chandra_aca/tests/test_psf.py ...                                                                                                                                                        [ 84%]
chandra_aca/tests/test_residuals.py ss...                                                                                                                                                [ 86%]
chandra_aca/tests/test_star_probs.py .................................                                                                                                                   [100%]

======================================================================================= warnings summary =======================================================================================
chandra_aca/chandra_aca/tests/test_residuals.py::test_obc
  /Users/jean/miniforge3/envs/ska3/lib/python3.12/site-packages/django/utils/encoding.py:266: DeprecationWarning: 'locale.getdefaultlocale' is deprecated and slated for removal in Python 3.15. Use setlocale(), getencoding() and getlocale() instead.
    encoding = locale.getdefaultlocale()[1] or 'ascii'

chandra_aca/chandra_aca/tests/test_residuals.py::test_obc
  /Users/jean/miniforge3/envs/ska3/lib/python3.12/site-packages/django/http/request.py:1: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
    import cgi

chandra_aca/chandra_aca/tests/test_residuals.py::test_obc
chandra_aca/chandra_aca/tests/test_residuals.py::test_obc
  /Users/jean/miniforge3/envs/ska3/lib/python3.12/site-packages/bs4/builder/_lxml.py:124: DeprecationWarning: The 'strip_cdata' option of HTMLParser() has never done anything and will eventually be removed.
    parser = parser(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= 248 passed, 2 skipped, 4 warnings in 45.95s ==========================================================================
(ska3) flame:chandra_aca jean$ git rev-parse HEAD
52661a12d16081dc723b443dd870db2c569fb54c

Functional tests

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR adds an optional drift_pars keyword argument to the get_aca_offsets and get_fid_offset functions so that new drift models can be tested without modifying the flight models. It also updates the tests to exercise both the default behavior and the explicit provision of drift parameters, and bumps the ruff version in the pre-commit configuration.

Reviewed Changes

File Description
chandra_aca/tests/test_drift.py Updated tests to parameterize drift_pars usage and added drift model info.
chandra_aca/drift.py Updated function signatures to include the optional drift_pars argument.
.pre-commit-config.yaml Upgraded the ruff hook version from v0.9.0 to v0.9.9.

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

@taldcroft taldcroft merged commit ecb388d into master Mar 19, 2025
2 checks passed
@taldcroft taldcroft deleted the add-drift-pars-kwargs branch March 19, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants