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/78dbddba8c/build/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-0.1.5/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 

23import argparse 

24 

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

26# that may default to a backend that requires X 

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

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

29# should import this script. 

30import matplotlib 

31matplotlib.use('Agg') 

32 

33from lsst.validate.drp import validate, util # noqa: E402 

34 

35 

36description = """ 

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

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

39 

40Produces results to: 

41STDOUT 

42 Summary of key metrics 

43REPONAME*.png 

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

45REPONAME*.json 

46 JSON serialization of each KPM. 

47 

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

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

50""" 

51 

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

53 parser = argparse.ArgumentParser(description=description, 

54 formatter_class=argparse.RawDescriptionHelpFormatter) 

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

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

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

58 help=""" 

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

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

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

62 """) 

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

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

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

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

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

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

69 parser.add_argument('--metricsPackage', 

70 default='verify_metrics', 

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

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

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

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

75 default=True, action='store_false', 

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

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

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

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

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

81 

82 args = parser.parse_args() 

83 

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

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

86 load_json = True 

87 else: 

88 load_json = False 

89 

90 kwargs = {} 

91 

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

93 if args.configFile: 

94 pbStruct = util.loadDataIdsAndParameters(args.configFile) 

95 kwargs = pbStruct.getDict() 

96 

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

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

99 if args.verbose: 

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

101 

102 kwargs['metrics_package'] = args.metricsPackage 

103 

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

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

106 

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