4 Program to check for updated ancillary data files and download them
15 The main function for the program. Gets and checks command line options, instantiates
16 a getanc object (from the class defined in anc_utils) and then calls the methods to
17 get the ancillary data.
24 %(prog)s [OPTIONS] FILE
26 -s,--start YYYYDDDHHMMSS [-e,--end YYYDDDHHMMSS] [OPTIONS]
28 FILE Input L1A or L1B file
30 NOTE: Currently NO2 climatological data is used for OBPG operational
31 processing, so to match OBPG distributed data products, the default
32 behaviour disables NO2 searching.
34 This program queries an OBPG server and optionally downloads the optimal
35 ancillary data files for Level-1 to Level-2 processing. If an input file
36 is specified the start and end times are determined automatically, otherwise
37 a start time must be provided by the user.
39 A text file (with the extension '.anc') is created containing parameters
40 that can be directly used as input to the l2gen program for optimal Level-1
41 to Level-2 processing, e.g.:
43 l2gen ifile=<infile> ofile=<outfile> par=<the *.anc text file>
46 0 : all optimal ancillary files exist and are present on the locally
47 99 : an error was encountered; no .anc parameter text file was created
48 31 : no ancillary files currently exist corresponding to the start
49 time and therefore no .anc parameter text file was created
50 1-30 : bitwise value indicating one or more files are not optimal:
52 bit 0 set = missing one or more MET files
53 bit 1 set = missing one or more OZONE files
54 bit 2 set = no SST file found
55 bit 3 set = no NO2 file found
56 bit 4 set = no ICE file found
58 e.g. STATUS=11 indicates there are missing optimal MET, OZONE, and NO2 files
62 parser = argparse.ArgumentParser(prog=
"getanc",usage=usage)
63 parser.add_argument(
'--version', action=
'version', version=
'%(prog)s ' + version)
64 parser.add_argument(
"filename", nargs=
'?',
65 help=
"Input L1 file", metavar=
"L1FILE")
66 parser.add_argument(
"-s",
"--start",
67 help=
"Time of the first scanline (if used, no input file is required)",
69 parser.add_argument(
"-e",
"--stop",
70 help=
"Time of last scanline", metavar=
"STOP")
72 ancdb_help_text =
"Use a custom filename for ancillary database. If " \
73 "full path not given, ANCDB is assumed to exist "\
74 "(or will be created) under " + \
75 ga.DEFAULT_ANC_DIR_TEXT +
"/log/. If " + \
76 ga.DEFAULT_ANC_DIR_TEXT +
"/log/ does not " \
77 "exist, ANCDB is assumed (or will be created) " \
78 "under the current working directory"
79 parser.add_argument(
"--ancdb", default=
'ancillary_data.db',help=ancdb_help_text, metavar=
"ANCDB")
80 parser.add_argument(
"-o",
"--ofile", help=
"output ancillary par file", metavar=
"ANC_FILE")
81 parser.add_argument(
"--ancdir",
82 help=
"Use a custom directory tree for ancillary files", metavar=
"ANCDIR")
83 parser.add_argument(
"-c",
"--curdir", action=
"store_true",
84 default=
False, help=
"Download ancillary files directly into current working directory")
85 parser.add_argument(
"-r",
"--refreshDB", action=
"store_true", default=
False,
86 help=
"Remove existing database records and re-query for ancillary files")
87 parser.add_argument(
"--disable-download", action=
"store_false", dest=
"download",default=
True,
88 help=
"Disable download of ancillary files not found on hard disk")
89 parser.add_argument(
"--timeout", type=float, default=10.0, metavar=
"TIMEOUT",
90 help=
"set the network timeout in seconds")
91 parser.add_argument(
"-m",
"--mission", help=
"Mission name", metavar=
"MISSION")
93 parser.add_argument(
"-i",
"--ice", action=
"store_false", default=
True,
94 help=
"Do not search for sea-ice ancillary data")
95 parser.add_argument(
"-n",
"--no2", action=
"store_true", default=
False,
96 help=
"Search for NO2 ancillary data")
97 parser.add_argument(
"-t",
"--sst", action=
"store_false", default=
True,
98 help=
"Do not search for SST ancillary data")
99 parser.add_argument(
"-v",
"--verbose", action=
"count",
100 default=0, help=
"print status messages")
101 parser.add_argument(
"--noprint", action=
"store_false", default=
True,
102 help=
"Suppress printing the resulting list of files to the screen")
103 parser.add_argument(
"-f",
"--force-download", action=
"store_true", dest=
'force', default=
False,
104 help=
"Force download of ancillary files, even if found on hard disk")
105 parser.add_argument(
"-u",
"--use_filename", action=
"store_true", default=
False,
106 help=
"Use filename to call API instead of deriving start time")
108 args = parser.parse_args()
109 if args.filename
is None and args.start
is None:
113 g = ga.getanc(filename=args.filename,
122 verbose=args.verbose,
123 printlist=args.noprint,
124 download=args.download,
125 timeout=args.timeout,
126 refreshDB=args.refreshDB,
127 use_filename=args.use_filename)
129 if args.sst
is False:
130 g.set_opt_flag(
'sst', off=
True)
132 g.set_opt_flag(
'no2')
133 if args.ice
is False:
134 g.set_opt_flag(
'ice', off=
True)
138 if (args.filename
and g.finddb())
or (args.start
and g.finddb()):
143 g.locate(forcedl=args.force)
148 if __name__ ==
"__main__":