Skip to content

Commit

Permalink
Merge pull request #38 from cbcunc/fixargs
Browse files Browse the repository at this point in the history
Add __main__ namespaces to all packages and add complete distribution te...
  • Loading branch information
cbcunc committed Apr 23, 2015
2 parents a9cda5f + 4df9d18 commit bb5de04
Show file tree
Hide file tree
Showing 16 changed files with 467 additions and 87 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
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
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
43 changes: 37 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
from setuptools import setup, \
find_packages
from setuptools import setup
from setuptools import find_packages

setup(name='pyugrid',
version='1.0',

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 GIS shapefiles '
description='Compute a GIS shapefile '
'from a CF-UGRID compliant netCDF file.',
keywords="UGRID CF NetCDF shapefile",
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")
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:])
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)
3 changes: 0 additions & 3 deletions ugrid2shp/tests/test_parse_args.py
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()

0 comments on commit bb5de04

Please sign in to comment.