diff --git a/Inst_eddies/Analysis/plot_velocity.py b/Inst_eddies/Analysis/plot_velocity.py index c92a3de8152e1268cf9c092dbf2e93aee30a89e2..7b343d53fbf992300a05d222983e55f65da69b7a 100755 --- a/Inst_eddies/Analysis/plot_velocity.py +++ b/Inst_eddies/Analysis/plot_velocity.py @@ -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)