21 import lsst.pex.config
as pexConfig
23 from lsst.daf.butler
import DatasetType
26 from sqlalchemy.exc
import IntegrityError
30 """Config for MakeGen3SkyMapTask 32 datasetTypeName = pexConfig.Field(
33 doc=
"Name assigned to created skymap in butler registry",
35 default=
"deepCoadd_skyMap",
37 name = pexConfig.Field(
38 doc=
"Name assigned to created skymap in butler registry",
43 skyMap = skyMapRegistry.makeField(
50 raise ValueError(
"The name field must be set to the name of the specific " 51 "skymap to use when writing to the butler")
55 ConfigClass = MakeGen3SkyMapConfig
56 _DefaultName =
"makeGen3SkyMap" 58 """This is a task to construct and optionally save a SkyMap into a gen3 63 config : `MakeGen3SkyMapConfig` or None 64 Instance of a configuration class specifying task options, a default 65 config is created if value is None 69 super().
__init__(config=config, **kwargs)
71 def run(self, butler):
72 """Construct and optionally save a SkyMap into a gen3 repository 75 butler : `lsst.daf.butler.Butler` 76 Butler repository to which the new skymap will be written 78 skyMap = self.config.skyMap.apply()
79 skyMap.logSkyMapInfo(self.log)
80 skyMapHash = skyMap.getSha1()
81 self.log.info(f
"Inserting SkyMap {self.config.name} with hash={skyMapHash}")
82 with butler.registry.transaction():
84 skyMap.register(self.config.name, butler.registry)
85 except IntegrityError
as err:
86 raise RuntimeError(
"A skymap with the same name or hash already exists.")
from err
87 butler.registry.registerDatasetType(DatasetType(name=self.config.datasetTypeName,
88 dimensions=[
"skymap"],
89 storageClass=
"SkyMap",
90 universe=butler.registry.dimensions))
91 butler.put(skyMap, self.config.datasetTypeName, {
"skymap": self.config.name})
92 return pipeBase.Struct(
def __init__(self, config=None, kwargs)