Commit e37e4e88 authored by Espen Sollum's avatar Espen Sollum
Browse files

After merging, before adding parallelization

parent a525511f
......@@ -102,7 +102,7 @@ def PlotIASIFilteredGeo(nc_directory,
# Extract date info to check for date limits, and use for plot title
fnbits = f.split('/')
fnpng = fnbits[len(fnbits)-1]
fnpng = plot_directory + fnpng.replace(f.split('.')[-1],'png')
fnpng = os.path.join(plot_directory, fnpng.replace(f.split('.')[-1],'png'))
if old_iasi:
ydm = re.findall("[0-9]{8}",fnpng)[0]
hms = re.findall("[0-9]_[0-9]{6}",fnpng)[0]
......@@ -120,6 +120,15 @@ def PlotIASIFilteredGeo(nc_directory,
del(s)
continue
####################################################################
### Skip if file already exists TODO add --force option
if os.path.isfile(fnpng):
del(s)
if verbose:
print("File alredy exists, skipping ", fnpng)
continue
####################################################################
### Check if swath within geographic bounds
####################################################################
......
......@@ -18,6 +18,7 @@ import atexit
import numpy as np
import importlib
import datetime as dt
import config
importlib.reload(IASITools)
......@@ -29,7 +30,8 @@ importlib.reload(IASITools)
#IASI_PATH = "/sat_data_from_fred/eumetcast/EPS-11/"
# local files / 2010 Eyja
IASI_PATH = "/home/eso/repos/ash-iasi/data/0416/"
#IASI_PATH = "/home/eso/repos/ash-iasi/data/0416/"
IASI_PATH = config.IASI_PATH
### Paths to output
### locally for testing @betty
......@@ -41,8 +43,11 @@ IASI_PATH = "/home/eso/repos/ash-iasi/data/0416/"
# PNG_OUT = "/home/eso/repos/ash-iasi/Plots/"
#### for met.no
NETCDF_OUT = "/viper/nadir/nvap/IASI/"
PNG_OUT = "/viper/nadir/nvap/IASI/"
#NETCDF_OUT = "/viper/nadir/nvap/IASI/"
#PNG_OUT = "/viper/nadir/nvap/IASI/"
NETCDF_OUT = config.NETCDF_OUT
PNG_OUT = config.PNG_OUT
args = None
def at_exit(file_name):
......@@ -137,6 +142,8 @@ if __name__ == "__main__":
args = parser.parse_args()
verbose = args.verbose
# Check input arguments
if (not args.write_png) and (not args.write_ncf):
print("Nothing to do (give at least one of -p, -n)")
......@@ -154,8 +161,9 @@ if __name__ == "__main__":
# Start by clearing the netcdf output directory for files older that 14 days
IASITools.remove_old_files(NETCDF_OUT, 14, False, dry_run=False)
# Start by clearing the netcdf output directory for files older than
# (default) 14 days
IASITools.remove_old_files(NETCDF_OUT, config.DAYS_TO_KEEP, verbose, dry_run=False)
path = IASI_PATH
......@@ -208,18 +216,18 @@ if __name__ == "__main__":
# Skip if netcdf already processed
if args.write_ncf and os.path.exists(fnncf) and not args.force_run:
print("Netcdf file already exists, skipping")
print(fnncf)
ii = ii + 1
continue
print("Netcdf file already exists, skipping")
print(fnncf)
ii = ii + 1
continue
# Skip if input file less limit (some files seems to contain only 1 scan line
# and gives problems plotting?)
# Tka into account that the file may have been deleted since start of processing
# Take into account that the file may have been deleted since start of processing
try:
if os.path.getsize(fn) < 2.9*1.e7:
if os.path.getsize(fn) < 2.9*1.e7:
print("Skipping file (likely corrupted due to file size):", fn)
ii = ii + 1
continue
......@@ -251,8 +259,8 @@ if __name__ == "__main__":
continue
except Exception as e:
print("Error", e)
ii = ii + 1
continue
ii = ii + 1
continue
# Remove lock file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment