diff --git a/Inst_eddies/inst_eddies_Aviso.py b/Inst_eddies/inst_eddies_Aviso.py index 97e9e583503a8edbe9281ed532750e84f7962cb3..e885ef8bd508c3a625aeaaa43ea3589730f3d7d3 100644 --- a/Inst_eddies/inst_eddies_Aviso.py +++ b/Inst_eddies/inst_eddies_Aviso.py @@ -10,6 +10,7 @@ import sys from dateutil import parser import netCDF4 import inst_eddies +import glob def filename_generator(first_file, first_date, last_date, template): dirname = path.dirname(first_file) @@ -23,6 +24,18 @@ def filename_generator(first_file, first_date, last_date, template): basename = my_date.strftime(template) nc_file = path.join(dirname, basename) + # The template may contain a wild card as long as there is no + # more than one file matching it. A missing file is ok and + # will be dealt with in inst_eddies.py. + + path_list = glob.glob(nc_file) + + if len(path_list) == 1: + nc_file = path_list[0] + elif len(path_list) >= 2: + sys.exit("inst_eddies_Aviso.py:filename_generator: more than one " + "file matching template") + argparser = argparse.ArgumentParser() argparser.add_argument("first_file", help = "NetCDF file containing SSH and velocity at a " @@ -31,7 +44,8 @@ argparser.add_argument("slice", type = int, help = "slice number to create") argparser.add_argument("--template", help = "template of basename with date.strftime format " - "codes, only used for several dates") + "codes (and possible shell wildcards), only used for " + "several dates") argparser.add_argument("-l", "--last_date", help = "%%Y-%%m-%%d") argparser.add_argument("-b", "--bbox", nargs=4, type = float, metavar = ("xmin", "xmax", "ymin", "ymax"))