コード例 #1
0
    def residual(self, coordinates, model, as_grid):
        assert(not as_grid)
        self._update_image_configuration(coordinates, model.shape)

        # Degrid model.
        model_vis = self._degrid(coordinates, model)

        # Compute residual.
        residual = self._ms.getcol(self._data_column) - model_vis

        # Grid residual.
        args = {}
        args["ANTENNA1"] = self._ms.getcol("ANTENNA1")
        args["ANTENNA2"] = self._ms.getcol("ANTENNA2")
        args["UVW"] = self._ms.getcol("UVW")
        args["TIME"] = self._ms.getcol("TIME")
        args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID")
        args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW")
        args["FLAG"] = self._ms.getcol("FLAG")
        args["IMAGING_WEIGHT"] = numpy.ones(args["FLAG"].shape[:2],
            dtype=numpy.float32)
        args["DATA"] = residual

        casaimwrap.begin_grid(self._context, model.shape, \
            coordinates.dict(), False, args)
        result = casaimwrap.end_grid(self._context, False)
        self._response_available = True

        return (result["image"], result["weight"])
コード例 #2
0
    def grid(self, coordinates, shape, as_grid):
        assert (not as_grid)
        self._update_image_configuration(coordinates, shape)

        args = {}
        args["ANTENNA1"] = self._ms.getcol("ANTENNA1")
        args["ANTENNA2"] = self._ms.getcol("ANTENNA2")
        args["UVW"] = self._ms.getcol("UVW")
        args["TIME"] = self._ms.getcol("TIME")
        args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID")
        args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW")
        args["FLAG"] = self._ms.getcol("FLAG")
        args["IMAGING_WEIGHT_CUBE"] = numpy.ones(args["FLAG"].shape,
                                                 dtype=numpy.float32)
        args["DATA"] = self._ms.getcol(self._data_column)

        # INI: Modified grid in casaimwrap to separate begin_grid, grid and end_grid
        '''casaimwrap.begin_grid(self._context, shape, coordinates.dict(), \
            False, args)
        result = casaimwrap.end_grid(self._context, False)'''

        casaimwrap.begin_grid(self._context, shape, coordinates.dict(), \
            False)
        casaimwrap.grid(self._context, \
            args)
        result = casaimwrap.end_grid(
            self._context,
            False)  # INI: why is this False? Insert proper options here

        self._response_available = True
        return (result["image"], result["weight"])
コード例 #3
0
    def grid(self, coordinates, shape, as_grid):
        assert(not as_grid)
        self._update_image_configuration(coordinates, shape)

        args = {}
        args["ANTENNA1"] = self._ms.getcol("ANTENNA1")
        args["ANTENNA2"] = self._ms.getcol("ANTENNA2")
        args["UVW"] = self._ms.getcol("UVW")
        args["TIME"] = self._ms.getcol("TIME")
        args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID")
        args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW")
        args["FLAG"] = self._ms.getcol("FLAG")
        args["IMAGING_WEIGHT_CUBE"] = numpy.ones(args["FLAG"].shape, dtype=numpy.float32)
        args["DATA"] = self._ms.getcol(self._data_column)

	# INI: Modified grid in casaimwrap to separate begin_grid, grid and end_grid
        '''casaimwrap.begin_grid(self._context, shape, coordinates.dict(), \
            False, args)
        result = casaimwrap.end_grid(self._context, False)'''

        casaimwrap.begin_grid(self._context, shape, coordinates.dict(), \
            False)
        casaimwrap.grid(self._context, \
            args)
        result = casaimwrap.end_grid(self._context, False) # INI: why is this False? Insert proper options here

        self._response_available = True
        return (result["image"], result["weight"])
コード例 #4
0
    def grid_chunk(self, coordinates, shape, as_grid, chunksize):
        assert (not as_grid)
        self._update_image_configuration(coordinates, shape)

        casaimwrap.begin_grid(self._context, shape, coordinates.dict(), \
            False)

        # INI: looping through chunks of data
        nrows = self._ms.nrows()
        lastchunksize = nrows % chunksize
        if lastchunksize > 0:
            nchunks = nrows / chunksize + 1
        else:
            nchunks = nrows / chunksize

        print 'nrows, chunksize, lastchunksize: ', nrows, chunksize, lastchunksize

        for chunk in numpy.arange(nchunks):
            start = chunk * chunksize
            if chunk == nchunks - 1 and lastchunksize > 0:
                nrow = lastchunksize
            else:
                nrow = chunksize

            args = {}
            args["ANTENNA1"] = self._ms.getcol("ANTENNA1", start, nrow)
            args["ANTENNA2"] = self._ms.getcol("ANTENNA2", start, nrow)
            args["UVW"] = self._ms.getcol("UVW", start, nrow)
            args["TIME"] = self._ms.getcol("TIME", start, nrow)
            args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID", start,
                                                    nrow)
            args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW", start, nrow)
            args["FLAG"] = self._ms.getcol("FLAG", start, nrow)
            args["IMAGING_WEIGHT_CUBE"] = numpy.ones(args["FLAG"].shape,
                                                     dtype=numpy.float32)
            args["DATA"] = self._ms.getcol(self._data_column, start, nrow)

            casaimwrap.grid(self._context, \
                args)

        result = casaimwrap.end_grid(
            self._context,
            False)  # INI: why is this False? Insert proper options here

        print "Result is ------------------: ", result

        self._response_available = True
        return (result["image"], result["weight"])
