Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
object.
Parameters
----------
wcsim: WCSImageCatalog, WCSGroupCatalog, RefCatalog, 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, RefCatalog)):
return self._polygon.intersection(wcsim.polygon)
else:
return self._polygon.intersection(wcsim)
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))
log.info("***** {:s}.{:s}() TOTAL RUN TIME: {}"
.format(__name__, function_name, runtime_end - runtime_begin))
raise TypeError("Unsupported 'refcat' type. Supported 'refcat' "
"types are 'tweakwcs.tpwcs.TPWCS' and "
"'astropy.table.Table'")
# find group ID and assign images to groups:
grouped_images = collections.defaultdict(list)
for wcat in wcs_im_cats:
grouped_images[wcat.group_id].append(wcat)
# create WCSImageCatalog and WCSGroupCatalog:
wcs_gcat = []
for group_id, wcatalogs in grouped_images.items():
if group_id is None:
for wcat in wcatalogs:
wcs_gcat.append(
WCSGroupCatalog(wcat, name='GROUP ID: None')
)
else:
gcat = WCSGroupCatalog(
wcatalogs,
name='GROUP ID: {}'.format(group_id)
)
if not len(gcat.catalog):
log.warning("Group with ID '{}' will not be aligned: empty "
"source catalog".format(group_id))
for wcat in wcatalogs:
wcat.tpwcs.meta['fit_info'] = {
'status': 'FAILED: empty source catalog'
}
# find group ID and assign images to groups:
grouped_images = collections.defaultdict(list)
for wcat in wcs_im_cats:
grouped_images[wcat.group_id].append(wcat)
# create WCSImageCatalog and WCSGroupCatalog:
wcs_gcat = []
for group_id, wcatalogs in grouped_images.items():
if group_id is None:
for wcat in wcatalogs:
wcs_gcat.append(
WCSGroupCatalog(wcat, name='GROUP ID: None')
)
else:
gcat = WCSGroupCatalog(
wcatalogs,
name='GROUP ID: {}'.format(group_id)
)
if not len(gcat.catalog):
log.warning("Group with ID '{}' will not be aligned: empty "
"source catalog".format(group_id))
for wcat in wcatalogs:
wcat.tpwcs.meta['fit_info'] = {
'status': 'FAILED: empty source catalog'
}
continue
wcs_gcat.append(gcat)