Skip to content
Snippets Groups Projects
Commit 33341133 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Generalize allowed input file names

I do not see a better way than to ask the user to provide the template
of basename as an additional argument. We cannot do as in
`Convert_Matlab/inst_eddies_v6.py`, that is try a list of templates,
because here the file names could be anything.
parent da752f21
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ parser = argparse.ArgumentParser()
parser.add_argument("first_file",
help = "NetCDF file containing SSH and velocity at a "
"single date")
parser.add_argument("date_format", help = "format of basename")
parser.add_argument("-l", "--last_date", help = "%%Y-%%m-%%d")
parser.add_argument("-b", "--bbox", nargs=4, type = float,
metavar = ("xmin", "xmax", "ymin", "ymax"))
......@@ -29,9 +30,7 @@ if not os.access(inst_eddies_exe, os.X_OK):
if os.access("SHPC_all_dates", os.F_OK): shutil.rmtree("SHPC_all_dates")
dirname, basename = path.split(args.first_file)
my_date = datetime.datetime.strptime(basename,
"dt_global_allsat_phy_l4_%Y%m%d"
"_20190101.nc").date()
my_date = datetime.datetime.strptime(basename, args.date_format).date()
nc_file = args.first_file
nco_instance = nco.Nco()
......@@ -89,7 +88,7 @@ while True:
my_date += datetime.timedelta(1)
if my_date > last_date: break
basename = my_date.strftime("dt_global_allsat_phy_l4_%Y%m%d_20190101.nc")
basename = my_date.strftime(args.date_format)
nc_file = path.join(dirname, basename)
os.remove("unpacked.nc")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment