diff --git a/bin/chkDataSize.sh b/bin/chkDataSize.sh deleted file mode 100755 index a432d92..0000000 --- a/bin/chkDataSize.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -########################################### -# script to make sure data is being purged -########################################### -# -ddtt=`date` -echo "------- `date` --------" -#echo "/awips2/data" -du /awips2/data -sh -#echo "/awips2/edex/data/hdf5" -du /awips2/edex/data/hdf5 -sh -echo "---------------------------------------------" - diff --git a/bin/getGINAsat.py b/bin/getGINAsat.py index f847948..594f38f 100755 --- a/bin/getGINAsat.py +++ b/bin/getGINAsat.py @@ -1,5 +1,9 @@ #!/usr/bin/env /awips2/python/bin/python +<<<<<<< HEAD +import urllib +======= +>>>>>>> 1c9d57602131d49629efe5254a5c0dcaca5f1b09 import urllib.request import datetime import os, sys @@ -171,7 +175,11 @@ def main(): continue print ("FILENAME={}".format(filename)) +<<<<<<< HEAD + urllib.urlretrieve(fileurl, filename) +======= urllib.request.urlretrieve(fileurl, filename) +>>>>>>> 1c9d57602131d49629efe5254a5c0dcaca5f1b09 if os.path.isfile(filename): fsize = os.path.getsize(filename) dcount += 1 diff --git a/bin/procldm.sh b/bin/procldm.sh deleted file mode 100755 index ab8a701..0000000 --- a/bin/procldm.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -############################ -yyyymmdd=`date +%Y%m%d` -#( -ingestDir="/awips2/edex/data/manual" -srcDir="/data_store/download" -# -cd $srcDir -# first look for the compressed GINA files -for filenm in `ls $srcDir` -do - #filenm=`echo $filenm | sed 's/.VIIRS_ALASK//'` - if echo $filenm | grep -q "gzVIIRS_ALASK" - then - newfilenm=`echo $filenm | sed 's/gzVIIRS_ALASK/gz/'` - mv $filenm $newfilenm - filenm=$newfilenm - fi - # - if echo $filenm | grep -q ".gz" - then - gunzip $srcDir/$filenm - filenm="${filenm%.*}" - fi - # - if echo $filenm | grep -q "SSEC" - then - gunzip -c $filenm > $filenm".nc" - rm -f $filenm - filenm=$filenm".nc" - fi - # - newfilenm="Alaska_"$filenm - echo "mv $filenm $ingestDir/$newfilenm" - mv $filenm $ingestDir/$newfilenm -done - -# -#) >> /awips2/edex/logs/edex-ingest-LDMsat-$yyyymmdd".log" 2>&1 - diff --git a/bin/showdstore.py b/bin/showdstore.py index f551572..24a914f 100755 --- a/bin/showdstore.py +++ b/bin/showdstore.py @@ -1,5 +1,6 @@ #!/awips2/python/bin/python3 """Get all the files in datastore netcdf file.""" + import argparse import os from datetime import datetime, timedelta @@ -9,12 +10,22 @@ "aqua": "aqua", "noaa21": "noaa21", "noaa20": "noaa20", - "n20": "n20", "noaa19": "noaa19", "noaa18": "noaa18", "metopc": "metopc", "metopb": "metopb", + "n21": "noaa21", + "N21": "noaa21", + "n20": "noaa20", + "j01": "noaa20", + "n19": "noaa19", + "n18": "noaa18", "npp": "s-npp", + "moc": "metopc", + "mob": "metopb", + "ma3": "metopc", + "ma1": "metopb", + "GW1": "amsr2", } def _process_command_line(): @@ -25,16 +36,18 @@ def _process_command_line(): parser.add_argument('-d', '--day', action='store', help='day of month to search') parser.add_argument('-t', '--type', action='store', default='regionalsat', help='type of file (goesr, grib, nucaps, regionalsat)') parser.add_argument('-m', '--match', action='store', help='string pattern to match') + parser.add_argument('-n', '--nws', action='store_true', help='use nws archivedirectory') + parser.add_argument('-e', '--exclude', action='store', help='string pattern to exclude') parser.add_argument('-lo', '--latencyonly', action='store_true', help='show latency summary') parser.add_argument('-fl', '--filelatency', action='store_true', help='compare file date and time stamp') parser.add_argument('-po', '--passesonly', action='store_true', help='show pass time, satellite, and sensor only') parser.add_argument('-s', '--tstamp', action='store_true', help='show time stamps only') parser.add_argument('-b', '--abbrev', action='store_true', help='abbreviate results') parser.add_argument('-v', '--verbose', action='store_true', help='verbose flag') - parser.add_argument('-e', '--exclude', action='store', help='string pattern to exclude') args = parser.parse_args() return args + def getvalidtime(path, ftype, verbose): """ extract the valid date and time from the filename. """ fname = os.path.basename(path) @@ -45,29 +58,18 @@ def getvalidtime(path, ftype, verbose): sensor = "" fplen = len(fparts) if ftype == "goesr": + ### SCMI DB Imagery (VIIRS, MODIS, AVHRR) if "Polar" in path: idx = fparts.index("Polar") datestr = fparts[idx+2] timestr = fparts[idx+3] - vyr = int(datestr[:4]) - vmo = int(datestr[4:6]) - vda = int(datestr[6:8]) - vhr = int(timestr[0:2]) - vmn = int(timestr[2:4]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") - for keyword, value in satellites.items(): - if keyword in path: - idx = fparts.index(keyword) - satellite = fparts[idx] - sensor = fparts[idx+1] - if satellite == "n20": - satellite = "noaa20" - break + vsecs, dtstr = parse_file_time(datestr, timestr,4) + satellite, sensor = get_sat_sensor(path, fparts) + ### GOES-18 from Unidata elif "G18" in path: idx = fparts.index("G18") - datestr = fparts[idx+2] + ## date string has day of year instead of month & day + datestr = fparts[idx+1] vyr = int(datestr[1:5]) vjd = int(datestr[5:8]) vhr = int(datestr[8:10]) @@ -84,109 +86,97 @@ def getvalidtime(path, ftype, verbose): if verbose: print ("Unknown {} file: {}".format(ftype, path)) vsecs = 0 + ### Regionalsat format for special products elif ftype == "regionalsat": - if "sport" in path: + if "sport" in path: ### sport microwave products idx = fparts.index("sport") datestr = fparts[idx-2] timestr = fparts[idx-1] - vyr = int(datestr[:4]) - vmo = int(datestr[4:6]) - vda = int(datestr[6:8]) - vhr = int(timestr[0:2]) - vmn = int(timestr[2:4]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") - elif "VSCD-AK" in path: + vsecs,dtstr = parse_file_time(datestr, timestr,4) + satellite = "noaa" + sensor = "microwave" + elif "VSCD-AK" in path: ### CIRA SnowCloud Discriminator idx = fparts.index("VIIRS") datestr = fparts[idx+1] timestr = fparts[idx+2] - vyr = int(datestr[:2]) + 2000 - vmo = int(datestr[2:4]) - vda = int(datestr[4:6]) - vhr = int(timestr[0:2]) - vmn = int(timestr[2:4]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") - elif "RIVER" in path: + vsecs,dtstr = parse_file_time(datestr, timestr,2) + satellite = "noaa" + sensor = "viirs" + elif "OMPS-AK" in path: ### OMPS Products idx = fparts.index("1KM") datestr = fparts[idx+2] timestr = fparts[idx+3] - vyr = int(datestr[:4]) - vmo = int(datestr[4:6]) - vda = int(datestr[6:8]) - vhr = int(timestr[0:2]) - vmn = int(timestr[2:4]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") + vsecs,dtstr = parse_file_time(datestr, timestr,2) + satellite = "noaa" + sensor = "omps" + elif "VIIRS-AK" in path: ### VIIRS Volcano Index products + idx = fparts.index("1KM") + datestr = fparts[idx+2] + timestr = fparts[idx+3] + vsecs,dtstr = parse_file_time(datestr, timestr,2) + satellite = "noaa" + sensor = "viirs" + elif "RIVER" in path: ### RiverFlood Products + idx = fparts.index("1KM") + datestr = fparts[idx+2] + timestr = fparts[idx+3] + vsecs,dtstr = parse_file_time(datestr, timestr,4) + satellite = "noaa" + sensor = "viirs" else: if verbose: - print ("Unknown {} file: {}".format(ftype, path)) + print ("Unknown {} file: {}".format(ftype, fname)) vsecs = 0 dtstr = "" - elif ftype == "nucaps": - pathparts=path.split('/') - pdx = pathparts.index("nucaps") - datestr = pathparts[pdx+1] - idx = fparts.index("KNES") - timestr = fparts[idx+1] - vyr = int(datestr[:4]) - vmo = int(datestr[4:6]) - vda = int(datestr[6:8]) - vhr = int(timestr[2:4]) - vmn = int(timestr[4:6]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") + ### Pointset data type for Microwave products elif ftype == "pointset": - if "v2r2" in path: + if "v2r2" in path: ### AMSR2 and SFR products idx = fparts.index("v2r2") - datestr = fparts[idx+2] - vyr = int(datestr[1:5]) - vmo = int(datestr[5:7]) - vda = int(datestr[7:9]) - vhr = int(datestr[9:11]) - vmn = int(datestr[11:13]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") + datestr = fparts[idx+2][1:9] + timestr = fparts[idx+2][9:13] + vsecs,dtstr = parse_file_time(datestr, timestr,4) + satellite, sensor = get_sat_sensor(path, fparts) + sensor = "microwave" + elif "v11r8" in path: ### MIRS products + idx = fparts.index("v11r8") + datestr = fparts[idx+2][1:9] + timestr = fparts[idx+2][9:13] + vsecs,dtstr = parse_file_time(datestr, timestr,4) + satellite, sensor = get_sat_sensor(path, fparts) + sensor = "microwave" + elif "v3r0" in path: ### VIIRS JRR products + idx = fparts.index("v3r0") + datestr = fparts[idx+2][1:9] + timestr = fparts[idx+2][9:13] + vsecs,dtstr = parse_file_time(datestr, timestr,4) + satellite, sensor = get_sat_sensor(path, fparts) + sensor = "microwave" else: if verbose: print ("Unknown {} file: {}".format(ftype, path)) vsecs = 0 dtstr = "" + ### CMORPH2 data on LatLon Grid elif ftype == "netcdfGrid": if "CMORPH2" in path: idx = fparts.index("0.05deg-30min") - datestr = fparts[idx+1] - vyr = int(datestr[:4]) - vmo = int(datestr[4:6]) - vda = int(datestr[6:8]) - vhr = int(datestr[8:10]) - vmn = int(datestr[10:12]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") + datestr = fparts[idx+1][:8] + timestr = fparts[idx+1][8:12] + vsecs,dtstr = parse_file_time(datestr, timestr,4) + satellite = "multiple" + sensor = "microwave" else: if verbose: - print ("Unknown {} file: {}".format(ftype, path)) + print ("Unknown {} file: {}".format(ftype, fname)) vsecs = 0 dtstr = "" + ### VIIRS Active Fire Detections elif ftype == "dmw": if "UAF" in path: idx = fparts.index("UAF") datestr = fparts[idx+4] - timestr = fparts[idx+4] - vyr = int(datestr[:4]) - vmo = int(datestr[4:6]) - vda = int(datestr[6:8]) - vhr = int(timestr[9:11]) - vmn = int(timestr[11:13]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") + timestr = fparts[idx+4][9:13] + vsecs,dtstr = parse_file_time(datestr, timestr,4) satellite = fparts[idx+3] sensor = fparts[idx+1] else: @@ -194,24 +184,21 @@ def getvalidtime(path, ftype, verbose): print ("Unknown {} file: {}".format(ftype, path)) vsecs = 0 dtstr = "" + ### MIMIC TPW from CIMSS elif ftype == "grib": if "TPW" in path: idx = fparts.index("TPW") datestr = fparts[idx+1] timestr = fparts[idx+2] - vyr = int(datestr[:4]) - vmo = int(datestr[4:6]) - vda = int(datestr[6:8]) - vhr = int(timestr[0:2]) - vmn = int(timestr[2:4]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") + vsecs,dtstr = parse_file_time(datestr, timestr,4) + satellite = "multiple" + sensor = "microwave" else: if verbose: print ("Unknown {} file: {}".format(ftype, path)) vsecs = 0 dtstr = "" + ### DB NUCAPS from HEAP elif ftype == "griddednucaps": if "KNES" in path: idx = fparts.index("KNES") @@ -219,15 +206,23 @@ def getvalidtime(path, ftype, verbose): diridx = dir.index("griddednucaps") subdirdatestr = dir[diridx + 1] datestr = subdirdatestr - timestr = fparts[idx+1] - vyr = int(datestr[:4]) - vmo = int(datestr[4:6]) - vda = int(datestr[6:8]) - vhr = int(timestr[2:4]) - vmn = int(timestr[4:6]) - vtime = datetime(vyr, vmo, vda, vhr, vmn) - vsecs = int(vtime.strftime("%s")) - dtstr = vtime.strftime("%y%m%d_%H%M") + timestr = fparts[idx+1][2:6] + vsecs,dtstr = parse_file_time(datestr, timestr,4) + else: + if verbose: + print ("Unknown {} file: {}".format(ftype, path)) + vsecs = 0 + dtstr = "" + ### DB NUCAPS from HEAP if not gridded + elif ftype == "nucaps": + if "KNES" in path: + idx = fparts.index("KNES") + dir = path.split("/") + diridx = dir.index("nucaps") + subdirdatestr = dir[diridx + 1] + datestr = subdirdatestr + timestr = fparts[idx+1][2:6] + vsecs,dtstr = parse_file_time(datestr, timestr,4) else: if verbose: print ("Unknown {} file: {}".format(ftype, path)) @@ -235,22 +230,33 @@ def getvalidtime(path, ftype, verbose): dtstr = "" return (vsecs, dtstr, satellite, sensor) -#def get_passes_by_type(path, ddttstr, sat, snsr, passes): -# """Get passes for a specific file type and date.""" -# args = _process_command_line() -# date = str(ddttstr)[:6] -# time = str(ddttstr)[7:] -# if sat: -# if args.match is None: -# format_pass = f"{date}\t{time} {sat}\t {snsr}\n" -# passes.append(format_pass) -# elif args.match.startswith(f"{snsr}_"): -# format_pass = f"{date}\t{time} {sat}\t {snsr}\n" -# passes.append(format_pass) -# elif args.match == snsr: -# format_pass = f"{date}\t{time} {sat}\t {snsr}\n" -# passes.append(format_pass) -# return passes + +def parse_file_time(datestr, timestr,yrlen): + if yrlen == 4: + vyr = int(datestr[:4]) + vmo = int(datestr[4:6]) + vda = int(datestr[6:8]) + elif yrlen == 2: + vyr = int(datestr[:2]) + 2000 + vmo = int(datestr[2:4]) + vda = int(datestr[4:6]) + vhr = int(timestr[:2]) + vmn = int(timestr[2:4]) + vtime = datetime(vyr, vmo, vda, vhr, vmn) + vsecs = int(vtime.strftime("%s")) + dtstr = vtime.strftime("%y%m%d_%H%M") + return (vsecs, dtstr) + + +def get_sat_sensor(path, fparts): + for keyword, value in satellites.items(): + if keyword in path: + satellite = value + idx = fparts.index(keyword) + sensor = fparts[idx+1] + return (satellite, sensor) + return ("unknown", "unknown") + def format_pass(path, ddttstr, sat, snsr): """Get passes for a specific file type and date.""" @@ -260,9 +266,17 @@ def format_pass(path, ddttstr, sat, snsr): return format_pass -def get_filepaths(directory): +def get_filepaths(directory,altpathflag): """Generate the filenames in a directory tree by walking down the tree.""" file_paths = [] + if altpathflag: + for root, directories, files in os.walk(directory): + if "GINA" in root: + for filename in files: + # Join the two strings to form the full path + filepath = os.path.join(root,filename) + file_paths.append(filepath) + for root, directories, files in os.walk(directory): for filename in files: filepath = os.path.join(root, filename) @@ -274,6 +288,11 @@ def main(): basedirectory = "/data_store/manual" passes = [] args = _process_command_line() + altpathflag = 0 + if args.nws: + basedirectory = "/data_store/sat" + altpathflag = 0 + searchpath = "{}/{}".format(basedirectory, args.type) curtime = datetime.utcnow() if args.day is not None: @@ -283,11 +302,11 @@ def main(): subDir = '{}{:02}{:02}'.format(curtime.strftime("%Y"), mon, dom) else: subDir = '{}{:02}'.format(curtime.strftime("%Y%m"), int(args.day)) - paths = get_filepaths('{}/{}'.format(searchpath, subDir)) + paths = get_filepaths('{}/{}'.format(searchpath, subDir), altpathflag) else: subDir = curtime.strftime("%Y%m%d") print(subDir) - paths = get_filepaths('{}/{}'.format(searchpath, subDir)) + paths = get_filepaths('{}/{}'.format(searchpath, subDir), altpathflag) paths.sort(reverse=True) count = 0 unknown = 0 @@ -360,4 +379,4 @@ def main(): print("Unknown products: {}".format(unknown)) if __name__ == '__main__': - main() \ No newline at end of file + main()