-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding stcal-alignment sub-package. (#196)
- Loading branch information
Showing
13 changed files
with
1,377 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
stcall API | ||
stcal API | ||
========== | ||
|
||
.. automodapi:: stcal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ Package Index | |
|
||
jump/index.rst | ||
ramp_fitting/index.rst | ||
alignment/index.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .util import * # noqa: F403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.