Skip to main content

numpy array with grids and associated operations

Project description

SPACEGRIDS README.

Tutorial: http://nbviewer.ipython.org/github/willo12/spacegrids/blob/master/Spacegrids.ipynb

The Python 2.7 Spacegrids module, “Numpy on grids”, provides useful classes for analyzing spatial data defined on grids (e.g. covering the Earth’s surface). It interprets Netcdf metadata, and is designed to ensure consistency between data and grid information via interacting objects of fields, grids, coordinates and axes. It provides intuitive short expressions for complex operations, including volume and distance related concepts such as integration and differentiation.

Interprets metadata for most climate model output and datasets in Netcdf format, and is confirmed to work with UVic (all versions), CSIRO Mk3L, FAMOUS, CCM3.6 (Atmosphere), Loveclim, various Levitus Data, GPlates output. If you have problems reading data and/ or interpreting metadata (or find a bug), the author would be happy to take a look (see also Github for email etc). Frequent updating is recommended for bug fixes and improvement.

Installs by typing “pip install spacegrids” on command line. On Mac, pip can be installed via “sudo easy_install pip”. On Ubuntu/ Debian, install dependencies via package manager if pip install fails:

apt-get install python-{tk,numpy,matplotlib,scipy}

Now using NetCDF4 by default. (If installed, with fallback to scipy.io)


More advanced tutorial: http://nbviewer.ipython.org/github/willo12/spacegrids/blob/master/advanced.ipynb

The following statement provides all functionality:

Import with “import spacegrids as sg”. Once loaded, sg allows an overview of the available data via sg.info(). A project object is created via P = sg.Project(D[‘some_project’]). This then allows fields to be loaded automatically for all experiment subdirectories. Data grids are constructed based on the Netcdf metadata.

Data directory tree:

Before using projects, Netcdf data must be organised in a projects directory tree. Create a directory named PROJECTS inside your home directory (name default), to contain all the data for all the projects. Then create a subdirectory for each of your projects, say one is called test_project. When using sg.info() and sg.project with the nonick = True argument (see documentation), this is all that is needed to allow the sg module to recognise these subdirectories as representing projects. This will allow the sg Python code to regard all Netcdf files placed directly inside test_project as belonging to individual experiments. Alternatively, instead of a single file, a subdirectory may represent an experiment. So directories inside the test_project directory are associated with output from a single experiment each, where all Netcdf files contained within are interpreted as belonging to that same experiment.

To get started in ipython (bring up with sg.overview() ):

import spacegrids as sg

D = sg.info(nonick = True)

P = sg.Project(D[‘my_project’] , nonick = True)

P.load([‘temperature’,’u’])

# obtain the axes under their names T, X, Y, Z in namespace:

for c in P[‘some_experiment’].axes:

exec c.name + ‘ = c’

# some examples:

TEMP = P[‘some_experiment’][‘temperature’]

U = P[‘some_experiment’][‘u’]

TEMP_sliced = TEMP[Y,:50]

m_TEMP = TEMP_sliced/(X*Y)

TEMP_regridded = TEMP(U.gr)


The following python modules are required:

numpy matplotlib (requires python-tk) scipy

To obtain pip on Ubuntu/ Debian: (sudo) apt-get install python-pip.

Tutorial: http://nbviewer.ipython.org/github/willo12/spacegrids/blob/master/Spacegrids.ipynb Older documentation: https://github.com/willo12/spacegrids/wiki

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spacegrids-1.6.1.tar.gz (77.0 kB view hashes)

Uploaded Source

Built Distribution

spacegrids-1.6.1-py2.7.egg (210.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page