Coverage for python/lsst/faro/measurement/PatchMeasurement.py: 59%

20 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-10-11 02:40 -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__ = ( 

31 "PatchMeasurementConnections", 

32 "PatchMeasurementConfig", 

33 "PatchMeasurementTask", 

34) 

35 

36 

37class PatchMeasurementConnections( 

38 CatalogMeasurementBaseConnections, dimensions=("tract", "patch", "skymap", "band") 

39): 

40 

41 cat = pipeBase.connectionTypes.Input( 

42 doc="Object catalog.", 

43 dimensions=("tract", "patch", "skymap", "band"), 

44 storageClass="SourceCatalog", 

45 name="deepCoadd_forced_src", 

46 ) 

47 

48 measurement = pipeBase.connectionTypes.Output( 

49 doc="Per-patch measurement.", 

50 dimensions=("tract", "patch", "skymap", "band"), 

51 storageClass="MetricValue", 

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

53 ) 

54 

55 

56class PatchMeasurementConfig( 

57 CatalogMeasurementBaseConfig, pipelineConnections=PatchMeasurementConnections 

58): 

59 pass 

60 

61 

62class PatchMeasurementTask(CatalogMeasurementBaseTask): 

63 

64 ConfigClass = PatchMeasurementConfig 

65 _DefaultName = "patchMeasurementTask" 

66 

67 def run(self, cat, vIds): 

68 return self.measure.run(cat, self.config.connections.metric, vIds) 

69 

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

71 inputs = butlerQC.get(inputRefs) 

72 inputs["vIds"] = inputRefs.cat.dataId 

73 outputs = self.run(**inputs) 

74 if outputs.measurement is not None: 

75 butlerQC.put(outputs, outputRefs) 

76 else: 

77 self.log.debug( 

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

79 self, 

80 inputRefs, 

81 )