Coverage for bin/validateDrp.py : 62%

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/fadf392ebd/build/python/miniconda3-4.7.12/envs/lsst-scipipe-984c9f7/bin/python # noqa
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/>.
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
32import argparse
34from lsst.validate.drp import validate, util
37description = """
38Calculate and plot validation Key Project Metrics from the LSST SRD.
39http://ls.st/LPM-17
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.
49where REPONAME is based on the repository name but with path separators
50replaced with underscores. E.g., "Cfht/output" -> "Cfht_output_"
51"""
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('--configFile', '-c', type=str, default=None,
65 help='YAML configuration file validation parameters and dataIds.')
66 parser.add_argument('--metricsPackage',
67 default='verify_metrics',
68 help='Name of the repository with YAML definitions of LPM-17 metrics.')
69 parser.add_argument('--verbose', '-v', default=False, action='store_true',
70 help='Display additional information about the analysis.')
71 parser.add_argument('--noplot', dest='makePlot',
72 default=True, action='store_false',
73 help='Skip making plots of performance.')
74 parser.add_argument('--level', type=str, default='design',
75 help='Level of SRD requirement to meet: "minimum", "design", "stretch"')
76 parser.add_argument('--skipNonSrd', dest='skipNonSrd', default=False, action='store_true',
77 help='Whether to skip measuring metrics not defined in the SRD')
79 args = parser.parse_args()
81 # Should clean up the duplication here between this and validate.run
82 if args.repo[-5:] == '.json': 82 ↛ 85line 82 didn't jump to line 85, because the condition on line 82 was never false
83 load_json = True
84 else:
85 load_json = False
87 kwargs = {}
89 if not load_json: 89 ↛ 90line 89 didn't jump to line 90, because the condition on line 89 was never true
90 if args.configFile:
91 pbStruct = util.loadDataIdsAndParameters(args.configFile)
92 kwargs = pbStruct.getDict()
94 if not args.configFile or not pbStruct.dataIds:
95 kwargs['dataIds'] = util.discoverDataIds(args.repo)
96 if args.verbose:
97 print("VISITDATAIDS: ", kwargs['dataIds'])
99 kwargs['metrics_package'] = args.metricsPackage
101 kwargs['verbose'] = args.verbose
102 kwargs['makePlot'] = args.makePlot
103 kwargs['level'] = args.level
104 kwargs['outputPrefix'] = args.outputPrefix
105 kwargs['skipNonSrd'] = args.skipNonSrd
107 validate.run(args.repo, **kwargs)