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#!/Users/square/j/ws/release/tarball/60e64ef311/build/conda/miniconda3-py37_4.8.2/envs/lsst-scipipe-cb4e2dc/bin/python # noqa 

2 

3# LSST Data Management System 

4# Copyright 2008-2016 AURA/LSST. 

5# 

6# This product includes software developed by the 

7# LSST Project (http://www.lsst.org/). 

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 LSST License Statement and 

20# the GNU General Public License along with this program. If not, 

21# see <https://www.lsstcorp.org/LegalNotices/>. 

22 

23 

24# Ensure that this script will run on a mis-configured node 

25# that may default to a backend that requires X 

26# e.g., 'Qt5Agg', even though there is is no display available 

27# Putting this here in the command-line script is fine because no one 

28# should import this script. 

29import matplotlib 

30matplotlib.use('Agg') # noqa E402 

31 

32import argparse 

33 

34from lsst.validate.drp import validate, util 

35 

36 

37description = """ 

38Calculate and plot validation Key Project Metrics from the LSST SRD. 

39http://ls.st/LPM-17 

40 

41Produces results to: 

42STDOUT 

43 Summary of key metrics 

44REPONAME*.png 

45 Plots of key metrics. Generated in current working directory. 

46REPONAME*.json 

47 JSON serialization of each KPM. 

48 

49where REPONAME is based on the repository name but with path separators 

50replaced with underscores. E.g., "Cfht/output" -> "Cfht_output_" 

51""" 

52 

53if __name__ == "__main__": 53 ↛ exitline 53 didn't exit the module, because the condition on line 53 was never false

54 parser = argparse.ArgumentParser(description=description, 

55 formatter_class=argparse.RawDescriptionHelpFormatter) 

56 parser.add_argument('repo', type=str, 

57 help='path to a repository containing the output of processCcd') 

58 parser.add_argument('--outputPrefix', '-o', type=str, default=None, 

59 help=""" 

60 Define basic name prefix for output files. Can include paths. 

61 E.g., --outputPrefix="mydir/awesome_reduction" will produce 

62 "mydir/awesome_reduction_r.json" for the r-band JSON file. 

63 """) 

64 parser.add_argument('--brightSnrMin', type=float, default=None, 

65 help='Minimum signal-to-noise ratio for SRD metrics on bright point sources') 

66 parser.add_argument('--brightSnrMax', type=float, default=None, 

67 help='Maximum signal-to-noise ratio for SRD metrics on bright point sources') 

68 parser.add_argument('--configFile', '-c', type=str, default=None, 

69 help='YAML configuration file validation parameters and dataIds.') 

70 parser.add_argument('--metricsPackage', 

71 default='verify_metrics', 

72 help='Name of the repository with YAML definitions of LPM-17 metrics.') 

73 parser.add_argument('--verbose', '-v', default=False, action='store_true', 

74 help='Display additional information about the analysis.') 

75 parser.add_argument('--noplot', dest='makePlot', 

76 default=True, action='store_false', 

77 help='Skip making plots of performance.') 

78 parser.add_argument('--level', type=str, default='design', 

79 help='Level of SRD requirement to meet: "minimum", "design", "stretch"') 

80 parser.add_argument('--skipNonSrd', dest='skipNonSrd', default=False, action='store_true', 

81 help='Whether to skip measuring metrics not defined in the SRD') 

82 

83 args = parser.parse_args() 

84 

85 # Should clean up the duplication here between this and validate.run 

86 if args.repo[-5:] == '.json': 86 ↛ 89line 86 didn't jump to line 89, because the condition on line 86 was never false

87 load_json = True 

88 else: 

89 load_json = False 

90 

91 kwargs = {} 

92 

93 if not load_json: 93 ↛ 94line 93 didn't jump to line 94, because the condition on line 93 was never true

94 if args.configFile: 

95 pbStruct = util.loadDataIdsAndParameters(args.configFile) 

96 kwargs = pbStruct.getDict() 

97 

98 if not args.configFile or not pbStruct.dataIds: 

99 kwargs['dataIds'] = util.discoverDataIds(args.repo) 

100 if args.verbose: 

101 print("VISITDATAIDS: ", kwargs['dataIds']) 

102 

103 kwargs['metrics_package'] = args.metricsPackage 

104 

105 for arg in ('brightSnrMin', 'brightSnrMax', 'level', 'makePlot', 'outputPrefix', 'skipNonSrd', 'verbose'): 

106 kwargs[arg] = getattr(args, arg) 

107 

108 validate.run(args.repo, **kwargs)