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

Create files in the current directory

Create `cropped.nc` and `unpacked.nc` in the current
directory. Several instances of script `inst_eddies.py` for different
slices should run in different directories.
parent 76812b2c
No related branches found
No related tags found
No related merge requests found
......@@ -20,8 +20,6 @@ def process_1_file(
bbox,
nco_instance,
nc_file,
cropped_fname,
unpacked_fname,
inst_eddies_exe,
d,
my_slice,
......@@ -37,7 +35,7 @@ def process_1_file(
try:
nco_instance.ncks(
nc_file,
output=cropped_fname,
output="cropped.nc",
options=[
f"--dimension=longitude,{xmin},{xmax}",
f"--dimension=latitude,{ymin},{ymax}",
......@@ -47,14 +45,14 @@ def process_1_file(
print(err.stdout)
raise
nc_file = cropped_fname
nc_file = "cropped.nc"
nco_instance.ncpdq(nc_file, output=unpacked_fname, options=["--unpack"])
nco_instance.ncpdq(nc_file, output="unpacked.nc", options=["--unpack"])
t1 = time.perf_counter()
elapsed_NCO = t1 - t0
t0 = t1
subprocess.run(
[inst_eddies_exe, SHPC_dir, unpacked_fname],
[inst_eddies_exe, SHPC_dir, "unpacked.nc"],
check=True,
input=f"&dates_nml date = {d}, slice = {my_slice}/\n"
+ config_nml_string,
......@@ -110,9 +108,6 @@ def loop_inst_eddies(SHPC_dir, files, bbox, d, my_slice):
# Short names (without blanks):
writer.writerow(["date", "elapsed_NCO", "elapsed_Fortran"])
cropped_fname = f"{SHPC_dir}/Slice_{my_slice}/cropped.nc"
unpacked_fname = f"{SHPC_dir}/Slice_{my_slice}/unpacked.nc"
# First file is out of the loop because it must be present:
nc_file = next(files)
print("inst_eddies.loop_inst_eddies: Date:", d)
......@@ -121,8 +116,6 @@ def loop_inst_eddies(SHPC_dir, files, bbox, d, my_slice):
bbox,
nco_instance,
nc_file,
cropped_fname,
unpacked_fname,
inst_eddies_exe,
d,
my_slice,
......@@ -141,8 +134,6 @@ def loop_inst_eddies(SHPC_dir, files, bbox, d, my_slice):
bbox,
nco_instance,
nc_file,
cropped_fname,
unpacked_fname,
inst_eddies_exe,
d,
my_slice,
......@@ -165,10 +156,10 @@ def loop_inst_eddies(SHPC_dir, files, bbox, d, my_slice):
d += 1
perf_report.close()
os.remove(unpacked_fname)
os.remove("unpacked.nc")
if bbox:
os.remove(cropped_fname)
os.remove("cropped.nc")
if my_slice == 0 and not os.access(f"{SHPC_dir}/n_slices.txt", os.F_OK):
with open(f"{SHPC_dir}/n_slices.txt", "w") as f:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment