@@ -561,9 +561,29 @@ def test_asExposure(self):
561561 geom .Extent2I (self .inner_size_x , self .inner_size_y ),
562562 )
563563 index = Index2D (x = x , y = y )
564- self .assertImagesEqual (exposure .image [bbox ], self .exposures [index ].image [bbox ])
565- self .assertImagesEqual (exposure .variance [bbox ], self .exposures [index ].variance [bbox ])
566- self .assertImagesEqual (exposure .mask [bbox ], self .exposures [index ].mask [bbox ])
564+ self .assertMaskedImagesEqual (exposure [bbox ], self .exposures [index ][bbox ])
565+
566+ self .assertMaskedImagesEqual (self .stitched_coadd .asExposure (noise_index = None ), exposure )
567+ for noise_index in range (self .n_noise_realizations ):
568+ noise_exposure = self .stitched_coadd .asExposure (noise_index = noise_index )
569+
570+ self .assertImagesEqual (noise_exposure .variance , exposure .variance )
571+ self .assertImagesEqual (noise_exposure .mask , exposure .mask )
572+
573+ for y in range (self .ny ):
574+ for x in range (self .nx ):
575+ bbox = geom .Box2I (
576+ geom .Point2I (self .x0 + x * self .inner_size_x , self .y0 + y * self .inner_size_y ),
577+ geom .Extent2I (self .inner_size_x , self .inner_size_y ),
578+ )
579+ index = Index2D (x = x , y = y )
580+ self .assertImagesEqual (
581+ noise_exposure .image [bbox ],
582+ self .multiple_cell_coadd .cells [index ].outer .noise_realizations [noise_index ][bbox ],
583+ )
584+
585+ with self .assertRaises (ValueError ):
586+ self .stitched_coadd .asExposure (noise_index = self .n_noise_realizations )
567587
568588 def test_aperture_correction (self ):
569589 """Test the aperture correction values are what we expect."""
@@ -613,9 +633,7 @@ def test_fits(self):
613633 read_exposure = ExposureF .readFits (filename ) # Test the readFits method.
614634
615635 # Test that the image planes are identical.
616- self .assertImagesEqual (read_exposure .image , write_exposure .image )
617- self .assertImagesEqual (read_exposure .variance , write_exposure .variance )
618- self .assertImagesEqual (read_exposure .mask , write_exposure .mask )
636+ self .assertMaskedImagesEqual (read_exposure , write_exposure )
619637
620638 # Test the PSF images in the StitchedPsf.
621639 for index in write_exposure .psf .images .indices ():
0 commit comments