-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from ocefpaf/cli
command line saver
- Loading branch information
Showing
6 changed files
with
92 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
from docopt import docopt | ||
|
||
from gridgeo import GridGeo | ||
|
||
__doc__ = """ | ||
Save a GeoJSON or ESRI Shapefile representation of an ocean model grid. | ||
Usage: | ||
gridio URL VAR --output=OUTFILE | ||
gridio (-h | --help -o | --output) | ||
Examples: | ||
gridio netcdf-file.nc sea_water_temperature --output=grid.shp | ||
gridio remote-opendap-url sea_water_temperature --output=grid.geojson | ||
Arguments: | ||
directory Configuration directory. | ||
Options: | ||
-h --help Show this screen. | ||
-o OUTFILE --output=OUTFILE Output file | ||
""" | ||
|
||
|
||
def parse_args(): | ||
args = docopt(__doc__) | ||
return args | ||
|
||
|
||
def cli(args): | ||
url = args.get('URL') | ||
standard_name = args.get('VAR') | ||
filename = args.get('--output') | ||
|
||
grid = GridGeo(url, standard_name=standard_name) | ||
grid.save(filename, float_precision=4) | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
cli(args) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters