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

Create function `plot_grid_bb`

Encapsulate the drawing of the domain box in a function `plot_grid_bb`.
parent bf203990
No related branches found
No related tags found
No related merge requests found
......@@ -151,6 +151,15 @@ def snapshot(shp_tr_dir, k = None, *, dashed = False, light = False,
ax.gridlines(draw_labels = True)
ax.coastlines()
def plot_grid_bb(shp_tr_dir, ax):
file = path.join(shp_tr_dir, "grid_nml.txt")
grid_nml = f90nml.read(file)["grid_nml"]
rect = patches.Rectangle(grid_nml["corner_deg"],
(grid_nml["nlon"] - 1) * 0.25,
(grid_nml["nlat"] - 1) * 0.25, edgecolor="black",
fill=False)
ax.add_patch(rect)
if __name__ == "__main__":
import argparse
import sys
......@@ -210,13 +219,7 @@ if __name__ == "__main__":
ax.plot(lon_2d.reshape(-1), lat_2d.reshape(-1), transform = src_crs,
marker = "+", color = "gray", linestyle = "None")
file = path.join(args.directory, "grid_nml.txt")
grid_nml = f90nml.read(file)["grid_nml"]
rect = patches.Rectangle(grid_nml["corner_deg"],
(grid_nml["nlon"] - 1) * 0.25,
(grid_nml["nlat"] - 1) * 0.25, edgecolor="black",
fill=False)
ax.add_patch(rect)
plot_grid_bb(args.shp_tr_dir, ax)
snapshot(args.shp_tr_dir, args.k, dashed = args.dashed,
light = args.light, window = args.window)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment