@@ -216,7 +216,8 @@ def resample_many_to_many(self):
216216 img = datamodels .open (img )
217217
218218 input_pixflux_area = img .meta .photometry .pixelarea_steradians
219- if input_pixflux_area :
219+ if (input_pixflux_area and
220+ 'SPECTRAL' not in img .meta .wcs .output_frame .axes_type ):
220221 img .meta .wcs .array_shape = img .data .shape
221222 input_pixel_area = _compute_image_pixel_area (img .meta .wcs )
222223 if input_pixel_area is None :
@@ -299,7 +300,8 @@ def resample_many_to_one(self):
299300 log .info ("Resampling science data" )
300301 for img in self .input_models :
301302 input_pixflux_area = img .meta .photometry .pixelarea_steradians
302- if input_pixflux_area :
303+ if (input_pixflux_area and
304+ 'SPECTRAL' not in img .meta .wcs .output_frame .axes_type ):
303305 img .meta .wcs .array_shape = img .data .shape
304306 input_pixel_area = _compute_image_pixel_area (img .meta .wcs )
305307 if input_pixel_area is None :
@@ -684,7 +686,6 @@ def _get_boundary_points(xmin, xmax, ymin, ymax, dx=None, dy=None, shrink=0):
684686def _compute_image_pixel_area (wcs ):
685687 """ Computes pixel area in steradians.
686688 """
687-
688689 if wcs .array_shape is None :
689690 raise ValueError ("WCS must have array_shape attribute set." )
690691
@@ -748,6 +749,12 @@ def _compute_image_pixel_area(wcs):
748749 wcenter = (world [spatial_idx [0 ]], world [spatial_idx [1 ]])
749750
750751 sky_area = SphericalPolygon .from_radec (ra , dec , center = wcenter ).area ()
752+ if sky_area > 2 * np .pi :
753+ log .warning (
754+ "Unexpectedly large computed sky area for an image. "
755+ "Setting area to: 4*Pi - area"
756+ )
757+ sky_area = 4 * np .pi - sky_area
751758 pix_area = sky_area / image_area
752759
753760 return pix_area
0 commit comments