321 """Write information about a sky map to supplied log
325 log : `logging.Logger`
326 Log object that information about skymap will be written.
328 log.info(
"sky map has %s tracts" % (len(self),))
329 for tractInfo
in self:
330 wcs = tractInfo.getWcs()
338 skyPosList = [wcs.pixelToSky(pos).getPosition(geom.degrees)
for pos
in pixelPosList]
339 posStrList = [
"(%0.3f, %0.3f)" % tuple(skyPos)
for skyPos
in skyPosList]
340 log.info(
"tract %s has corners %s (RA, Dec deg) and %s x %s patches" %
341 (tractInfo.getId(),
", ".join(posStrList),
342 tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1]))
388 """Add skymap, tract, and patch Dimension entries to the given Gen3
394 The name of the skymap.
395 butler : `lsst.daf.butler.Butler`
396 The butler to add to.
400 lsst.daf.butler.registry.ConflictingDefinitionError
401 Raised if a different skymap exists with the same name.
405 Registering the same skymap multiple times (with the exact same
406 definition) is safe, but inefficient; most of the work of computing
407 the rows to be inserted must be done first in order to check for
408 consistency between the new skymap and any existing one.
410 Re-registering a skymap with different tract and/or patch definitions
411 but the same summary information may not be detected as a conflict but
412 will never result in updating the skymap; there is intentionally no
413 way to modify a registered skymap (aside from manual administrative
414 operations on the database), as it is hard to guarantee that this can
415 be done without affecting reproducibility.
417 numPatches = [tractInfo.getNumPatches()
for tractInfo
in self]
418 nxMax = max(nn[0]
for nn
in numPatches)
419 nyMax = max(nn[1]
for nn
in numPatches)
424 "tract_max": len(self),
425 "patch_nx_max": nxMax,
426 "patch_ny_max": nyMax,
432 from lsst.daf.butler
import DatasetType
433 from lsst.daf.butler.registry
import ConflictingDefinitionError
434 datasetType = DatasetType(
436 dimensions=[
"skymap"],
437 storageClass=
"SkyMap",
438 universe=butler.dimensions
440 butler.registry.registerDatasetType(datasetType)
441 with butler.transaction():
443 inserted = butler.registry.syncDimensionData(
"skymap", skyMapRecord)
444 except ConflictingDefinitionError
as err:
445 raise ConflictingDefinitionError(
446 f
"SkyMap with hash {self.getSha1().hex()} is already registered with a different name."
449 for tractInfo
in self:
450 tractId = tractInfo.getId()
451 tractRegion = tractInfo.getOuterSkyPolygon()
452 tractWcs = tractInfo.getWcs()
458 butler.registry.insertDimensionData(
"tract", tractRecord)
461 for patchInfo
in tractInfo:
462 xx, yy = patchInfo.getIndex()
467 patch=tractInfo.getSequentialPatchIndex(patchInfo),
470 region=patchInfo.getOuterSkyPolygon(tractWcs),
473 butler.registry.insertDimensionData(
"patch", *patchRecords)