diff --git a/bgcval2/bgcvaltools/makeMask.py b/bgcval2/bgcvaltools/makeMask.py index 600cd21a..b0d27569 100644 --- a/bgcval2/bgcvaltools/makeMask.py +++ b/bgcval2/bgcvaltools/makeMask.py @@ -31,6 +31,7 @@ from calendar import month_name from shelve import open as shOpen import os +from glob import glob from bgcval2.Paths.paths import paths from netCDF4 import Dataset import bgcval2.bgcvaltools.bv2tools as bvt @@ -483,11 +484,11 @@ def makeMask(name, newSlice, xt, xz, xy, xx, xd, debug=False): shelveFn = bvt.folder(os.path.join(paths.shelvedir, "MatchingMasks/"))+ newSlice+"_diag_maskMask.shelve" - try: + if len(glob(shelveFn+'*')): + # Shelve already exists: with shOpen(shelveFn) as sh: lldict = sh['lldict'] - - except: + else: lldict = {} print("Bathy mask: before mask:", newSlice, nmask.sum(), 'of',