From cee3e995731ae64dc094d89487069a3e20c6138d Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Mon, 22 Nov 2021 16:27:22 +0100
Subject: [PATCH] Use only velocity file in `plot_veloicty.py`

And it is then conveninent to choose it from the command line.
---
 Inst_eddies/Analysis/plot_velocity.py | 5 +++--
 Inst_eddies/Analysis/tests.json       | 7 +++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Inst_eddies/Analysis/plot_velocity.py b/Inst_eddies/Analysis/plot_velocity.py
index 9e0d5c4f..f0eb401b 100755
--- a/Inst_eddies/Analysis/plot_velocity.py
+++ b/Inst_eddies/Analysis/plot_velocity.py
@@ -18,9 +18,10 @@ parser.add_argument("--save", metavar = "format",
                     help = "Save file to specified format")
 parser.add_argument("-u", "--undefined", action = "store_true",
                     help = "plot points where velocity is not defined")
+parser.add_argument("input_file", help = "NetCDF file containing velocity")
 args = parser.parse_args()
 
-with netCDF4.Dataset("h.nc") as f:
+with netCDF4.Dataset(args.input_file) as f:
     if "lon" in f.variables:
         lon = "lon"
         lat = "lat"
@@ -53,7 +54,7 @@ projection = ccrs.PlateCarree()
 ##projection = ccrs.NorthPolarStereo()
 ax = plt.axes(projection = projection)
 
-with netCDF4.Dataset("uv.nc") as f:
+with netCDF4.Dataset(args.input_file) as f:
     if args.undefined:
         undef_velocity = np.logical_or(f["ugos"][0].mask, f["vgos"][0].mask)
         lon_2d, lat_2d = np.meshgrid(longitude[lon_mask],
diff --git a/Inst_eddies/Analysis/tests.json b/Inst_eddies/Analysis/tests.json
index ffc08793..b1e8ef7b 100644
--- a/Inst_eddies/Analysis/tests.json
+++ b/Inst_eddies/Analysis/tests.json
@@ -61,11 +61,10 @@
     {
 	"title": "Plot_velocity",
 	"command":
-	["$src_dir/Inst_eddies/Analysis/plot_velocity.py", "--save=png"],
-	"required":
 	[
-	    ["$src_dir/Inst_eddies/Tests/Input/h_region_4.nc", "h.nc"],
-	    ["$src_dir/Inst_eddies/Tests/Input/uv_region_4.nc", "uv.nc"]
+	    "$src_dir/Inst_eddies/Analysis/plot_velocity.py",
+	    "$src_dir/Inst_eddies/Tests/Input/uv_region_4.nc",
+	    "--save=png"
 	]
     },
     {
-- 
GitLab