diff --git a/gwcs/wcs.py b/gwcs/wcs.py index cb33eae8..2ae714b2 100644 --- a/gwcs/wcs.py +++ b/gwcs/wcs.py @@ -258,15 +258,20 @@ def set_transform(self, from_frame, to_frame, transform): def forward_transform(self): """ Return the total forward transform - from input to output coordinate frame. - """ - - if self._pipeline: - #return functools.reduce(lambda x, y: x | y, [step[1] for step in self._pipeline[: -1]]) - return functools.reduce(lambda x, y: x | y, [step.transform for step in self._pipeline[:-1]]) - else: + if not self._pipeline: return None + transform = functools.reduce(lambda x, y: x | y, [step.transform for step in self._pipeline[:-1]]) + + if self.bounding_box is not None: + # Currently compound models do not attempt to combine individual model + # bounding boxes. Get the forward transform and assign the bounding_box to it + # before evaluating it. The order Model.bounding_box is reversed. + transform.bounding_box = self.bounding_box + + return transform + @property def backward_transform(self): """ @@ -354,12 +359,6 @@ def __call__(self, *args, **kwargs): if 'fill_value' not in kwargs: kwargs['fill_value'] = np.nan - if self.bounding_box is not None: - # Currently compound models do not attempt to combine individual model - # bounding boxes. Get the forward transform and assign the bounding_box to it - # before evaluating it. The order Model.bounding_box is reversed. - transform.bounding_box = self.bounding_box - result = transform(*args, **kwargs) if with_units: @@ -1287,6 +1286,10 @@ def bounding_box(self): frames = self.available_frames transform_0 = self.get_transform(frames[0], frames[1]) + + if transform_0 is None: + return None + try: bb = transform_0.bounding_box except NotImplementedError: