Skip to content

Catch a (0,) dimensionality issue on spectral axis in beamcon_3D#88

Merged
AlecThomson merged 1 commit into
AlecThomson:test-0specfrom
tjgalvin:test-0spec
Apr 20, 2026
Merged

Catch a (0,) dimensionality issue on spectral axis in beamcon_3D#88
AlecThomson merged 1 commit into
AlecThomson:test-0specfrom
tjgalvin:test-0spec

Conversation

@tjgalvin
Copy link
Copy Markdown
Contributor

I recently installed a new environment for some racs-all testing and started to run into a strange issue.

File "/datasets/work/jones-storage/work/miniconda/miniforge3/envs/flint_racsall/lib/python3.12/site-packages/racs_tools/beamcon_3D.py", line 768, in initfiles
    crpix = int(spec_axis.wcs.crpix)
            ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: only 0-dimensional arrays can be converted to Python scalars

Digging into this is appears as though a numpy array of length 1 is being returned in the spec_axis.wcs.crpix WCS instance. The attempt to int therefore fails, even though the array was of length 1. I am not sure if this was a change in numpy or astropy, as it honestly could be either. I am relatively certain it is not a fitscube issue as the cube there has gone through the astropy.io.fits infrastructure, and read in as such correctly as well.

This PR has a type check, and if a numpy array is found it is first squeezed before passing through the int typecast. I believe it is a backwards compatible change, i.e. whatever changed in whatever dependency will contrinue to work.

Copy link
Copy Markdown
Owner

@AlecThomson AlecThomson left a comment

Choose a reason for hiding this comment

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

All looks pretty reasonable to me! I'm going to make a slight change from a type check to a scalar check. Any idea which version of astropy+numpy caused this issue?

@AlecThomson AlecThomson changed the base branch from master to test-0spec April 20, 2026 12:50
@AlecThomson AlecThomson merged commit 3ea3cd3 into AlecThomson:test-0spec Apr 20, 2026
7 checks passed
AlecThomson added a commit that referenced this pull request Apr 20, 2026
* additional check around (0,) dim spectral axis (#88)

Co-authored-by: Tim Galvin <gal16b@petrichor-i3.cm.cluster>

* Use scalar test

* Lint

---------

Co-authored-by: tjgalvin <tjgalvin@users.noreply.github.com>
Co-authored-by: Tim Galvin <gal16b@petrichor-i3.cm.cluster>
Co-authored-by: Alec Thomson <alec.thomson@skao.int>
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