diff --git a/Inst_eddies/Analysis/plot_velocity.py b/Inst_eddies/Analysis/plot_velocity.py index 88a9f08b282207389650b31f6a957e6d462d55d6..75718cedef4bee35e25da39745848ac1d04fe5b5 100755 --- a/Inst_eddies/Analysis/plot_velocity.py +++ b/Inst_eddies/Analysis/plot_velocity.py @@ -15,8 +15,8 @@ import netCDF4 import wind_cartopy -def plot_velocity(args): - with netCDF4.Dataset(args.input_file) as f: +def plot_velocity(input_file, window, undefined, scale): + with netCDF4.Dataset(input_file) as f: if "lon" in f.variables: lon = "lon" lat = "lat" @@ -34,11 +34,11 @@ def plot_velocity(args): ugos = f["ugos"][:] vgos = f["vgos"][:] - if args.window is None: + if window is None: lon_mask = np.ones(len(longitude), dtype=bool) lat_mask = np.ones(len(latitude), dtype=bool) else: - llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat = args.window + llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat = window if urcrnrlon - llcrnrlon > 360: sys.exit("bad values of urcrnrlon and llcrnrlon") @@ -62,7 +62,7 @@ def plot_velocity(args): fig = plt.figure() ax = plt.axes(projection=projection) - if args.undefined: + if undefined: undef_velocity = np.logical_or(ugos.mask, vgos.mask) lon_2d, lat_2d = np.meshgrid(longitude, latitude) ax.plot( @@ -80,7 +80,7 @@ def plot_velocity(args): latitude, ugos[lat_mask][:, lon_mask], vgos[lat_mask][:, lon_mask], - scale=args.scale, + scale=scale, scale_units="width", ) ax.quiverkey( @@ -124,7 +124,9 @@ if __name__ == "__main__": ) parser.add_argument("input_file", help="NetCDF file containing velocity") args = parser.parse_args() - fig = plot_velocity(args) + fig = plot_velocity( + args.input_file, args.window, args.undefined, args.scale + ) if args.save: fig.savefig(f"plot_velocity.{args.save}")