gwcs
gwcs copied to clipboard
Prevent creation of WCS with (or insertion of) duplicate frames
In https://github.com/spacetelescope/jwst/pull/2629#discussion_r221419842 @nden said:
all frame names in the pipeline must be unique
In this issue I propose that this be enforced when the WCS
object is created or its pipeline modified.
Currently, when using the standard example from the [gWCS
docs] modified to have two identical frames, it does not raise an exception: wcsobj = wcs.WCS([('det', det2sky), ('det', det2sky), ('sky', None)])
. But the code does crash when attempting to evaluate forward transform:
In [19]: wcsobj(10,10)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-19-a8018916eccf> in <module>()
----> 1 wcsobj(10,10)
~/.../lib/python3.5/site-packages/gwcs/wcs.py in __call__(self, *args, **kwargs)
242 kwargs['fill_value'] = np.nan
243
--> 244 if self.bounding_box is not None:
245 # Currently compound models do not attempt to combine individual model
246 # bounding boxes. Get the forward transform and assign the ounding_box to it
~/.../lib/python3.5/site-packages/gwcs/wcs.py in bounding_box(self)
456 transform_0 = self.get_transform(frames[0], frames[1])
457 try:
--> 458 bb = transform_0.bounding_box
459 except NotImplementedError:
460 return None
AttributeError: 'NoneType' object has no attribute 'bounding_box'
However, this 'bounding_box'
error is not intuitive or directly pointing to the underlying issue.
This ticket is now being tracked at AL-28