Exemplo n.º 1
0
    def degrid(self, coordinates, model, as_grid):
        assert (not as_grid)
        self._update_image_configuration(coordinates, model.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)

        casaimwrap.begin_degrid(self._context, \
            coordinates.dict(), model)

        result = casaimwrap.degrid(self._context, \
            args)

        casaimwrap.end_degrid(self._context)
        self._response_available = True
        # INI: uncommenting the line below so that the result is written to the MS.
        self._ms.putcol(self._data_column, result["data"])
Exemplo n.º 2
0
    def degrid_chunk(self, coordinates, model, as_grid, chunksize):
        assert (not as_grid)
        self._update_image_configuration(coordinates, model.shape)

        casaimwrap.begin_degrid(self._context, \
            coordinates.dict(), model)

        # 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)

            result = casaimwrap.degrid(self._context, \
                args)
            self._ms.putcol(self._data_column, result["data"], start, nrow)

        casaimwrap.end_degrid(self._context)

        self._response_available = True
Exemplo n.º 3
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"])
    def degrid_chunk(self, coordinates, model, as_grid, chunksize):
        assert(not as_grid)
        self._update_image_configuration(coordinates, model.shape)

        casaimwrap.begin_degrid(self._context, \
            coordinates.dict(), model)

	# 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)
     
        	result = casaimwrap.degrid(self._context, \
	            args)
	        self._ms.putcol(self._data_column, result["data"], start, nrow)
          
        casaimwrap.end_degrid(self._context)

        self._response_available = True
    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"])
    def degrid(self, coordinates, model, as_grid):
        assert(not as_grid)
        self._update_image_configuration(coordinates, model.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)

        casaimwrap.begin_degrid(self._context, \
            coordinates.dict(), model)
          
        result = casaimwrap.degrid(self._context, \
            args)
          
        casaimwrap.end_degrid(self._context)
        self._response_available = True
	# INI: uncommenting the line below so that the result is written to the MS.
        self._ms.putcol(self._data_column, result["data"])