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

Read `inst_eddies_nml.txt` outside

Read `inst_eddies_nml.txt` out of function
`loop_inst_eddies`. Preparing to modify the date in the namelist in
`inst_eddies_Aviso.py`.
parent d0a84637
No related branches found
No related tags found
No related merge requests found
......@@ -64,7 +64,9 @@ def process_1_file(
writer.writerow([d, elapsed_NCO, elapsed_Fortran])
def loop_inst_eddies(SHPC_dir, files, bbox, d, my_slice, periodic):
def loop_inst_eddies(
SHPC_dir, files, bbox, config_nml_string, d, my_slice, periodic
):
"""`files` is an iterator of file paths. The first file must exist,
others can be missing. bbox is a tuple of four real numbers. `d`
is a date index (integer value) for the first date. my_slice is
......@@ -81,17 +83,6 @@ def loop_inst_eddies(SHPC_dir, files, bbox, d, my_slice, periodic):
+ " not found or not executable"
)
if os.access("inst_eddies_nml.txt", os.R_OK):
print("inst_eddies.loop_inst_eddies: Will use inst_eddies_nml.txt.")
else:
sys.exit(
'inst_eddies.loop_inst_eddies: "inst_eddies_nml.txt" not found '
"-- Aborting"
)
with open("inst_eddies_nml.txt") as f_obj:
config_nml_string = f_obj.read()
nco_instance = nco.Nco()
if os.access(f"{SHPC_dir}/Slice_{my_slice}", os.F_OK):
......@@ -192,11 +183,25 @@ if __name__ == "__main__":
if not os.access(args.file[0], os.F_OK):
sys.exit(args.file[0] + " not found")
if os.access("inst_eddies_nml.txt", os.R_OK):
print("Will use inst_eddies_nml.txt.")
else:
sys.exit('"inst_eddies_nml.txt" not found -- Aborting')
with open("inst_eddies_nml.txt") as f_obj:
config_nml_string = f_obj.read()
d = input("Enter first date index (integer value): ")
d = int(d)
my_slice = input("Enter slice index (integer value): ")
my_slice = int(my_slice)
periodic = input("periodic (t/f)? ")
loop_inst_eddies(
args.SHPC_dir, iter(args.file), args.bbox, d, my_slice, periodic
args.SHPC_dir,
iter(args.file),
args.bbox,
config_nml_string,
d,
my_slice,
periodic,
)
......@@ -10,6 +10,7 @@ import argparse
import datetime
import sys
import glob
import os
from dateutil import parser
......@@ -65,11 +66,20 @@ first_date = parser.parse(args.first_date).date()
last_date = parser.parse(args.last_date).date()
d = (first_date - datetime.date(1950, 1, 1)).days
if os.access("inst_eddies_nml.txt", os.R_OK):
print("Will use inst_eddies_nml.txt.")
else:
sys.exit('"inst_eddies_nml.txt" not found -- Aborting')
with open("inst_eddies_nml.txt") as f_obj:
config_nml_string = f_obj.read()
# We choose to use d as the first date index. We could choose anything.
inst_eddies.loop_inst_eddies(
args.SHPC_dir,
filename_generator(args.template, first_date, last_date),
args.bbox,
config_nml_string,
d,
my_slice=args.slice,
periodic=args.periodic,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment