OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
modis_atteph.py
Go to the documentation of this file.
1 #! /usr/bin/env python3
2 
3 import argparse
4 import os
5 import sys
6 import seadasutils.anc_utils as ga
7 from seadasutils.setupenv import env
8 from seadasutils.ProcUtils import check_sensor
9 
10 if __name__ == "__main__":
11  version = "2.2"
12 
13  # Read commandline options...
14  usage = '''
15  %(prog)s L1A_file
16  or
17  %(prog)s -m modisa|aqua|modist|terra -s YYYYDDDHHMMSS -e YYYYDDDHHMMSS
18 
19  NOTE: Currently NO2 climatological data is used for OBPG operational
20  processing, so to match OBPG distributed data products, the default
21  behaviour disables NO2 searching.
22 
23  This program queries an OBPG server and optionally downloads the optimal
24  ancillary data files for modis_GEO processing. If an input file
25  is specified the start and end times are determined automatically, otherwise
26  a start time must be provided by the user.
27 
28  A text file (with the extension '.atteph') is created containing parameters
29  that can be directly used for optimal optimal modis_GEO processing
30 
31  EXIT STATUS:
32  0 - all is well in the world
33  1 - predicted attitude selected
34  2 - predicted ephemeris selected
35  4 - no attitude found
36  8 - no ephemeris found
37  16 - invalid mission
38  12 - no att/eph files currently exist corresponding to the start
39  time and therefore no .atteph parameter text file was created
40  99 - an error was encountered; no .atteph parameter text file was created
41  '''
42 
43  parser = argparse.ArgumentParser(prog="modis_atteph",usage=usage)
44  parser.add_argument('--version', action='version', version='%(prog)s ' + version)
45  parser.add_argument("filename", nargs='?',
46  help="Input L1 file", metavar="L1FILE")
47  parser.add_argument("-s", "--start",
48  help="Granule start time (YYYYDDDHHMMSS)",
49  metavar="START")
50  parser.add_argument("-e", "--stop",
51  help="Granule stop time (YYYYDDDHHMMSS)", metavar="STOP")
52 
53  ancdb_help_text = "Use a custom file for ancillary database. If full " \
54  "path not given, ANCDB is assumed to exist (or " \
55  "will be created) under " + ga.DEFAULT_ANC_DIR_TEXT + \
56  "/log/. If " + ga.DEFAULT_ANC_DIR_TEXT + "/log/ does " \
57  "not exist, ANCDB is assumed (or will be created) " \
58  " under the current working directory"
59 
60  ancdb_help_text = "Use a custom filename for ancillary database. If " \
61  "full path not given, ANCDB is assumed to exist "\
62  "(or will be created) under " + \
63  ga.DEFAULT_ANC_DIR_TEXT + "/log/. If " + \
64  ga.DEFAULT_ANC_DIR_TEXT + "/log/ does not " \
65  "exist, ANCDB is assumed (or will be created) " \
66  "under the current working directory"
67  parser.add_argument("--ancdb", default='ancillary_data.db',help=ancdb_help_text, metavar="ANCDB")
68  parser.add_argument("--ancdir",
69  help="Use a custom directory tree for ancillary files", metavar="ANCDIR")
70  parser.add_argument("-c", "--curdir", action="store_true",
71  default=False, help="Download ancillary files directly into current working directory")
72  parser.add_argument("-r", "--refreshDB", action="store_true", default=False,
73  help="Remove existing database records and re-query for ancillary files")
74  parser.add_argument("--disable-download", action="store_false", dest="download",default=True,
75  help="Disable download of ancillary files not found on hard disk")
76  parser.add_argument("--timeout", type=float, default=10.0, metavar="TIMEOUT",
77  help="set the network timeout in seconds")
78  parser.add_argument("-m", "--mission", help="MODIS mission - A(qua) or T(erra)", metavar="MISSION")
79 
80  parser.add_argument("-v", "--verbose", action="count",
81  default=0, help="print status messages")
82  parser.add_argument("--noprint", action="store_false", default=True,
83  help="Suppress printing the resulting list of files to the screen")
84  parser.add_argument("-f", "--force-download", action="store_true", dest='force', default=False,
85  help="Force download of ancillary files, even if found on hard disk")
86 
87  args = parser.parse_args()
88  if args.filename is None and (args.mission and args.start is None):
89  parser.print_help()
90  sys.exit(32)
91 
92 
93  m = ga.getanc(filename=args.filename,
94  start=args.start,
95  stop=args.stop,
96  ancdir=args.ancdir,
97  curdir=args.curdir,
98  ancdb=args.ancdb,
99  sensor=args.mission,
100  download=args.download,
101  refreshDB=args.refreshDB,
102  atteph=True,
103  verbose=args.verbose,
104  timeout=args.timeout)
105 
106  env(m)
107  m.chk()
108  if m.sensor is None and os.path.exists(args.filename):
109  m.sensor = check_sensor(args.filename)
110  if args.filename and m.finddb():
111  m.setup()
112  elif args.start and m.finddb():
113  m.setup()
114  else:
115  m.setup()
116  m.findweb()
117 
118  m.locate(forcedl=args.force)
119  m.write_anc_par()
120  m.cleanup()
121 
122  sys.exit(m.db_status)
def check_sensor(inp_file)
Definition: ProcUtils.py:376
def env(self)
Definition: setupenv.py:7