OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
update_luts.py
Go to the documentation of this file.
1 #! /usr/bin/env python3
2 """
3 update_luts.py
4 
5 Updates LUTS for the various sensors.
6 """
7 
8 import argparse
9 import seadasutils.LutUtils as Lut
10 
11 
12 class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter,
13  argparse.RawTextHelpFormatter):
14  pass
15 
16 
17 if __name__ == '__main__':
18 
19  version = '2.1'
20  description = 'Retrieve latest lookup tables for specified sensor.'
21  sensors = [ 'all', 'common', 'seawifs', 'hico', 'modisa', 'modist', 'viirsn', 'viirsj1', 'viirsj2', 'oci']
22  platforms = ['aqua', 'terra', 'npp', 'j1', 'j2']
23 
24  # Define commandline options
25 
26  parser = argparse.ArgumentParser(prog='update_luts',formatter_class=CustomFormatter,
27  description=description, add_help=True)
28 
29  parser.add_argument('mission', metavar='MISSION',
30  help='sensor or platform to process; one of:\n%(choices)s',
31  choices= sensors + platforms)
32 
33  parser.add_argument('-e', '--eval', action='store_true', dest='evalluts',
34  help='also download evaluation LUTs')
35 
36  parser.add_argument('-v', '--verbose', action='count', default=0,
37  help='print status messages')
38 
39  parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
40  help='no action; preview files to be downloaded')
41 
42  parser.add_argument('--timeout', type=float, default=10,
43  help='network timeout in seconds')
44 
45  parser.add_argument('--version', action='version', version='%(prog)s ' + version)
46 
47  parser.add_argument('-d', '--debug', action='store_true',
48  help=argparse.SUPPRESS) # hidden option
49 
50  # Read options and take action
51  args = parser.parse_args()
52  if args.debug:
53  import logging
54  logging.basicConfig(level=logging.DEBUG,
55  format='%(levelname)s:%(message)s')
56 
57  # install all of the luts
58  if args.mission == 'all':
59  for tmpMission in sensors:
60  if tmpMission != 'all':
61  luts = Lut.LutUtils(verbose=args.verbose,
62  mission=tmpMission,
63  evalluts=args.evalluts,
64  timeout=args.timeout,
65  dry_run=args.dry_run)
66  luts.get_luts()
67  if luts.status != 0:
68  parser.exit(luts.status)
69  parser.exit(luts.status)
70 
71  # always update the common directory
72  luts = Lut.LutUtils(verbose=args.verbose,
73  mission='common',
74  evalluts=False,
75  timeout=args.timeout,
76  dry_run=args.dry_run)
77  luts.get_luts()
78  if luts.status != 0:
79  parser.exit(luts.status)
80 
81  # stop here if only the common dir was requested
82  if args.mission == 'common':
83  parser.exit(luts.status)
84 
85  # on to the requested sensor
86  luts = Lut.LutUtils(verbose=args.verbose,
87  mission=args.mission,
88  evalluts=args.evalluts,
89  timeout=args.timeout,
90  dry_run=args.dry_run)
91 
92  luts.get_luts()
93  parser.exit(luts.status)