From 8b36f8575720a381c99ed33a30cf649805452067 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Mon, 21 Nov 2022 17:27:02 +0100 Subject: [PATCH] Bug fix: require `grid_nml.txt` if `args.grid` This bug comes from commit cd8df9d. --- Inst_eddies/Analysis/plot_eddy_contours.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Inst_eddies/Analysis/plot_eddy_contours.py b/Inst_eddies/Analysis/plot_eddy_contours.py index 0ea731b3..71d0a9af 100755 --- a/Inst_eddies/Analysis/plot_eddy_contours.py +++ b/Inst_eddies/Analysis/plot_eddy_contours.py @@ -167,17 +167,10 @@ if __name__ == "__main__": parser.add_argument("--save", metavar = "format", help = "Save file to specified format") args = parser.parse_args() - - 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 + file = path.join(args.shpc_dir, "grid_nml.txt") if args.grid: + grid_nml = f90nml.read(file)["grid_nml"] width = (grid_nml["NLON"] - 1) * grid_nml["STEP_DEG"][0] height = (grid_nml["NLat"] - 1) * grid_nml["STEP_DEG"][1] longitude = np.linspace(grid_nml["CORNER_DEG"][0], @@ -186,6 +179,12 @@ if __name__ == "__main__": latitude = np.linspace(grid_nml["CORNER_DEG"][1], grid_nml["CORNER_DEG"][1] + height, 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: llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat = args.window -- GitLab