Go to the documentation of this file.
9 f = os.path.basename(lut_name)
12 if re.match(
'xcal', f):
13 parts = re.split(
'([_.])', f)
14 return ''.join(parts[4:-4])
17 v = re.search(
'[_.][vV]\d+', f)
19 parts = re.split(
'([_.])', f[v.start() + 1:])
20 return ''.join(parts[0:-2])
28 d = os.path.dirname(lut_name)
29 f = os.path.basename(lut_name)
33 return os.path.join(d, p.sub(
'*', f))
41 deletable = [f
for f
in similar
if
42 os.path.getmtime(f) < os.path.getmtime(newfile)]
47 deletable = [
old_version(newf)
for newf
in newfiles]
49 deletable = [oldf
for sublist
in deletable
for oldf
in sublist]
50 if len(deletable) > 0:
52 print(
'\n...deleting outdated LUTs:')
53 for f
in sorted(deletable):
55 print(
'- ' + os.path.basename(f))
61 Utilities to update various LUT files for processing
64 def __init__(self, mission=None, verbose=False, evalluts=False,
65 timeout=10, clobber=False, dry_run=False):
74 self.
site_root =
'https://oceandata.sci.gsfc.nasa.gov/Ancillary/LUTs'
76 self.
sensor = SensorUtils.by_desc(mission)
78 self.
session = Session.SessionUtils(timeout=timeout, clobber=clobber, verbose=verbose)
84 if self.
sensor[
'instrument'] ==
'MODIS':
85 dirs.append(self.
sensor[
'dir'])
88 sensor = self.
sensor[
'sensor'].lower()
92 if self.
sensor[
'instrument']
in [
'MODIS',
'VIIRS',
'OCI']:
93 caldirs = [
'cal',
'xcal']
94 for caldir
in caldirs:
95 dirs.append(os.path.join(sensor, caldir,
'OPER'))
97 dirs.append(os.path.join(sensor, caldir,
'EVAL'))
100 # Uncomment this section if we ever reorganize $OCVARROOT to match $OCDATAROOT
101 dirs.append(self.sensor['dir'])
102 subdir = self.sensor.get('subdir')
104 dirs.append(os.path.join(self.sensor['dir'], subdir))
113 query =
'?format=json'
117 url = os.path.join(self.
site_root, d,
'') + query
118 dirpath = os.path.join(self.
localroot, d)
121 print(
'Downloading files into ' + dirpath)
125 newfiles = self.
session.download_allfiles(
128 regex=
"(?m)^(?!.*(?:gbr100|gbrReflectance|LandWater15ARC|VIIRS_DARKTARGET_LUT)).*$",
134 new1 = self.
session.download_allfiles(
137 regex=
'^((?!\d+).)*' + suffix, check_times=
True)
142 new2 = self.
session.download_allfiles(
145 regex=suffix, check_times=
False)
149 newfiles = new1 + new2
152 if len(newfiles) == 0:
154 print(
'...no new files.')
156 downloaded.append(newfiles)
def __init__(self, mission=None, verbose=False, evalluts=False, timeout=10, clobber=False, dry_run=False)
def lut_version(lut_name)
def purge_luts(newfiles, verbose=False)
def any_version(lut_name)