示例#1
0
def create_griddata_from_array(
        data: numpy.array, grid_wcs: WCS, projection_wcs: WCS,
        polarisation_frame: PolarisationFrame) -> GridData:
    """ Create a griddata from an array and wcs's
    
    The griddata has axes [chan, pol, z, y, x] where z, y, x are spatial axes in either sky or Fourier plane. The
    order in the WCS is reversed so the grid_WCS describes UU, VV, WW, STOKES, FREQ axes
    
    Griddata holds the original sky plane projection in the projection_wcs.

    :param data: Numpy.array
    :param grid_wcs: Grid world coordinate system
    :param projection_wcs: Projection world coordinate system
    :param polarisation_frame: Polarisation Frame
    :return: GridData
    
    """
    fgriddata = GridData()
    fgriddata.polarisation_frame = polarisation_frame

    fgriddata.data = data
    fgriddata.grid_wcs = grid_wcs.deepcopy()
    fgriddata.projection_wcs = projection_wcs.deepcopy()

    if griddata_sizeof(fgriddata) >= 1.0:
        log.debug(
            "create_griddata_from_array: created %s image of shape %s, size %.3f (GB)"
            % (fgriddata.data.dtype, str(
                fgriddata.shape), griddata_sizeof(fgriddata)))

    assert isinstance(fgriddata, GridData), "Type is %s" % type(fgriddata)
    return fgriddata
示例#2
0
def copy_griddata(gd):
    """ Copy griddata
    
    :param gd:
    :return:
    """
    assert isinstance(gd, GridData), gd
    newgd = GridData()
    newgd.polarisation_frame = gd.polarisation_frame
    newgd.data = copy.deepcopy(gd.data)
    if gd.grid_wcs is None:
        newgd.grid_wcs = None
    else:
        newgd.grid_wcs = copy.deepcopy(gd.grid_wcs)
    if gd.projection_wcs is None:
        newgd.projection_wcs = None
    else:
        newgd.projection_wcs = copy.deepcopy(gd.projection_wcs)
    if griddata_sizeof(newgd) >= 1.0:
        log.debug("copy_image: copied %s image of shape %s, size %.3f (GB)" %
                  (newgd.data.dtype, str(newgd.shape), griddata_sizeof(newgd)))
    assert type(newgd) == GridData
    return newgd