How to use the tweakwcs.wcsimage.WCSImageCatalog function in tweakwcs

To help you get started, we’ve selected a few tweakwcs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spacetelescope / tweakwcs / tweakwcs / wcsimage.py View on Github external
object.

        Parameters
        ----------
        wcsim: WCSImageCatalog, WCSGroupCatalog, SphericalPolygon
            Another object that should be intersected with this
            `WCSImageCatalog`.

        Returns
        -------
        polygon: SphericalPolygon
            A :py:class:`~spherical_geometry.polygon.SphericalPolygon` that is
            the intersection of this `WCSImageCatalog` and `wcsim`.

        """
        if isinstance(wcsim, (WCSImageCatalog, WCSGroupCatalog)):
            return self._polygon.intersection(wcsim.polygon)
        else:
            return self._polygon.intersection(wcsim)
github spacetelescope / tweakwcs / tweakwcs / imalign.py View on Github external
start = 1
    else:
        start = 0

    if not (hasattr(wcscat, '__iter__') and all(isinstance(wcat, TPWCS)
                                                for wcat in wcscat[start:])):
        raise TypeError("Input 'wcscat' must be either a single TPWCS-derived "
                        " object or a list of TPWCS-derived objects.")

    wcs_im_cats = []
    for wcat in wcscat:
        if wcat.meta.get('catalog', None) is None:
            raise ValueError("Each object in 'wcscat' must have a valid "
                             "catalog.")

        wcs_im_cat = WCSImageCatalog(
            catalog=wcat.meta['catalog'],
            tpwcs=wcat,
            name=wcat.meta.get('name', 'Unknown'),
            group_id=wcat.meta.get('group_id', None)
        )
        wcs_im_cat.fit_status = "FAILED: Unknown error"

        wcs_im_cats.append(wcs_im_cat)

    # check fitgeom:
    fitgeom = fitgeom.lower()
    if fitgeom not in ['shift', 'rscale', 'general']:
        raise ValueError("Unsupported 'fitgeom'. Valid values are: "
                         "'shift', 'rscale', or 'general'")

    if minobj is None:  # pragma: no branch
github spacetelescope / tweakwcs / tweakwcs / imalign.py View on Github external
log.info("      Version {}".format(__version__))
    log.info(" ")

    try:
        # Attempt to set initial status to FAILED.
        tpwcs.meta['fit_info'] = {'status': 'FAILED: Unknown error'}
    except Exception:
        raise AttributeError("Unable to set/modify tpwcs.meta attribute.")

    # check fitgeom:
    fitgeom = fitgeom.lower()
    if fitgeom not in ['shift', 'rscale', 'general']:
        raise ValueError("Unsupported 'fitgeom'. Valid values are: "
                         "'shift', 'rscale', or 'general'")

    wimcat = WCSImageCatalog(imcat, tpwcs,
                             name=imcat.meta.get('name', 'Unnamed'))
    wgcat = WCSGroupCatalog(wimcat, name=imcat.meta.get('name', 'Unnamed'))
    wrefcat = RefCatalog(refcat, name=imcat.meta.get('name', 'Unnamed'))

    succes = wgcat.align_to_ref(refcat=wrefcat, match=None, minobj=None,
                                fitgeom=fitgeom, nclip=nclip, sigma=sigma)

    tpwcs.meta['fit_info'] = wimcat.fit_info
    if not succes:
        log.warning("Failed to align catalog '{}'.".format(wgcat.name))

    # log running time:
    runtime_end = datetime.now()
    log.info(" ")
    log.info("***** {:s}.{:s}() ended on {}"
             .format(__name__, function_name, runtime_end))
github spacetelescope / tweakwcs / tweakwcs / wcsimage.py View on Github external
def __init__(self, images, name=None):
        """
        Parameters
        ----------
        images: list of WCSImageCatalog
            A list of `WCSImageCatalog` image catalogs.

        name: str, None, optional
            Name of the group.

        """
        self._catalog = None

        if isinstance(images, WCSImageCatalog):
            self._images = [images]
            if images.catalog is None:
                raise ValueError("Each input WCS image catalog must have a "
                                 "valid catalog.")

        elif hasattr(images, '__iter__'):
            if not images:
                raise ValueError("List of images cannot be empty.")

            self._images = []
            for im in images:
                if not isinstance(im, WCSImageCatalog):
                    raise TypeError("Each element of the 'images' parameter "
                                    "must be an 'WCSImageCatalog' object.")
                if im.catalog is None:
                    raise ValueError("Each input WCS image catalog must have "