コード例 #1
0
def copy_skymodel(sm):
    """ Copy a sky model

    :param sm: SkyModel to be copied
    :return: SkyModel
    """
    if sm.components is not None:
        newcomps = [copy_skycomponent(comp) for comp in sm.components]
    else:
        newcomps = None

    if sm.image is not None:
        newimage = copy_image(sm.image)
    else:
        newimage = None

    if sm.mask is not None:
        newmask = copy_image(sm.mask)
    else:
        newmask = None

    if sm.gaintable is not None:
        newgt = copy_gaintable(sm.gaintable)
    else:
        newgt = None

    return SkyModel(components=newcomps,
                    image=newimage,
                    gaintable=newgt,
                    mask=newmask,
                    fixed=sm.fixed)
コード例 #2
0
def initialize_skymodel_voronoi(model, comps, gt=None):
    """Create a skymodel by Voronoi partitioning of the components, fill with components
    
    :param model: Model image
    :param comps: Skycomponents
    :param gt: Gaintable
    :return:

    For example::

        gaintable = create_gaintable_from_blockvisibility(block_vis)
        mpccal_skymodel = initialize_skymodel_voronoi(model, ical_components, gaintable)

    """
    skymodel_images = list()
    for i, mask in enumerate(image_voronoi_iter(model, comps)):
        im = copy_image(model)
        im.data *= mask.data
        if gt is not None:
            newgt = copy_gaintable(gt)
            newgt.phasecentre = comps[i].direction
        else:
            newgt = None

        skymodel_images.append(
            SkyModel(image=im, components=None, gaintable=newgt, mask=mask))

    return skymodel_images
コード例 #3
0
def expand_skymodel_by_skycomponents(sm, **kwargs):
    """ Expand a sky model so that all components and the image are in separate skymodels
    
    The mask and gaintable are taken to apply for all new skymodels.
    
    :param sm: SkyModel
    :return: List of SkyModels
    """
    result = [
        SkyModel(components=[comp],
                 image=None,
                 gaintable=copy_gaintable(sm.gaintable),
                 mask=copy_image(sm.mask),
                 fixed=sm.fixed) for comp in sm.components
    ]
    if sm.image is not None:
        result.append(
            SkyModel(components=None,
                     image=copy_image(sm.image),
                     gaintable=copy_gaintable(sm.gaintable),
                     mask=copy_image(sm.mask),
                     fixed=sm.fixed))
    return result