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 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 (CatalogMeasurementBaseConnections, 

26 CatalogMeasurementBaseConfig, 

27 CatalogMeasurementBaseTask) 

28 

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

30 

31 

32class VisitTableMeasurementConnections(CatalogMeasurementBaseConnections, 

33 dimensions=("instrument", "visit", "band")): 

34 

35 catalog = pipeBase.connectionTypes.Input( 

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

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

38 storageClass="DataFrame", 

39 name="sourceTable_visit", 

40 deferLoad=True 

41 ) 

42 

43 measurement = pipeBase.connectionTypes.Output( 

44 doc="Per-visit measurement", 

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

46 storageClass="MetricValue", 

47 name="metricvalue_{package}_{metric}" 

48 ) 

49 

50 

51class VisitTableMeasurementConfig(CatalogMeasurementBaseConfig, 

52 pipelineConnections=VisitTableMeasurementConnections): 

53 """Configuration for VisitTableMeasurementTask.""" 

54 

55 columns = pexConfig.ListField(doc="Columns from sourceTable_visit to load.", 

56 dtype=str, default=['coord_ra', 'coord_dec']) 

57 

58 

59class VisitTableMeasurementTask(CatalogMeasurementBaseTask): 

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

61 ConfigClass = VisitTableMeasurementConfig 

62 _DefaultName = "visitTableMeasurementTask" 

63 

64 def run(self, catalog): 

65 return self.measure.run(self.config.connections.metric, catalog) 

66 

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

68 inputs = butlerQC.get(inputRefs) 

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

70 outputs = self.run(catalog) 

71 if outputs.measurement is not None: 

72 butlerQC.put(outputs, outputRefs) 

73 else: 

74 self.log.debugf("Skipping measurement of {!r} on {} " 

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