Coverage for python/lsst/faro/measurement/DetectorMeasurement.py: 52%

23 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-15 03:34 -0700

1# This file is part of faro. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

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

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

7# for details of code ownership. 

8# 

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

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

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

12# (at your option) any later version. 

13# 

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

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

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

17# GNU General Public License for more details. 

18# 

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

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

21 

22import lsst.pipe.base as pipeBase 

23 

24from lsst.faro.base.CatalogMeasurementBase import ( 

25 CatalogMeasurementBaseConnections, 

26 CatalogMeasurementBaseConfig, 

27 CatalogMeasurementBaseTask, 

28) 

29 

30__all__ = ("DetectorMeasurementConfig", "DetectorMeasurementTask") 

31 

32 

33class DetectorMeasurementConnections( 

34 CatalogMeasurementBaseConnections, 

35 dimensions=("instrument", "visit", "detector", "band"), 

36): 

37 

38 catalog = pipeBase.connectionTypes.Input( 

39 doc="Source catalog.", 

40 dimensions=("instrument", "visit", "detector", "band"), 

41 storageClass="SourceCatalog", 

42 name="src", 

43 ) 

44 visitSummary = pipeBase.connectionTypes.Input( 

45 doc="Exposure catalog with WCS and PhotoCalib this detector+visit combination.", 

46 dimensions=("instrument", "visit"), 

47 storageClass="ExposureCatalog", 

48 name="finalVisitSummary", 

49 ) 

50 measurement = pipeBase.connectionTypes.Output( 

51 doc="Per-detector measurement.", 

52 dimensions=("instrument", "visit", "detector", "band"), 

53 storageClass="MetricValue", 

54 name="metricvalue_{package}_{metric}", 

55 ) 

56 

57 

58class DetectorMeasurementConfig( 

59 CatalogMeasurementBaseConfig, pipelineConnections=DetectorMeasurementConnections 

60): 

61 pass 

62 

63 

64class DetectorMeasurementTask(CatalogMeasurementBaseTask): 

65 ConfigClass = DetectorMeasurementConfig 

66 _DefaultName = "detectorMeasurementTask" 

67 

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

69 inputs = butlerQC.get(inputRefs) 

70 visitSummary = inputs.pop("visitSummary") 

71 detector = inputRefs.catalog.dataId["detector"] 

72 row = visitSummary.find(detector) 

73 inputs["photoCalib"] = row.getPhotoCalib() 

74 inputs["skyWcs"] = row.getSkyWcs() 

75 outputs = self.run(**inputs) 

76 if outputs.measurement is not None: 

77 butlerQC.put(outputs, outputRefs) 

78 else: 

79 self.log.debug( 

80 "Skipping measurement of {!r} on {} " "as not applicable.", 

81 self, 

82 inputRefs, 

83 )