Go to the documentation of this file.
18 utilities for Aquarius ancillary data
25 ancdb='ancillary_data.db',
53 anc.buildParameterFile(
'main')
57 Run mk_aquarius_ancillary_data to create the "y" files
67 callnum = format(count,
'd')
68 hour = os.path.basename(self.
ancfiles[
'met' + callnum])[8:10]
69 yancfilename =
''.join([
'y', sdt, hour,
'.h5'])
74 print(
"Creating Aquarius yancfile%s %s..." % (count, yancfilename))
75 mk_anc = os.path.join(self.
dirs[
'bin'],
'mk_aquarius_ancillary_data')
82 self.
ancfiles[
'frozenfile' + callnum],
90 status = subprocess.call(mk_anc_cmd, shell=
False)
93 print(
"mk_aquarius_ancillary_data returned with exit status: "
95 print(
'command: ' + mk_anc_cmd)
99 geos = os.path.join(self.
dirs[
'bin'],
'geos')
100 geos_cmd = [geos, yancfilename, self.
ancfiles[
'geosfile']]
101 status = subprocess.call(geos_cmd, shell=
False)
104 print(
'geos returned with exit status: ' +
str(status))
105 print(
'command: ' + geos_cmd)
110 print(
"yancfile %s created successfully!" % yancfilename)
114 if __name__ ==
"__main__":
120 %(prog)s [OPTIONS] FILE
122 This program does the following:
124 1) executes getanc for Aquarius L1 files. If an input file is
125 specified the start and end times are determined automatically,
126 otherwise a start time must be provided by the user.
128 2) runs the mk_aquarius_ancillary_data program to create the "y-files"
129 required as input to l2gen_aquarius.
131 3) retrieves and un-tars the scatterometer files
134 parser = argparse.ArgumentParser(prog=
"getanc_aquarius",usage=usage)
135 parser.add_argument(
'--version', action=
'version', version=
'%(prog)s ' + version)
136 parser.add_argument(
"filename", nargs=
'?',
137 help=
"Input L1 file", metavar=
"L1FILE")
138 parser.add_argument(
"-s",
"--start",
139 help=
"Time of the first scanline (if used, no input file is required)",
141 parser.add_argument(
"-e",
"--stop",
142 help=
"Time of last scanline", metavar=
"STOP")
144 ancdb_help_text =
"Use a custom filename for ancillary database. If " \
145 "full path not given, ANCDB is assumed to exist "\
146 "(or will be created) under " + \
147 ga.DEFAULT_ANC_DIR_TEXT +
"/log/. If " + \
148 ga.DEFAULT_ANC_DIR_TEXT +
"/log/ does not " \
149 "exist, ANCDB is assumed (or will be created) " \
150 "under the current working directory"
151 parser.add_argument(
"--ancdb", default=
'ancillary_data.db',help=ancdb_help_text, metavar=
"ANCDB")
152 parser.add_argument(
"--ancdir",
153 help=
"Use a custom directory tree for ancillary files", metavar=
"ANCDIR")
154 parser.add_argument(
"-c",
"--curdir", action=
"store_true",
155 default=
False, help=
"Download ancillary files directly into current working directory")
156 parser.add_argument(
"-r",
"--refreshDB", action=
"store_true", default=
False,
157 help=
"Remove existing database records and re-query for ancillary files")
158 parser.add_argument(
"--disable-download", action=
"store_false", dest=
"download",default=
True,
159 help=
"Disable download of ancillary files not found on hard disk")
160 parser.add_argument(
"--timeout", type=float, default=10.0, metavar=
"TIMEOUT",
161 help=
"set the network timeout in seconds")
162 parser.add_argument(
"-v",
"--verbose", action=
"store_true",
163 default=
False, help=
"print status messages")
164 parser.add_argument(
"--noprint", action=
"store_false", default=
True,
165 help=
"Suppress printing the resulting list of files to the screen")
166 parser.add_argument(
"-f",
"--force-download", action=
"store_true", dest=
'force', default=
False,
167 help=
"Force download of ancillary files, even if found on hard disk")
169 args = parser.parse_args()
171 if args.filename
is None and args.start
is None:
181 verbose=args.verbose,
182 printlist=args.noprint,
183 download=args.download,
184 refreshDB=args.refreshDB)
191 getanc = os.path.join(g.dirs[
'bin'],
'getanc')
193 getanc_cmd = [getanc,
'--mission=aquarius --noprint', args.filename]
195 getanc_cmd = [getanc,
'--mission=aquarius --noprint',
'-s', args.start]
197 getanc_cmd.append(args.stop)
200 getanc_cmd.append(
' --verbose')
202 getanc_cmd.appen(
' --refreshDB')
204 getanc_cmd.append(
' --force')
207 status = subprocess.call(getanc_cmd, shell=
False)
209 if status
and args.verbose:
210 print(
'getanc returned with exit status: ' +
str(status))
211 print(
'command: ' + getanc_cmd)
213 if args.filename
is None:
214 anc_filelist = args.start +
".anc"
216 anc_filelist =
'.'.join([os.path.basename(args.filename),
'anc'])
218 g.parse_anc(anc_filelist)
219 anclist =
list(g.ancfiles.keys())
222 g.ancfiles[
'yancfile1'] = g.run_mk_anc(1)
223 g.ancfiles[
'yancfile2'] = g.run_mk_anc(2)
224 if not (g.ancfiles[
'yancfile1']
and g.ancfiles[
'yancfile2']):
225 print(
'ERROR in making yancfiles!')
229 atm3 = g.ancfiles.get(
'atm3',
None)
230 if atm3
and atm3
not in (g.ancfiles[
'atm1'], g.ancfiles[
'atm2']):
231 g.ancfiles[
'yancfile3'] = g.run_mk_anc(3)
234 gran = os.path.basename(args.filename).split(
'.')[0]
235 scatfile =
'.'.join([gran,
'L2_SCAT_V5.0.tar'])
236 scatpath =
'/'.join([
'/cgi/getfile', scatfile])
238 print(
'\nDownloading ' + scatfile +
' to current directory.')
239 status =
httpdl(
'oceandata.sci.gsfc.nasa.gov',
240 scatpath, uncompress=
True, verbose=verbose)
242 print(
'Error downloading', scatfile)
244 tar = tarfile.open(scatfile)
249 g.ancfiles[
'l2_uncertainties_file'] = g.ancfiles.get(
'pert',
'')
250 g.ancfiles[
'sif_file'] = g.ancfiles.get(
'sif',
'')
251 g.ancfiles[
'sss_matchup_file'] = g.ancfiles.get(
'sssmatchup',
'')
255 if key
not in (
'xrayfile1',
'xrayfile2',
256 'l2_uncertainties_file',
260 del (g.ancfiles[key])
263 g.ancfiles[
'suite'] =
'V5.0.0'
266 os.rename(anc_filelist, anc_filelist +
'.orig')
269 g.write_anc(anc_filelist)
270 if args.verbose
or args.printlist:
def parse_anc(self, anc_filelist)
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
def aquarius_timestamp(arg)
def write_anc(self, anc_filelist)
def __init__(self, filename=None, start=None, stop=None, ancdir=None, ancdb='ancillary_data.db', curdir=False, verbose=False, printlist=True, download=True, refreshDB=False)
def run_mk_anc(self, count)
def httpdl(server, request, localpath='.', outputfilename=None, ntries=5, uncompress=False, timeout=30., verbose=0, force_download=False, chunk_size=DEFAULT_CHUNK_SIZE)
def date_convert(datetime_i, in_datetype=None, out_datetype=None)
def addsecs(datetime_i, dsec, datetype=None)