def test_raster_overlap(self): m31original = create_test_image(polarisation_frame=PolarisationFrame('stokesI')) assert numpy.max(numpy.abs(m31original.data)), "Original is empty" flat = create_empty_image_like(m31original) for nraster, overlap in [(1, 0), (1, 16), (4, 8), (4, 16), (8, 8), (16, 4), (9, 5)]: m31model = create_test_image(polarisation_frame=PolarisationFrame('stokesI')) for patch, flat_patch in zip(image_raster_iter(m31model, facets=nraster, overlap=overlap), image_raster_iter(flat, facets=nraster, overlap=overlap)): patch.data *= 2.0 flat_patch.data[...] += 1.0 assert numpy.max(numpy.abs(m31model.data)), "Raster is empty for %d" % nraster
def test_raster_exception(self): m31original = create_test_image(polarisation_frame=PolarisationFrame('stokesI')) assert numpy.max(numpy.abs(m31original.data)), "Original is empty" for nraster, overlap in [(-1, -1), (-1, 0), (2, 128), (1e6, 127)]: with self.assertRaises(AssertionError) as context: m31model = create_test_image(polarisation_frame=PolarisationFrame('stokesI')) for patch in image_raster_iter(m31model, facets=nraster, overlap=overlap): patch.data *= 2.0
def test_raster(self): m31original = create_test_image(polarisation_frame=PolarisationFrame('stokesI')) assert numpy.max(numpy.abs(m31original.data)), "Original is empty" for nraster in [1, 2, 4, 8, 9]: m31model = create_test_image(polarisation_frame=PolarisationFrame('stokesI')) for patch in image_raster_iter(m31model, facets=nraster): assert patch.data.shape[3] == (m31model.data.shape[3] // nraster), \ "Number of pixels in each patch: %d not as expected: %d" % (patch.data.shape[3], (m31model.data.shape[3] // nraster)) assert patch.data.shape[2] == (m31model.data.shape[2] // nraster), \ "Number of pixels in each patch: %d not as expected: %d" % (patch.data.shape[2], (m31model.data.shape[2] // nraster)) patch.data *= 2.0 diff = m31model.data - 2.0 * m31original.data assert numpy.max(numpy.abs(m31model.data)), "Raster is empty for %d" % nraster assert numpy.max(numpy.abs(diff)) == 0.0, "Raster set failed for %d" % nraster