Beispiel #1
0
 def setUp(self):
     self.dir = './test_results'
     os.makedirs(self.dir, exist_ok=True)
     self.niter = 1000
     self.lowcore = create_named_configuration('LOWBD2-CORE')
     self.nchan = 5
     self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7)
     self.frequency = numpy.linspace(0.9e8, 1.1e8, self.nchan)
     self.channel_bandwidth = numpy.array(self.nchan * [self.frequency[1] - self.frequency[0]])
     self.phasecentre = SkyCoord(ra=+0.0 * u.deg, dec=-45.0 * u.deg, frame='icrs', equinox='J2000')
     self.vis = create_visibility(self.lowcore, self.times, self.frequency, self.channel_bandwidth,
                                  phasecentre=self.phasecentre, weight=1.0,
                                  polarisation_frame=PolarisationFrame('stokesI'))
     self.vis.data['vis'] *= 0.0
     
     # Create model
     self.test_model = create_low_test_image_from_gleam(npixel=512, cellsize=0.001,
                                                        phasecentre=self.vis.phasecentre,
                                                        frequency=self.frequency,
                                                        channel_bandwidth=self.channel_bandwidth)
     beam = create_low_test_beam(self.test_model)
     export_image_to_fits(beam, "%s/test_deconvolve_msmfsclean_beam.fits" % self.dir)
     self.test_model.data *= beam.data
     export_image_to_fits(self.test_model, "%s/test_deconvolve_msmfsclean_model.fits" % self.dir)
     self.vis = predict_2d(self.vis, self.test_model)
     assert numpy.max(numpy.abs(self.vis.vis)) > 0.0
     self.model = create_image_from_visibility(self.vis, npixel=512, cellsize=0.001,
                                               polarisation_frame=PolarisationFrame('stokesI'))
     self.dirty, sumwt = invert_2d(self.vis, self.model)
     self.psf, sumwt = invert_2d(self.vis, self.model, dopsf=True)
     export_image_to_fits(self.dirty, "%s/test_deconvolve_msmfsclean_dirty.fits" % self.dir)
     export_image_to_fits(self.psf, "%s/test_deconvolve_msmfsclean_psf.fits" % self.dir)
     window = numpy.ones(shape=self.model.shape, dtype=numpy.bool)
     window[..., 129:384, 129:384] = True
     self.innerquarter = create_image_from_array(window, self.model.wcs)
Beispiel #2
0
def gleam_model_serial_bag(npixel=512,
                           frequency=[1e8],
                           channel_bandwidth=[1e6],
                           cellsize=0.001,
                           phasecentre=SkyCoord(ra=+30.0 * u.deg,
                                                dec=-60.0 * u.deg,
                                                frame='icrs',
                                                equinox='J2000'),
                           applybeam=True,
                           polarisation_frame=PolarisationFrame("stokesI"),
                           **kwargs):
    """Bag to create GLEAM model, inner loop serial
    
    :param npixel:
    :param frequency:
    :param channel_bandwidth:
    :param cellsize:
    :param phasecentre:
    :param applybeam:
    :param polarisation_frame:
    :return:
    """
    return bag.from_sequence([{
        'image':
        create_low_test_image_from_gleam(npixel=npixel,
                                         frequency=frequency,
                                         channel_bandwidth=channel_bandwidth,
                                         cellsize=cellsize,
                                         phasecentre=phasecentre,
                                         applybeam=applybeam,
                                         polarisation_frame=polarisation_frame,
                                         **kwargs),
        'freqwin':
        chan
    } for chan, freq in enumerate(frequency)])
Beispiel #3
0
 def test_get_frequency_map_gleam(self):
     self.model = create_low_test_image_from_gleam(
         npixel=512,
         cellsize=0.001,
         frequency=self.frequency,
         channel_bandwidth=self.channel_bandwidth)
     spectral_mode, vfrequency_map = get_frequency_map(self.vis, self.model)
     assert numpy.max(vfrequency_map) == self.model.nchan - 1
     assert spectral_mode == 'channel'
