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

Bug fix: require `grid_nml.txt` if `args.grid`

This bug comes from commit cd8df9d2.
parent 787726e0
No related branches found
No related tags found
No related merge requests found
...@@ -167,17 +167,10 @@ if __name__ == "__main__": ...@@ -167,17 +167,10 @@ if __name__ == "__main__":
parser.add_argument("--save", metavar = "format", parser.add_argument("--save", metavar = "format",
help = "Save file to specified format") help = "Save file to specified format")
args = parser.parse_args() args = parser.parse_args()
file = path.join(args.shpc_dir, "grid_nml.txt")
if args.grid or args.window is None:
file = path.join(args.shpc_dir, "grid_nml.txt")
try:
grid_nml = f90nml.read(file)["grid_nml"]
except FileNotFoundError:
print("grid_nml.txt not found. Will not plot bounding box.")
grid_nml = None
if args.grid: if args.grid:
grid_nml = f90nml.read(file)["grid_nml"]
width = (grid_nml["NLON"] - 1) * grid_nml["STEP_DEG"][0] width = (grid_nml["NLON"] - 1) * grid_nml["STEP_DEG"][0]
height = (grid_nml["NLat"] - 1) * grid_nml["STEP_DEG"][1] height = (grid_nml["NLat"] - 1) * grid_nml["STEP_DEG"][1]
longitude = np.linspace(grid_nml["CORNER_DEG"][0], longitude = np.linspace(grid_nml["CORNER_DEG"][0],
...@@ -186,6 +179,12 @@ if __name__ == "__main__": ...@@ -186,6 +179,12 @@ if __name__ == "__main__":
latitude = np.linspace(grid_nml["CORNER_DEG"][1], latitude = np.linspace(grid_nml["CORNER_DEG"][1],
grid_nml["CORNER_DEG"][1] + height, grid_nml["CORNER_DEG"][1] + height,
grid_nml["NLat"]) grid_nml["NLat"])
elif args.window is None:
try:
grid_nml = f90nml.read(file)["grid_nml"]
except FileNotFoundError:
print("grid_nml.txt not found. Will not plot bounding box.")
grid_nml = None
if args.window is not None: if args.window is not None:
llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat = args.window llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat = args.window
......
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