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

ExtraCoords half works if not attached to a NDCube #753

Open
Cadair opened this issue Aug 22, 2024 · 0 comments
Open

ExtraCoords half works if not attached to a NDCube #753

Cadair opened this issue Aug 22, 2024 · 0 comments
Labels
Discussion An issue opened for, or undergoing discussion.

Comments

@Cadair
Copy link
Member

Cadair commented Aug 22, 2024

Describe the bug

I came across this due to this conversation. We should decide what we want the behaviour to be for a standalone ExtraCoords object.

To Reproduce

import astropy.units as u
from ndcube import ExtraCoords

ec = ExtraCoords.from_lookup_tables(('hello', 'bye'),
                                    (1, 1),
                                    (list(range(3)) * u.m,
                                    list(range(3)) * u.keV,
                                    )
                                   )
ec.wcs
<WCS(output_frame=CompositeFrame, input_frame=PixelFrame, forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1')
Outputs: ('y0', 'y1')
Model set size: 1
Expression: [0] & [1]
Components: 
    [0]: <Tabular1D(points=(<Quantity [0., 1., 2.] pix>,), lookup_table=[0. 1. 2.] m)>

    [1]: <Tabular1D(points=(<Quantity [0., 1., 2.] pix>,), lookup_table=[0. 1. 2.] keV)>
Parameters:)>
ec.mapping
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 1
----> 1 ec.mapping

File ~/Git/ndcube/ndcube/extra_coords/extra_coords.py:264, in ExtraCoords.mapping(self)
    261 # The mapping is from the array index (position in the list) to the
    262 # pixel dimensions (numbers in the list)
    263 lts = [list([lt[0]] if isinstance(lt[0], Integral) else lt[0]) for lt in self._lookup_tables]
--> 264 converter = partial(convert_between_array_and_pixel_axes, naxes=len(self._ndcube.shape))
    265 pixel_indicies = [list(converter(np.array(ids))) for ids in lts]
    266 return tuple(reduce(list.__add__, pixel_indicies))

AttributeError: 'NoneType' object has no attribute 'shape'

Screenshots

No response

System Details

No response

Installation method

No response

@Cadair Cadair added bug Discussion An issue opened for, or undergoing discussion. labels Aug 22, 2024
@Cadair Cadair mentioned this issue Aug 22, 2024
@github-actions github-actions bot removed the Bug label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion An issue opened for, or undergoing discussion.
Projects
None yet
Development

No branches or pull requests

1 participant