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

Open the input file only once

parent 23cfb7d3
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,13 @@ with netCDF4.Dataset(args.input_file) as f:
longitude = f[lon][:]
latitude = f[lat][:]
if "time" in f["ugos"].dimensions:
ugos = f["ugos"][0]
vgos = f["vgos"][0]
else:
ugos = f["ugos"][:]
vgos = f["vgos"][:]
if args.window is None:
lon_mask = np.ones(len(longitude), dtype = bool)
lat_mask = np.ones(len(latitude), dtype = bool)
......@@ -55,14 +62,6 @@ projection = ccrs.PlateCarree()
fig = plt.figure()
ax = plt.axes(projection = projection)
with netCDF4.Dataset(args.input_file) as f:
if "time" in f["ugos"].dimensions:
ugos = f["ugos"][0]
vgos = f["vgos"][0]
else:
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],
......
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