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

Move argument parsing to main part of the script

parent e4587446
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,6 @@ that is special to surface ocean current coming from AVISO ADT files.
"""
import sys
import argparse
import numpy as np
import cartopy.crs as ccrs
......@@ -15,37 +14,8 @@ import netCDF4
import wind_cartopy
def plot_velocity():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"-s",
"--scale",
default=20,
type=float,
help="scale of arrows for the velocity field",
)
parser.add_argument(
"-w",
"--window",
help="choose a limited plot window",
type=float,
nargs=4,
metavar=("llcrnrlon", "llcrnrlat", "urcrnrlon", "urcrnrlat"),
)
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()
def plot_velocity(args):
with netCDF4.Dataset(args.input_file) as f:
if "lon" in f.variables:
lon = "lon"
......@@ -126,5 +96,37 @@ def plot_velocity():
else:
plt.show()
if __name__ == "__main__":
plot_velocity()
import argparse
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"-s",
"--scale",
default=20,
type=float,
help="scale of arrows for the velocity field",
)
parser.add_argument(
"-w",
"--window",
help="choose a limited plot window",
type=float,
nargs=4,
metavar=("llcrnrlon", "llcrnrlat", "urcrnrlon", "urcrnrlat"),
)
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()
plot_velocity(args)
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