Skip to content

Commit

Permalink
Merge branch 'main' into ci/separate_devdeps
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett authored Oct 13, 2023
2 parents 712f0c0 + 2251433 commit be55937
Show file tree
Hide file tree
Showing 13 changed files with 1,377 additions and 11 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
coverage/
cov.xml

# Translations
*.mo
Expand Down Expand Up @@ -86,7 +88,7 @@ ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down Expand Up @@ -143,4 +145,7 @@ src/stcal/_version.py

# auto-generated API docs
docs/source/api
.DS_Store
.DS_Store

# VSCode stuff
.vscode
13 changes: 13 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
1.4.5 (unreleased)
==================

- Added ``alignment`` sub-package. [#179]

Changes to API
--------------

Expand Down Expand Up @@ -88,6 +90,17 @@ Bug Fixes
jump
~~~~

- Added setting of number_extended_events for non-multiprocessing
mode. This is the value that is put into the header keyword EXTNCRS. [#178]

1.4.1 (2023-06-29)

Bug Fixes
---------

jump
~~~~

- Added statement to prevent the number of cores used in multiprocessing from
being larger than the number of rows. This was causing some CI tests to fail. [#176]

Expand Down
2 changes: 2 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
BUILDDIR = _build
APIDIR = api

# Internal variables
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
Expand All @@ -25,6 +26,7 @@ help:

clean:
-rm -rf $(BUILDDIR)/*
-rm -rf $(APIDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
Expand Down
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
stcall API
stcal API
==========

.. automodapi:: stcal
34 changes: 28 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
from pathlib import Path

import stsci_rtd_theme

if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib


def setup(app):
try:
Expand All @@ -27,7 +28,7 @@ def setup(app):
# values here:
with open(REPO_ROOT / "pyproject.toml", "rb") as configuration_file:
conf = tomllib.load(configuration_file)
setup_metadata = conf['project']
setup_metadata = conf["project"]

project = setup_metadata["name"]
primary_author = setup_metadata["authors"][0]
Expand All @@ -38,19 +39,40 @@ def setup(app):
version = package.__version__.split("-", 1)[0]
release = package.__version__

# Configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"numpy": ("https://numpy.org/devdocs", None),
"scipy": ("http://scipy.github.io/devdocs", None),
"matplotlib": ("https://matplotlib.org/stable", None),
"gwcs": ("https://gwcs.readthedocs.io/en/latest/", None),
"astropy": ("https://docs.astropy.org/en/stable/", None),
}

extensions = [
"pytest_doctestplus.sphinx.doctestplus",
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.viewcode",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx_automodapi.automodapi",
"numpydoc",
"sphinx_automodapi.automodsumm",
"sphinx_automodapi.autodoc_enhancements",
"sphinx_automodapi.smart_resolver",
"sphinx_asdf",
"sphinx.ext.mathjax",
]

autosummary_generate = True
numpydoc_show_class_members = False
autoclass_content = "both"

html_theme = "stsci_rtd_theme"
html_theme_options = {
"collapse_navigation": True
}
html_theme_options = {"collapse_navigation": True}
html_theme_path = [stsci_rtd_theme.get_html_theme_path()]
html_domain_indices = True
html_sidebars = {"**": ["globaltoc.html", "relations.html", "searchbox.html"]}
Expand Down
4 changes: 4 additions & 0 deletions docs/stcal/alignment/description.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Description
============

This sub-package contains all the modules common to all missions.
12 changes: 12 additions & 0 deletions docs/stcal/alignment/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _alignment:

===============
Alignment Utils
===============

.. toctree::
:maxdepth: 2

description.rst

.. automodapi:: stcal.alignment
1 change: 1 addition & 0 deletions docs/stcal/package_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Package Index

jump/index.rst
ramp_fitting/index.rst
alignment/index.rst
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ dependencies = [
'scipy >=1.6.0',
'numpy >=1.20',
'opencv-python-headless >=4.6.0.66',
'asdf >=2.15.0',
'gwcs >= 0.18.1',
]
dynamic = ['version']

[project.optional-dependencies]
docs = [
'numpydoc',
'packaging >=17',
'sphinx',
'sphinx<7.0.0',
'sphinx-asdf',
'sphinx-astropy',
'sphinx-rtd-theme',
'stsci-rtd-theme',
'tomli; python_version <"3.11"',
'tomli; python_version <="3.11"',
]
test = [
'psutil',
Expand Down
1 change: 1 addition & 0 deletions src/stcal/alignment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .util import * # noqa: F403
40 changes: 40 additions & 0 deletions src/stcal/alignment/resample_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import logging
import numpy as np
from stcal.alignment import util
from gwcs.wcstools import grid_from_bounding_box

log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


def calc_pixmap(in_wcs, out_wcs, shape=None):
"""Return a pixel grid map from input frame to output frame
Parameters
----------
in_wcs : `~astropy.wcs.WCS`
Input WCS objects or transforms.
out_wcs : `~astropy.wcs.WCS` or `~gwcs.wcs.WCS`
output WCS objects or transforms.
shape : tuple, optional
Shape of grid in pixels. The default is None.
Returns
-------
pixmap : ndarray of shape (xdim, ydim, 2)
Reprojected pixel grid map. `pixmap[xin, yin]` returns `xout,
yout` indices in the output image.
"""
if shape:
bb = util.wcs_bbox_from_shape(shape)
log.debug("Bounding box from data shape: {}".format(bb))
else:
bb = util.wcs_bbox_from_shape(in_wcs.pixel_shape)
log.debug("Bounding box from WCS: {}".format(bb))

# creates 2 grids, one with rows of all x values * len(y) rows,
# and the reverse for all y columns
grid = grid_from_bounding_box(bb)
transform_function = util.reproject(in_wcs, out_wcs)
pixmap = np.dstack(transform_function(grid[0], grid[1]))
return pixmap
Loading

0 comments on commit be55937

Please sign in to comment.