From 23cfb7d323dafed5bf2b7694a655f4131c5b2278 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Mon, 24 Apr 2023 23:05:07 +0200 Subject: [PATCH] Finish the `with` statement earlier --- Inst_eddies/Analysis/plot_velocity.py | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Inst_eddies/Analysis/plot_velocity.py b/Inst_eddies/Analysis/plot_velocity.py index 9092e9c6..e5594b7d 100755 --- a/Inst_eddies/Analysis/plot_velocity.py +++ b/Inst_eddies/Analysis/plot_velocity.py @@ -63,22 +63,22 @@ with netCDF4.Dataset(args.input_file) as f: ugos = f["ugos"][:] vgos = f["vgos"][:] - if args.undefined: - undef_velocity = np.logical_or(ugos.mask, vgos.mask) - lon_2d, lat_2d = np.meshgrid(longitude[lon_mask], - latitude[lat_mask]) - ax.plot(lon_2d[undef_velocity].reshape(-1), - lat_2d[undef_velocity].reshape(-1), transform = src_crs, - marker = "*", color = "violet", linestyle = "None") - else: - quiver_return = wind_cartopy.plot(ax, longitude[lon_mask], - latitude[lat_mask], - ugos[lat_mask][:, lon_mask], - vgos[lat_mask][:, lon_mask], - scale = args.scale, - scale_units = "width") - ax.quiverkey(quiver_return, 0.9, 0.9, 1, r"1 m s$^{-1}$", - coordinates = "figure") +if args.undefined: + undef_velocity = np.logical_or(ugos.mask, vgos.mask) + lon_2d, lat_2d = np.meshgrid(longitude[lon_mask], + latitude[lat_mask]) + ax.plot(lon_2d[undef_velocity].reshape(-1), + lat_2d[undef_velocity].reshape(-1), transform = src_crs, + marker = "*", color = "violet", linestyle = "None") +else: + quiver_return = wind_cartopy.plot(ax, longitude[lon_mask], + latitude[lat_mask], + ugos[lat_mask][:, lon_mask], + vgos[lat_mask][:, lon_mask], + scale = args.scale, + scale_units = "width") + ax.quiverkey(quiver_return, 0.9, 0.9, 1, r"1 m s$^{-1}$", + coordinates = "figure") ax.gridlines(draw_labels = True) ax.coastlines() -- GitLab