Skip to content

Commit

Permalink
Add option to load grids with non standard variable name for gpis. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpaulik authored Jan 17, 2017
1 parent 5292a42 commit 946674f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

v0.2.2
======

- Add option to load grids with non standard variable name for gpis.

v0.2.1
======

Expand Down
8 changes: 6 additions & 2 deletions pygeogrids/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ def save_grid(filename, grid, subset_name='subset_flag',
global_attrs=global_attrs)


def load_grid(filename, subset_flag='subset_flag'):
def load_grid(filename, subset_flag='subset_flag',
location_var_name='gpi'):
"""
load a grid from netCDF file
Expand All @@ -334,6 +335,9 @@ def load_grid(filename, subset_flag='subset_flag'):
filename
subset_flag : string, optional
name of the subset to load.
location_var_name: string, optional
variable name under which the grid point locations
are stored
Returns
-------
Expand All @@ -347,7 +351,7 @@ def load_grid(filename, subset_flag='subset_flag'):
if 'cell' in nc_data.variables.keys():
arrcell = nc_data.variables['cell'][:].flatten()

gpis = nc_data.variables['gpi'][:].flatten()
gpis = nc_data.variables[location_var_name][:].flatten()

shape = None
if hasattr(nc_data, 'shape'):
Expand Down

0 comments on commit 946674f

Please sign in to comment.