Skip to content

Commit

Permalink
Merge pull request #4 from renci-unc/fixargs
Browse files Browse the repository at this point in the history
Fixargs
  • Loading branch information
lstillwe committed Apr 23, 2015
2 parents 47f599e + bb5de04 commit 6b39f10
Show file tree
Hide file tree
Showing 25 changed files with 481 additions and 131 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
Ugrid2Shp
UgridShp
old
*.{prj,cpg,shx,shp,dbf}
*~
README.txt
test_*
*.pyc
*.zip
*.egg-info
*.egg-info
3 changes: 3 additions & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copyright 2015 University of North Carolina. ALL RIGHTS RESERVED.
Use of this software is authorized pursuant to the terms of
the accompanying LICENSE.txt.
3 changes: 3 additions & 0 deletions CREDITS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Brian Blanton ([email protected])
Lisa Stillwell ([email protected])
Chris Calloway ([email protected])
3 changes: 3 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version 1.0 2015-04-23
-------------------------------
- Initial release. (cbc)
5 changes: 5 additions & 0 deletions INSTALL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ pip install ugrid2shp

or

$ python setup.py install
Empty file removed LICENSE
Empty file.
340 changes: 340 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include *.txt
include *.rst
Binary file removed QGIS_test1.png
Binary file not shown.
74 changes: 0 additions & 74 deletions README.md

This file was deleted.

48 changes: 48 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Convert CF-UGRID netCDF files to GIS shapefiles
===============================================

This package computes a GIS shapefile from a CF-UGRID compliant netCDF file.
Contours are generated with matplotlib and then output using shapely and fiona.

To use as a package (using a list of default arguments):

>>> from ugrid2shp import ugrid2shp, defaults
>>> ugrid2shp(defaults)

To use as a script:

usage: ugrid2shp [-h] [-d] [-s] [-w] [-x] [-z] [-n NC_FILE_NAME]
[-o OUTPUT_FILE_NAME] [-v NC_VAR_NAME] [-a MIN_VAL]
[-b MAX_VAL] [-c NUM_LEVELS] [-l X0 Y0 X1 Y1]
[-p PROJECTION_STRING]

optional arguments:
-h, --help show this help message and exit
-d, --debug Display diagnostics. (default: False)
-s, --silent No screen diagnostic output. (default: False)
-w, --writeimage Write matplotlib image to a file <outfile>.png.
(default: False)
-x, --showimage Display matplotlib image, user must close before
continuing. (default: False)
-z, --nozip No zip file output. (default: False)
-n NC_FILE_NAME, --ncfilename NC_FILE_NAME
Path to NetCDF file to read, or a URL to an OPeNDAP
resource. (default: maxele.63.nc)
-o OUTPUT_FILE_NAME, --outfilename OUTPUT_FILE_NAME
Filename to write as shapefile. (default: outShape)
-v NC_VAR_NAME, --ncvarname NC_VAR_NAME
NetCDF variable name to render. (default: zeta_max)
-a MIN_VAL, --minval MIN_VAL
Smallest scalar value to render. (default: 0)
-b MAX_VAL, --maxval MAX_VAL
Largest scalar value to render. (default: 10)
-c NUM_LEVELS, --numlevels NUM_LEVELS
Number of contour levels. (default: 11)
-l X0 Y0 X1 Y1, --axislimits X0 Y0 X1 Y1
Bounding box list of coordinates. (default: [])
-p PROJECTION_STRING, --proj PROJECTION_STRING
Projection string as Well Known Text (WKT). (default:
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS
_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.
0],UNIT["Degree",0.0174532925199433]])

1 change: 1 addition & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0
1 change: 0 additions & 1 deletion __init__.py

This file was deleted.

16 changes: 0 additions & 16 deletions adcirc_local_test.py

This file was deleted.

15 changes: 0 additions & 15 deletions adcirc_thredds_test.py

This file was deleted.

2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[sdist]
formats=zip
57 changes: 44 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
from setuptools import setup, \
find_packages

setup(name='pyugrid',
version='1.0',
packages=find_packages(),
author='Brian O. Blanton',
author_email='[email protected]',
description='Compute GIS shapefiles from a CF-UGRID compliant netCDF file.',
keywords="UGRID CF NetCDF shapefile",
url="https://github.com/renci-unc/ugrid2shp",
test_suite="tests"
)
from setuptools import setup
from setuptools import find_packages


def version():
"""Get the version number."""

with open("VERSION.txt") as v:
_version = v.read()
return _version.strip()


__version__ = version()


def long_description():
"""Construct the long description text."""

with open("README.rst") as r:
long_description_1 = r.read()
with open("HISTORY.txt") as h:
long_description_2 = h.read()
return "\n".join([long_description_1, long_description_2, ])


setup(name='ugrid2shp',
version=__version__,
license="GPL2",
packages=find_packages(),
author='Brian O. Blanton',
author_email='[email protected]',
description='Compute a GIS shapefile '
'from a CF-UGRID compliant netCDF file.',
long_description=long_description(),
url="https://github.com/renci-unc/ugrid2shp",
keywords="UGRID CF NetCDF shapefile",
classifiers=["Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: "
"GNU General Public License v2 (GPLv2)",
"Programming Language :: Python :: 2.7",
"Topic :: Scientific/Engineering :: Atmospheric Science",
"Topic :: Scientific/Engineering :: GIS", ],
zip_safe=False,
test_suite="ugrid2shp.tests")
Binary file removed test1.png
Binary file not shown.
1 change: 0 additions & 1 deletion tests/__init__.py

This file was deleted.

5 changes: 5 additions & 0 deletions ugrid2shp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""The ugrid2shp package."""

from .ugrid2shp import defaults
from .ugrid2shp import parse_args
from .ugrid2shp import ugrid2shp
11 changes: 11 additions & 0 deletions ugrid2shp/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env python

"""
A __main__ namespace for the ugrid2shp package.
"""

import sys
from ugrid2shp import ugrid2shp

if __name__ == '__main__':
ugrid2shp(sys.argv[1:])
1 change: 1 addition & 0 deletions ugrid2shp/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""The ugrid2shp.tests subpackage."""
11 changes: 11 additions & 0 deletions ugrid2shp/tests/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env python

"""
A __main__ namespace for the ugrid2shp package.
"""

import unittest
from ugrid2shp.tests import test_parse_args

if __name__ == '__main__':
unittest.main(test_parse_args)
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,3 @@ def test_numlevels_arg(self):
test_numlevels,
"Option --numlevels did not set "
"number of contour levels.")

if __name__ == "__main__":
unittest.main()
5 changes: 1 addition & 4 deletions ugrid2shp.py → ugrid2shp/ugrid2shp.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def parse_args(argv):
return parser.parse_args(argv)


def main(argv):
def ugrid2shp(argv):

args = parse_args(argv)

Expand Down Expand Up @@ -293,6 +293,3 @@ def main(argv):

# try reading the Shapefile back in
# c = fiona.open(shapefilename, 'r')

if __name__ == "__main__":
main(sys.argv[1:])

0 comments on commit 6b39f10

Please sign in to comment.