Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# This product includes software developed by the LSST Project 

2# (https://www.lsst.org). 

3# See the COPYRIGHT file at the top-level directory of this distribution 

4# for details of code ownership. 

5# 

6# This program is free software: you can redistribute it and/or modify 

7# it under the terms of the GNU General Public License as published by 

8# the Free Software Foundation, either version 3 of the License, or 

9# (at your option) any later version. 

10# 

11# This program is distributed in the hope that it will be useful, 

12# but WITHOUT ANY WARRANTY; without even the implied warranty of 

13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

14# GNU General Public License for more details. 

15# 

16# You should have received a copy of the GNU General Public License 

17# along with this program. If not, see <https://www.gnu.org/licenses/>. 

18 

19import lsst.pipe.base as pipeBase 

20from lsst.verify.tasks import MetricConnections 

21 

22from lsst.faro.base.CatalogMeasurementBase import CatalogMeasurementBaseConfig, CatalogMeasurementBaseTask 

23 

24__all__ = ("VisitMeasurementConfig", "VisitMeasurementTask") 

25 

26 

27class VisitMeasurementConnections(MetricConnections, 

28 dimensions=("instrument", "visit", "band"), 

29 defaultTemplates={"photoCalibName": "calexp.photoCalib", 

30 "wcsName": "calexp.wcs"}): 

31 

32 catalogs = pipeBase.connectionTypes.Input(doc="Source catalogs.", 

33 dimensions=("instrument", "visit", 

34 "detector", "band"), 

35 storageClass="SourceCatalog", 

36 name="src", 

37 multiple=True) 

38 

39 photoCalibs = pipeBase.connectionTypes.Input(doc="Photometric calibration object.", 

40 dimensions=("instrument", "visit", 

41 "detector", "band"), 

42 storageClass="PhotoCalib", 

43 name="{photoCalibName}", 

44 multiple=True) 

45 

46 astromCalibs = pipeBase.connectionTypes.Input(doc="WCS for the catalog.", 

47 dimensions=("instrument", "visit", 

48 "detector", "band"), 

49 storageClass="Wcs", 

50 name="{wcsName}", 

51 multiple=True) 

52 

53 measurement = pipeBase.connectionTypes.Output(doc="Per-visit measurement.", 

54 dimensions=("instrument", "visit", "band"), 

55 storageClass="MetricValue", 

56 name="metricvalue_{package}_{metric}") 

57 

58 

59class VisitMeasurementConfig(CatalogMeasurementBaseConfig, 

60 pipelineConnections=VisitMeasurementConnections): 

61 pass 

62 

63 

64class VisitMeasurementTask(CatalogMeasurementBaseTask): 

65 ConfigClass = VisitMeasurementConfig 

66 _DefaultName = "visitMeasurementTask" 

67 

68 def runQuantum(self, butlerQC, inputRefs, outputRefs): 

69 inputs = butlerQC.get(inputRefs) 

70 inputs['dataIds'] = [butlerQC.registry.expandDataId(c.dataId) for c in inputRefs.catalogs] 

71 outputs = self.run(**inputs) 

72 if outputs.measurement is not None: 

73 butlerQC.put(outputs, outputRefs) 

74 else: 

75 self.log.debug("Skipping measurement of {!r} on {} " 

76 "as not applicable.", self, inputRefs)