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

Fix lon_pole units in VaryingCelestialTransform #225

Merged
merged 21 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,31 @@ on:
- push
- pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
coverage: 'codecov'
envs: |
- linux: py39
- macos: py311
- linux: py310-devdeps
- linux: py311
- windows: py310
- macos: py39
- linux: build_docs
pytest: false
nabobalis marked this conversation as resolved.
Show resolved Hide resolved
libraries:
apt:
- graphviz
- macos: py310-devdeps
- windows: py38-oldestdeps
coverage: 'codecov'

publish:
needs: [tests]
if: github.event_name != 'pull_request'
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@main
with:
test_extras: tests
test_command: pytest --pyargs dkist
Expand Down
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,14 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

### VScode: https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore
.vscode/*
### VSCode
.vscode/

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### Extra Python Items and SunPy Specific
.hypothesis
Expand All @@ -214,7 +220,7 @@ examples/**/*.asdf
# This is incase you run the figure tests
figure_test_images*

### Pycharm(?)
### Pycharm
.idea

# Release script
Expand Down
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v4.4.0
hooks:
- id: check-yaml
- id: check-ast
Expand All @@ -14,14 +14,16 @@ repos:
files: ".*.py"
- id: end-of-file-fixer
exclude: ".*(.fits|.asdf)"
- id: flake8
additional_dependencies: [flake8-docstrings]
args: ['--select', 'E101,W191,W291,W292,W293,W391,E111,E112,E113,E901,E902,F401']
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings]
args: ['--select', 'E101,W191,W291,W292,W293,W391,E111,E112,E113,E901,E902,F401']
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
additional_dependencies: [toml]

ci:
autofix_prs: false
4 changes: 3 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ formats:
- pdf

build:
os: ubuntu-20.04
os: ubuntu-22.04
apt_packages:
- graphviz
tools:
python: "3.10"

Expand Down
70 changes: 0 additions & 70 deletions azure-pipelines.yml

This file was deleted.

2 changes: 2 additions & 0 deletions changelog/225.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Unit for ``lon_pole`` was set to the spatial unit of the input parameters within `~dkist.wcs.models.VaryingCelestialTransform`.
It is now fixed to always be degrees.
3 changes: 2 additions & 1 deletion dkist/wcs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def generate_celestial_transform(crpix: Union[Iterable[float], u.Quantity],
if lon_pole is None:
lon_pole = 180
if spatial_unit is not None:
lon_pole = u.Quantity(lon_pole, unit=spatial_unit)
# Lon pole should always have the units of degrees
lon_pole = u.Quantity(lon_pole, unit=u.deg)

# Make translation unitful if all parameters have units
translation = (0, 0)
Expand Down
13 changes: 13 additions & 0 deletions dkist/wcs/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ def test_generate_celestial_unitless():
assert u.allclose(shift1.offset, 0)


def test_varying_transform_no_lon_pole_unit():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you prefer, I can remove this test and add the unit check to the test below and remove the lon_pole argument in the VaryingCelestialTransform call.

I can also add a test for generate_celestial_transform instead? Or both?

varying_matrix_lt = [rotation_matrix(a)[:2, :2] for a in np.linspace(0, 90, 10)] * u.arcsec
# Without a lon_pole passed, the transform was originally setting
# the unit for it to be the same as crval, which is wrong.
vct = VaryingCelestialTransform(crpix=(5, 5) * u.pix,
cdelt=(1, 1) * u.arcsec/u.pix,
crval_table=(0, 0) * u.arcsec,
pc_table=varying_matrix_lt,
)
trans5 = vct.transform_at_index(5)
assert isinstance(trans5, CompoundModel)
assert u.allclose(trans5.right.lon_pole, 180 * u.deg)

def test_varying_transform_pc():
varying_matrix_lt = [rotation_matrix(a)[:2, :2] for a in np.linspace(0, 90, 10)] * u.arcsec

Expand Down
14 changes: 7 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,20 @@
(None, "http://www.astropy.org/astropy-data/intersphinx/numpy.inv"),
),
"scipy": (
"https://docs.scipy.org/doc/scipy/reference/",
"https://docs.scipy.org/doc/scipy/",
(None, "http://www.astropy.org/astropy-data/intersphinx/scipy.inv"),
),
"matplotlib": (
"https://matplotlib.org/",
"https://matplotlib.org/stable/",
(None, "http://www.astropy.org/astropy-data/intersphinx/matplotlib.inv"),
),
"astropy": ("https://docs.astropy.org/en/stable/", None),
"parfive": ("https://parfive.readthedocs.io/en/stable/", None),
"sunpy": ('http://docs.sunpy.org/en/latest/', None),
"ndcube": ('http://docs.sunpy.org/projects/ndcube/en/latest/', None),
"gwcs": ('http://gwcs.readthedocs.io/en/latest/', None),
"asdf": ('http://asdf.readthedocs.io/en/latest/', None),
"dask": ('http://dask.pydata.org/en/latest/', None),
"sunpy": ('https://docs.sunpy.org/en/stable/', None),
"ndcube": ('https://docs.sunpy.org/projects/ndcube/en/latest/', None),
"gwcs": ('https://gwcs.readthedocs.io/en/latest/', None),
"asdf": ('https://asdf.readthedocs.io/en/latest/', None),
"dask": ('https://dask.pydata.org/en/latest/', None),
}