Beispiel #4
0
 def calculate_gleam_model(vis):
     model = create_low_test_image_from_gleam(
         npixel=npixel,
         frequency=frequency,
         channel_bandwidth=channel_bandwidth,
         cellsize=cellsize,
         phasecentre=vis.phasecentre)
     beam = create_low_test_beam(model)
     model.data *= beam.data
     return model
 def test_create_low_test_image_from_gleam(self):
     im = create_low_test_image_from_gleam(npixel=256, cellsize=0.001,
                                           channel_bandwidth=self.channel_bandwidth,
                                           frequency=self.frequency,
                                           phasecentre=self.phasecentre, kind='cubic')
     assert im.data.shape[0] == 3
     assert im.data.shape[1] == 1
     assert im.data.shape[2] == 256
     assert im.data.shape[3] == 256
     export_image_to_fits(im, '%s/test_low_gleam.fits' % (self.dir))
Beispiel #6
0
 def test_calculate_image_frequency_moments(self):
     frequency = numpy.linspace(0.9e8, 1.1e8, 9)
     cube = create_low_test_image_from_gleam(npixel=512, cellsize=0.0001, frequency=frequency)
     log.debug(export_image_to_fits(cube, fitsfile='%s/test_moments_cube.fits' % (self.dir)))
     original_cube = copy_image(cube)
     moment_cube = calculate_image_frequency_moments(cube, nmoments=3)
     log.debug(export_image_to_fits(moment_cube, fitsfile='%s/test_moments_moment_cube.fits' % (self.dir)))
     reconstructed_cube = calculate_image_from_frequency_moments(cube, moment_cube)
     log.debug(export_image_to_fits(reconstructed_cube, fitsfile='%s/test_moments_reconstructed_cube.fits' % (
         self.dir)))
     error = numpy.std(reconstructed_cube.data - original_cube.data)
     assert error < 0.2
Beispiel #7
0
 def test_create_low_test_image_from_gleam_with_pb(self):
     im = create_low_test_image_from_gleam(
         npixel=256,
         cellsize=0.001,
         channel_bandwidth=self.channel_bandwidth,
         frequency=self.frequency,
         phasecentre=self.phasecentre,
         kind='cubic',
         applybeam=True,
         flux_limit=1.0)
     assert im.data.shape[0] == 3
     assert im.data.shape[1] == 1
     assert im.data.shape[2] == 256
     assert im.data.shape[3] == 256
     export_image_to_fits(
         im, '%s/test_test_support_low_gleam_with_pb.fits' % (self.dir))
block_vis = create_blockvisibility(lowcore, times, frequency=frequency, channel_bandwidth=channel_bandwidth,
                     weight=1.0, phasecentre=phasecentre,
                     polarisation_frame=PolarisationFrame("stokesI"))


wprojection_planes=1
advice=advise_wide_field(block_vis, guard_band_image=4.0, delA=0.02,
                             wprojection_planes=wprojection_planes)

vis_slices = advice['vis_slices']
npixel=advice['npixels2']
cellsize=advice['cellsize']


gleam_model = create_low_test_image_from_gleam(npixel=npixel, frequency=frequency,
    channel_bandwidth=channel_bandwidth, cellsize=cellsize, phasecentre=phasecentre, flux_limit = 1.0, applybeam=True)


predicted_vis = predict_function(block_vis, gleam_model, vis_slices=51, context='wstack')
#print("np.sum(predicted_vis.data): ", numpy.sum(predicted_vis.data['vis']))
block_vis=convert_visibility_to_blockvisibility(predicted_vis)
#print("np.sum(block_vis.data): ", numpy.sum(block_vis.data['vis']))

#print("nchan npol nants ", block_vis.nchan, block_vis.npol, block_vis.nants)
#print("uvw", block_vis.uvw, numpy.sum(block_vis.uvw))
#print("vis", block_vis.vis, numpy.sum(block_vis.vis))
#print("weight", block_vis.weight, numpy.sum(block_vis.weight))
#print("time", block_vis.time, numpy.sum(block_vis.time))
#print("integration_time", block_vis.integration_time, numpy.sum(block_vis.integration_time))
#print("nvis, size", block_vis.nvis, block_vis.size())
Beispiel #9
0
 def create(request):
     return {
         'image': create_low_test_image_from_gleam(**(request[1])),
         'freqwin': request[0]
     }