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

Accept multiple SHPC as command line arguments

parent 3ba95458
No related branches found
No related tags found
No related merge requests found
......@@ -178,8 +178,8 @@ if __name__ == "__main__":
action = "store_true")
parser.add_argument("--dashed", action = "store_true",
help = "dashed linestyle, useful for a second snapshot")
parser.add_argument("shpc_dir", help = "directory containing the "
"collection of shapefiles")
parser.add_argument("shpc_dir", help = "directories containing the "
"collections of shapefiles", nargs = "+")
parser.add_argument("--save", metavar = "format",
help = "Save file to specified format")
args = parser.parse_args()
......@@ -225,7 +225,7 @@ if __name__ == "__main__":
ax.plot(lon_2d.reshape(-1), lat_2d.reshape(-1), transform = src_crs,
marker = "+", color = "gray", linestyle = "None")
if args.window is None: plot_grid_bb(args.shpc_dir, ax)
if args.window is None: plot_grid_bb(args.shpc_dir[0], ax)
if args.velocity:
with netCDF4.Dataset("uv.nc") as f:
......@@ -239,28 +239,30 @@ if __name__ == "__main__":
plt.quiverkey(quiver_return, 0.9, 0.9, 1, r"1 m s$^{-1}$",
coordinates = "figure")
readers, d_init, ishape_last = util_eddies.open_shpc(args.shpc_dir)
for shpc_dir in args.shpc_dir:
readers, d_init, ishape_last = util_eddies.open_shpc(shpc_dir)
if ishape_last is None:
print("We will use all the shapes.")
ishape_last = [len(readers["extremum"]) - 1]
if len(ishape_last) == 1:
if args.date is not None and args.date != d_init:
sys.exit("Bad value of option k")
d = d_init
else:
if args.date is None:
print("No option k, plotting first date:", d_init)
if ishape_last is None:
print(f"{shpc_dir}: We will use all the shapes.")
ishape_last = [len(readers["extremum"]) - 1]
if len(ishape_last) == 1:
if args.date is not None and args.date != d_init:
sys.exit(f"{shpc_dir}: Bad value of option k")
d = d_init
else:
d = args.date
if args.date is None:
print(f"{shpc_dir}: No option k, plotting first date:", d_init)
d = d_init
else:
d = args.date
ishape_list = select_ishapes(d, d_init, ishape_last,
readers["extremum"], args.window)
if len(ishape_list) == 0: print("No eddy found")
snapshot(ax, ishape_list, readers, dashed = args.dashed,
light = args.light)
ishape_list = select_ishapes(d, d_init, ishape_last,
readers["extremum"], args.window)
if len(ishape_list) == 0: print(f"{shpc_dir}: No eddy found")
snapshot(ax, ishape_list, readers, dashed = args.dashed,
light = args.light)
ax.set_title(f"d = {d}", y = 1.05)
ax.gridlines(draw_labels = True)
ax.coastlines()
......
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