Skip to content

Commit

Permalink
Release commit created with Cranko.
Browse files Browse the repository at this point in the history
+++ cranko-release-info-v1
[[projects]]
qnames = ["toasty", "pypa"]
version = "0.16.1"
age = 0

+++
  • Loading branch information
cranko committed Jan 27, 2022
2 parents 409a435 + 75835dc commit c9fdc08
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# toasty 0.16.1 (2022-01-27)

- Toasty is now more forgiving with FITS and WCS shapes when tiling FITS data
(#76, @pkgw). In particular, it will behave more correctly when the data and
WCS shapes disagree, and if the data have interesting structure in the
non-celestial axes, Toasty will take the first celestial plane it finds rather
than rejecting the input file.


# toasty 0.16.0 (2022-01-25)

- Add support for some more kinds of longitude arrangements seen in planetary
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_long_desc():

setup_args = dict(
name="toasty", # cranko project-name
version="0.16.0", # cranko project-version
version="0.16.1", # cranko project-version
description="Generate TOAST image tile pyramids from existing image data",
long_description=get_long_desc(),
long_description_content_type="text/markdown",
Expand Down
15 changes: 11 additions & 4 deletions toasty/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ def _load(self, actually_load_data):
wcs = WCS(hdu.header)
shape = hdu.shape

if wcs.naxis >= len(shape):
# Sometimes the WCS defines more axes than are in the data cube;
# this should generally mean that there are virtual coordinate
# axes that we can think of as adding extra size-1 dimensions.
shape = (1,) * (wcs.naxis - len(shape)) + shape

# We need to make sure the data are 2D celestial, since that's
# what our image code and `reproject` (if it's being used) expect.

Expand All @@ -208,16 +214,17 @@ def _load(self, actually_load_data):
for t in full_wcs.get_axis_types()[::-1]
]

for keep, axlen in zip(keep_axes, shape):
for axnum, (keep, axlen) in enumerate(zip(keep_axes, shape)):
if not keep and axlen != 1:
raise Exception(
f"cannot process input `{fits_path}`: found a non-celestial axis with size other than 1"
warnings.warn(
f"taking 0'th plane of non-celestial axis #{axnum} in input `{fits_path}`"
)

# OK, almost there. Are we loading data or just the descriptor?

if actually_load_data:
data = hdu.data
# Reshape in case of extra WCS axes:
data = hdu.data.reshape(shape)

if full_wcs is not None: # need to subset?
data = data[tuple(slice(None) if k else 0 for k in keep_axes)]
Expand Down

0 comments on commit c9fdc08

Please sign in to comment.