OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
modis_L1B.py
Go to the documentation of this file.
1 #! /usr/bin/env python3
2 
3 """
4 Wrapper program for running the l1bgen program on MODIS L1A files.
5 """
6 import argparse
7 from shlex import quote
8 import sys
9 from modis.modis_utils import buildpcf, modis_env
10 import modis.modis_L1B_utils as modisL1B
11 from seadasutils.setupenv import env
12 
13 
14 def main():
15  """
16  This is the primary driver function for the modis_L1B.py program.
17  """
18  version = "1.1"
19 
20  # Read commandline options...
21  parser = argparse.ArgumentParser(prog="modis_L1B")
22  parser.add_argument('--version', action='version', version='%(prog)s ' + version)
23  parser.add_argument("filename", nargs='?',
24  help="Input L1A file", metavar="L1AFILE")
25  parser.add_argument("geofile", nargs='?',
26  help="INPUT GEOFILE filename - defaults to basename of L1AFILE +'.GEO'", metavar="GEOFILE")
27  parser.add_argument("-p", "--parfile",
28  help="Parameter file containing program inputs", metavar="PARFILE")
29  parser.add_argument("-o", "--okm",
30  help="Output L1B 1KM filename - defaults to '(A|T)YYYYDDDHHMMSS.L1B_LAC'", metavar="1KMFILE")
31 
32  parser.add_argument("-k", "--hkm",
33  help="Output MODIS L1B HKM HDF filename", metavar="HKMFILE")
34  parser.add_argument("-q", "--qkm",
35  help="Output MODIS L1B QKM HDF filename", metavar="QKMFILE")
36  parser.add_argument("-c", "--obc",
37  help="Output MODIS L1B OBC HDF filename", metavar="OBCFILE")
38 
39  parser.add_argument("-l", "--lutver",
40  help="L1B LUT version number", metavar="LUTVER")
41  parser.add_argument("-d", "--lutdir",
42  help="Path of directory containing LUT files", metavar="LUTDIR")
43 
44  parser.add_argument("-x", "--del-okm", action="store_const", const=1,
45  default=0, help="Delete 1km resolution L1B file")
46  parser.add_argument("-y", "--del-hkm", action="store_const", const=2,
47  default=0, help="Delete 500m resolution L1B file")
48  parser.add_argument("-z", "--del-qkm", action="store_const", const=4,
49  default=0, help="Delete 250m resolution L1B file")
50  parser.add_argument("--keep-obc", action="store_const", const=0,
51  default=8, help="Save onboard calibration file")
52 
53  parser.add_argument("-v", "--verbose", action="store_true",
54  default=False, help="print status messages")
55  parser.add_argument("--log", action="store_true",
56  default=False, help="Save processing log file(s)")
57 
58  args = parser.parse_args()
59 
60  if args.parfile is None and args.filename is None:
61  parser.print_help()
62  sys.exit(1)
63 
64  parfile = None
65  if args.parfile:
66  parfile = quote(args.parfile)
67 
68  geofile = None
69  if args.geofile:
70  geofile = quote(args.geofile)
71  okm = None
72  if args.okm:
73  okm = quote(args.okm)
74  hkm = None
75  if args.hkm:
76  hkm = quote(args.hkm)
77  qkm = None
78  if args.qkm:
79  qkm = quote(args.qkm)
80  obc = None
81  if args.obc:
82  obc = quote(args.obc)
83 
84  delfiles = args.del_okm + args.del_hkm + args.del_qkm + args.keep_obc
85 
86  l1b_instance = modisL1B.ModisL1B(inp_file=quote(args.filename),
87  parfile=parfile,
88  geofile=geofile,
89  okm=okm,
90  hkm=hkm,
91  qkm=qkm,
92  obc=obc,
93  lutver=args.lutver,
94  lutdir=args.lutdir,
95  delfiles=delfiles,
96  log=args.log,
97  verbose=args.verbose
98  )
99  env(l1b_instance)
100  modis_env(l1b_instance)
101  l1b_instance.chk()
102  buildpcf(l1b_instance)
103  l1b_instance.run()
104  return 0
105 
106 if __name__ == "__main__":
107  sys.exit(main())
def main()
Definition: modis_L1B.py:14
def modis_env(self)
Definition: modis_utils.py:227
def buildpcf(self)
Definition: modis_utils.py:17
def env(self)
Definition: setupenv.py:7