|
63 | 63 | import shutil # For OS-friendly file operations |
64 | 64 | import functools # For function decorators |
65 | 65 | import traceback # For printing stack traces |
| 66 | +import shutil # For copy/pasting fixed file after -split |
66 | 67 |
|
67 | 68 | # Load amesCAP modules |
68 | 69 | from amescap.Ncdf_wrapper import (Ncdf, Fort) |
@@ -986,12 +987,23 @@ def split_files(file_list, split_dim): |
986 | 987 | ) |
987 | 988 | exit() |
988 | 989 |
|
989 | | - if split_dim in ('time', 'areo'): |
990 | | - time_dim = (np.squeeze(fNcdf.variables['time'][:]))[indices] |
991 | | - print(f"time_dim = {time_dim}") |
992 | | - |
993 | 990 | fpath = os.path.dirname(input_file_name) |
994 | 991 | fname = os.path.basename(input_file_name) |
| 992 | + |
| 993 | + if split_dim in ('time', 'areo'): |
| 994 | + time_dim = (np.squeeze(fNcdf.variables['time'][:]))[indices] |
| 995 | + print(f"time_dim = {time_dim}\n") |
| 996 | + |
| 997 | + try: |
| 998 | + org_fixed_file = (os.path.normpath(os.path.join(fpath, f"{original_date}.fixed.nc"))) |
| 999 | + new_fixed_file = (os.path.normpath(os.path.join(fpath, f"{int(time_dim[0]):05d}.fixed.nc"))) |
| 1000 | + shutil.copyfile(org_fixed_file, new_fixed_file) |
| 1001 | + print(f"File {original_date}.fixed.nc copied to {int(time_dim[0]):05d}.fixed.nc.\n") |
| 1002 | + except FileNotFoundError: |
| 1003 | + print(f"{Red}No compatible fixed file for {fname} (e.g., {original_date}.fixed.nc) was found in {fpath}{Nclr}\n") |
| 1004 | + except Exception as e: |
| 1005 | + print(f"{Red}An error occurred: {e}\n") |
| 1006 | + |
995 | 1007 | if split_dim == 'time': |
996 | 1008 | if len(np.atleast_1d(bounds)) < 2: |
997 | 1009 | base_name = (f"{int(time_dim):05d}{fname[5:-3]}_nearest_sol" |
|
0 commit comments