Skip to content

Commit

Permalink
Merge pull request #19 from ocefpaf/pysgrid
Browse files Browse the repository at this point in the history
Update code to use latest pysgrid...
  • Loading branch information
ocefpaf authored Sep 2, 2016
2 parents 8b67ec1 + b934f42 commit 0003101
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 206 deletions.
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: python

sudo: false

env:
- CONDA="python=2.7"
- CONDA="python=3.4"
Expand All @@ -9,11 +11,12 @@ before_install:
- wget http://bit.ly/miniconda -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- conda update --yes conda
- conda config --add channels ioos -f
- travis_retry conda create --yes -n TEST $CONDA --file requirements.txt
- conda update --yes --all
- conda config --add channels conda-forge --force

install:
- conda create --yes -n TEST $CONDA --file requirements.txt --file requirements-dev.txt
- source activate TEST
- conda install --yes --file requirements-dev.txt
# GUI.
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
---------

Version 0.2.1

* Use latest `pysgrid` API.

Version 0.2.0

* Parse cubes with more than one `X`, `Y` axis.
Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
gridgeo
-------

.. image:: https://travis-ci.org/pyoceans/gridgeo.svg?branch=master
:target: https://travis-ci.org/pyoceans/gridgeo

.. image:: https://zenodo.org/badge/5715/pyoceans/gridgeo.svg
:target: https://zenodo.org/badge/latestdoi/5715/pyoceans/gridgeo

Convert ocean numerical models grids,
including UGRID and SGRID compliant files,
to a variety of geo-like objects (GeoJSON, TopoJSON, and Shapefile).
2 changes: 1 addition & 1 deletion gridgeo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .gridgeo import GridGeo
from .utilities import load_grid, rasterize

__version__ = '0.2.0'
__version__ = '0.2.1'

__all__ = ['GridGeo',
'load_grid',
Expand Down
16 changes: 7 additions & 9 deletions gridgeo/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

import pyugrid
import pysgrid

import numpy as np

from pysgrid.custom_exceptions import SGridNonCompliantError

from netCDF4 import Dataset
from shapely.geometry.polygon import Polygon

Expand Down Expand Up @@ -37,11 +33,11 @@ def load_grid(nc):
nc = Dataset(nc)

try:
grid = pysgrid.from_nc_dataset(nc)
grid = pysgrid.load_grid(nc)
polygons = _parse_sgrid(grid)
mesh = 'sgrid'
return grid, polygons, mesh
except (SGridNonCompliantError, KeyError):
except (ValueError, KeyError):
pass
try:
grid = pyugrid.UGrid.from_nc_dataset(nc)
Expand Down Expand Up @@ -72,11 +68,13 @@ def _parse_sgrid(sgrid):
"""
Return a polygons generator from an `sgrid` object.
NOTE: Works only for the grid center. The edges are not implemented in
`pysgrid` yet.
FIXME: Creating a fake grid for the grid center.
We should honor the SGRID conventions and make a quad cell grid from the
nodes and instead.
"""
coords = sgrid.centers.copy()
coords = np.concatenate([sgrid.center_lon[:][..., None],
sgrid.center_lat[:][..., None, ]], axis=2)
return _make_grid(coords)


Expand Down
52 changes: 19 additions & 33 deletions notebooks/example_gridgeo_generic_grid.ipynb

Large diffs are not rendered by default.

104 changes: 45 additions & 59 deletions notebooks/example_gridgeo_non-compliant.ipynb

Large diffs are not rendered by default.

54 changes: 20 additions & 34 deletions notebooks/example_gridgeo_sgrid.ipynb

Large diffs are not rendered by default.

53 changes: 24 additions & 29 deletions notebooks/example_gridgeo_sgrid_all_grids_via_cube.ipynb

Large diffs are not rendered by default.

54 changes: 20 additions & 34 deletions notebooks/example_gridgeo_ugrid.ipynb

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
netCDF4 >=1.2.0,<1.2.2
netCDF4
pysgrid
pyugrid
fiona
shapely
iris
cartopy
matplotlib
2 changes: 1 addition & 1 deletion tests/test_sgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_nc_from_string():


def test_grid():
assert isinstance(grid.grid, pysgrid.SGrid2D)
assert isinstance(grid.grid, pysgrid.SGrid)


def test_mesh():
Expand Down

0 comments on commit 0003101

Please sign in to comment.