def pol_map(self): if hasattr(self, '_pol_map'): return self._pol_map else: self._pol_map = sakura.empty_aligned((self.npol, ), dtype=numpy.int32) self._pol_map[:] = numpy.arange(self.npol) return self._pol_map
def get_result(self): # remove margin from grid array grid_shape = self.grid_real.shape outgrid_shape = (grid_shape[0] - 2 * self.convsupport, grid_shape[1] - 2 * self.convsupport, grid_shape[2], grid_shape[3]) grid_real = self.grid_real[self.convsupport:-self.convsupport, self.convsupport:-self.convsupport, :, :] grid_imag = self.grid_imag[self.convsupport:-self.convsupport, self.convsupport:-self.convsupport, :, :] wgrid_real = self.wgrid_real[self.convsupport:-self.convsupport, self.convsupport:-self.convsupport, :, :] wgrid_imag = self.wgrid_imag[self.convsupport:-self.convsupport, self.convsupport:-self.convsupport, :, :] assert grid_real.shape == outgrid_shape assert grid_imag.shape == outgrid_shape assert wgrid_real.shape == outgrid_shape assert wgrid_imag.shape == outgrid_shape nonzero_real = numpy.where(wgrid_real != 0.0) nonzero_imag = numpy.where(wgrid_imag != 0.0) uvgrid_real = sakura.empty_aligned(outgrid_shape, dtype=numpy.float64) uvgrid_imag = sakura.empty_aligned(outgrid_shape, dtype=numpy.float64) uvgrid_wreal = sakura.empty_aligned(outgrid_shape, dtype=numpy.float64) uvgrid_wreal[:] = wgrid_real if numpy.all(wgrid_real == wgrid_imag): uvgrid_wimag = None else: uvgrid_wimag = sakura.empty_aligned(outgrid_shape, dtype=numpy.float64) uvgrid_wimag[:] = wgrid_imag uvgrid_real[:] = 0.0 uvgrid_imag[:] = 0.0 uvgrid_real[ nonzero_real] = grid_real[nonzero_real] / wgrid_real[nonzero_real] uvgrid_imag[ nonzero_imag] = grid_imag[nonzero_imag] / wgrid_imag[nonzero_imag] result = datacontainer.GriddedVisibilityStorage( uvgrid_real, uvgrid_imag, uvgrid_wreal, uvgrid_wimag, self.num_ws) return result
def _init(self): # grid parameter from visibility selection parameter # sel = self.visparam.as_msindex() # poldd = sel['poldd'] # with casa.OpenTableForRead(os.path.join(self.visparam.vis, # 'DATA_DESCRIPTION')) as tb: # tsel = tb.selectrows(poldd) # polids = numpy.unique(tsel.getcol('POLARIZATION_ID')) # tsel.close() # with casa.OpenTableForRead(os.path.join(self.visparam.vis, # 'POLARIZATION')) as tb: # tsel = tb.selectrows(polids) # num_corrs = numpy.unique(tsel.getcol('NUM_CORR')) # tsel.close() # assert len(num_corrs) == 1 # self.npol = num_corrs[0] # so far npol should be 1 (only I) self.npol = 1 # grid parameter from image parameter uvgridconfig = self.imageparam.uvgridconfig self.cellu = uvgridconfig.cellu self.cellv = uvgridconfig.cellv self.nu = uvgridconfig.nu self.nv = uvgridconfig.nv self.offsetu = uvgridconfig.offsetu self.offsetv = uvgridconfig.offsetv # create storage # require margin based on convsupport parameter since # sakura gridding function ignore convsupport-pixels # from spatial edges wsshape = (self.npol, self.nchan) self.wsum_real = sakura.empty_aligned(wsshape, dtype=numpy.float64) self.wsum_imag = sakura.empty_aligned(wsshape, dtype=numpy.float64) gridshape = (self.nv + 2 * self.convsupport, self.nu + 2 * self.convsupport, self.npol, self.nchan) self.grid_real = sakura.empty_aligned(gridshape, dtype=numpy.float32) self.grid_imag = sakura.empty_aligned(gridshape, dtype=numpy.float32) self.wgrid_real = sakura.empty_aligned(gridshape, dtype=numpy.float32) self.wgrid_imag = sakura.empty_aligned(gridshape, dtype=numpy.float32) # zero clear self._clear_grid() # number of ws to be gridded self.num_ws = 0
def allocate(convsupport, convsampling, init=False): n = (convsupport + 1) * convsampling * 2 gf = sakura.empty_aligned((n, ), dtype=numpy.float32) if init: gf[:] = 0.0 return gf