コード例 #5
0
    def grid_chunk(self, coordinates, shape, as_grid, chunksize):
        assert(not as_grid)
        self._update_image_configuration(coordinates, shape)

        casaimwrap.begin_grid(self._context, shape, coordinates.dict(), \
            False)

        # INI: looping through chunks of data
        nrows = self._ms.nrows()
        lastchunksize = nrows % chunksize
        if lastchunksize > 0:
            nchunks = nrows / chunksize + 1
        else:
            nchunks = nrows / chunksize

        print 'nrows, chunksize, lastchunksize: ', nrows, chunksize, lastchunksize

        for chunk in numpy.arange(nchunks):
                start = chunk * chunksize
                if chunk == nchunks-1 and lastchunksize > 0:
                        nrow = lastchunksize
                else:
                        nrow = chunksize

	        args = {}
        	args["ANTENNA1"] = self._ms.getcol("ANTENNA1",start,nrow)
	        args["ANTENNA2"] = self._ms.getcol("ANTENNA2",start,nrow)
        	args["UVW"] = self._ms.getcol("UVW",start,nrow)
	        args["TIME"] = self._ms.getcol("TIME",start,nrow)
        	args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID",start,nrow)
	        args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW",start,nrow)
        	args["FLAG"] = self._ms.getcol("FLAG",start,nrow)
	        args["IMAGING_WEIGHT_CUBE"] = numpy.ones(args["FLAG"].shape, dtype=numpy.float32)
        	args["DATA"] = self._ms.getcol(self._data_column,start,nrow)

	        casaimwrap.grid(self._context, \
        	    args)

        result = casaimwrap.end_grid(self._context, False) # INI: why is this False? Insert proper options here

	print "Result is ------------------: ", result

        self._response_available = True
        return (result["image"], result["weight"])
コード例 #6
0
    def point_spread_function(self, coordinates, shape, as_grid):
        assert(not as_grid)
        self._update_image_configuration(coordinates, shape)

        args = {}
        args["ANTENNA1"] = self._ms.getcol("ANTENNA1")
        args["ANTENNA2"] = self._ms.getcol("ANTENNA2")
        args["UVW"] = self._ms.getcol("UVW")
        args["TIME"] = self._ms.getcol("TIME")
        args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID")
        args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW")
        args["FLAG"] = self._ms.getcol("FLAG")
        args["IMAGING_WEIGHT"] = self.imw.imaging_weight(args["UVW"],
            self.channel_frequency(), args["FLAG"],
            self._ms.getcol("WEIGHT_SPECTRUM"))
        args["DATA"] = numpy.ones(args["FLAG"].shape, dtype=numpy.complex64)

        casaimwrap.begin_grid(self._context, shape, coordinates.dict(),
            True, args)
        result = casaimwrap.end_grid(self._context, False)
        return (result["image"], result["weight"])
コード例 #7
0
    def point_spread_function(self, coordinates, shape, as_grid):
        assert(not as_grid)
        self._update_image_configuration(coordinates, shape)

        args = {}
        args["ANTENNA1"] = self._ms.getcol("ANTENNA1")
        args["ANTENNA2"] = self._ms.getcol("ANTENNA2")
        args["UVW"] = self._ms.getcol("UVW")
        args["TIME"] = self._ms.getcol("TIME")
        args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID")
        args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW")
        args["FLAG"] = self._ms.getcol("FLAG")
        #args["IMAGING_WEIGHT"] = self.imw.imaging_weight(args["UVW"], \
            #self.channel_frequency(), args["FLAG"], self._ms.getcol("WEIGHT_SPECTRUM"))
        args["IMAGING_WEIGHT_CUBE"] = numpy.ones(args["FLAG"].shape, dtype=numpy.float32)
        args["DATA"] = numpy.ones(args["FLAG"].shape, dtype=numpy.complex64)

        casaimwrap.begin_grid(self._context, shape, coordinates.dict(), \
            True, args)
        result = casaimwrap.end_grid(self._context, False)
        return (result["image"], result["weight"])
コード例 #8
0
    def residual(self, coordinates, model, as_grid):
        assert(not as_grid)
        self._update_image_configuration(coordinates, model.shape)

        # Degrid model.
        args = {}
        args["ANTENNA1"] = self._ms.getcol("ANTENNA1")
        args["ANTENNA2"] = self._ms.getcol("ANTENNA2")
        args["UVW"] = self._ms.getcol("UVW")
        args["TIME"] = self._ms.getcol("TIME")
        args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID")
        args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW")
        args["FLAG"] = self._ms.getcol("FLAG")
        args["IMAGING_WEIGHT_CUBE"] = numpy.ones(args["FLAG"].shape, dtype=numpy.float32)

        result = casaimwrap.begin_degrid(self._context, \
            coordinates.dict(), model, args)
        casaimwrap.end_degrid(self._context)

        # Compute residual.
        residual = self._ms.getcol(self._data_column) - result["data"]

        # Grid residual.
        args = {}
        args["ANTENNA1"] = self._ms.getcol("ANTENNA1")
        args["ANTENNA2"] = self._ms.getcol("ANTENNA2")
        args["UVW"] = self._ms.getcol("UVW")
        args["TIME"] = self._ms.getcol("TIME")
        args["TIME_CENTROID"] = self._ms.getcol("TIME_CENTROID")
        args["FLAG_ROW"] = self._ms.getcol("FLAG_ROW")
        args["FLAG"] = self._ms.getcol("FLAG")
        args["IMAGING_WEIGHT_CUBE"] = numpy.ones(args["FLAG"].shape, dtype=numpy.float32)
        args["DATA"] = residual

        casaimwrap.begin_grid(self._context, model.shape, \
            coordinates.dict(), False, args)
        result = casaimwrap.end_grid(self._context, False)
        self._response_available = True

        return (result["image"], result["weight"])