# -- Options for HTML output ---------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ classifiers =
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11

[options]
python_requires = >=3.8
Expand Down Expand Up @@ -52,7 +53,6 @@ docs =
sphinx-gallery
sphinx-changelog
pytest
towncrier
sphinx_autodoc_typehints
dkist-sphinx-theme>=1.0.0rc6

Expand All @@ -74,7 +74,7 @@ show_response = 1
[tool:pytest]
minversion = 3.0
testpaths = "dkist" "docs"
norecursedirs = ".tox" "build" "docs[\/]_build" "docs[\/]generated" "*.egg-info" "examples"
norecursedirs = ".tox" "build" "docs[\/]_build" "docs[\/]generated" "*.egg-info" "examples" ".history"
doctest_plus = enabled
doctest_optionflags = NORMALIZE_WHITESPACE FLOAT_CMP ELLIPSIS
addopts = --doctest-ignore-import-errors
Expand Down
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ passenv = CC
setenv =
MPLBACKEND = agg
COLUMNS = 180
PYTEST_COMMAND = pytest {tty:--color=yes} --cov=dkist --cov-config={toxinidir}/setup.cfg --verbose --timeout=120
PYTEST_COMMAND = pytest {tty:--color=yes} --cov=dkist --cov-config={toxinidir}/setup.cfg --verbose
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scipy-wheels-nightly/simple
extras = tests
commands =
Expand All @@ -21,9 +21,6 @@ description =
devdeps: with the latest developer version of key dependencies
oldestdeps: with the oldest supported version of all dependencies
deps =
# We currently require a development version of astropy for this to all work
pytest-timeout

# Devdeps installs our key dependancies from git to ensure we catch future
# breaking changes before they make it to release
devdeps: astropy>=0.0.dev0
Expand Down Expand Up @@ -51,9 +48,13 @@ deps =
oldestdeps: setuptools<60 # Use older setuptools to prevent distutils warning

[testenv:build_docs]
changedir = docs
extras = docs
description = invoke sphinx-build to build the HTML docs
commands = sphinx-build docs docs/_build/html -W -b html
description = Invoke sphinx-build to build the HTML docs
commands =
pip freeze --all --no-input
sphinx-build -j auto --color -W --keep-going -b html -d _build/.doctrees . _build/html {posargs}
python -c 'import pathlib; print("Documentation available under file://\{0\}".format(pathlib.Path(r"{toxinidir}") / "docs" / "_build" / "index.html"))'

[testenv:codestyle]
skip_install = true
Expand Down