Coverage for python/lsst/faro/measurement/VisitTableMeasurement.py: 38%

Shortcuts 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

28 statements  

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 

23import lsst.pex.config as pexConfig 

24 

25from lsst.faro.base.CatalogMeasurementBase import ( 

26 CatalogMeasurementBaseConnections, 

27 CatalogMeasurementBaseConfig, 

28 CatalogMeasurementBaseTask, 

29) 

30 

31__all__ = ("VisitTableMeasurementConfig", "VisitTableMeasurementTask") 

32 

33 

34class VisitTableMeasurementConnections( 

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

36): 

37 

38 catalog = pipeBase.connectionTypes.Input( 

39 doc="Source table in parquet format, per visit", 

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

41 storageClass="DataFrame", 

42 name="sourceTable_visit", 

43 deferLoad=True, 

44 ) 

45 

46 measurement = pipeBase.connectionTypes.Output( 

47 doc="Per-visit measurement", 

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

49 storageClass="MetricValue", 

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

51 ) 

52 

53 

54class VisitTableMeasurementConfig( 

55 CatalogMeasurementBaseConfig, pipelineConnections=VisitTableMeasurementConnections 

56): 

57 """Configuration for VisitTableMeasurementTask.""" 

58 

59 columns = pexConfig.ListField( 

60 doc="Columns from sourceTable_visit to load.", 

61 dtype=str, 

62 default=["coord_ra", "coord_dec"], 

63 ) 

64 

65 

66class VisitTableMeasurementTask(CatalogMeasurementBaseTask): 

67 """Base class for science performance metrics measured on single-visit source catalogs.""" 

68 

69 ConfigClass = VisitTableMeasurementConfig 

70 _DefaultName = "visitTableMeasurementTask" 

71 

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

73 inputs = butlerQC.get(inputRefs) 

74 catalog = inputs["catalog"].get(parameters={"columns": self.config.columns}) 

75 

76 kwargs = {} 

77 kwargs['catalog'] = catalog 

78 if self.config.connections.refDataset != "": 

79 refCats = inputs.pop("refCat") 

80 filterList = [butlerQC.quantum.dataId.records["physical_filter"].name] 

81 # Time at the start of the visit 

82 epoch = butlerQC.quantum.dataId.records["visit"].timespan.begin 

83 refCat, refCatCorrected = self._getReferenceCatalog( 

84 butlerQC, 

85 [ref.datasetRef.dataId for ref in inputRefs.refCat], 

86 refCats, 

87 filterList, 

88 epoch, 

89 ) 

90 kwargs["refCat"] = refCat 

91 kwargs["refCatCorrected"] = refCatCorrected 

92 

93 outputs = self.run(**kwargs) 

94 if outputs.measurement is not None: 

95 butlerQC.put(outputs, outputRefs) 

96 else: 

97 self.log.debugf( 

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

99 self, 

100 inputRefs, 

101 )