Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

DSL for creating NetCDF files

Project Description

A DSL for creating NetCDF files. Here’s a simple example:

from pup import *

class Test(NetCDF):
    # NC_GLOBAL attributes go here
    history = 'Created for a test'

    # dimensions need to be set explicitly only when they
    # have no variable associated with them
    dim0 = Dimension(2)

    # variables that don't specify dimensions are assumed to
    # be their own dimension
    time = Variable(range(10), record=True, units='days since 2008-01-01')

    # now a variable with dimensions (time,)
    temperature = Variable(range(10), (time,), units='deg C')'')

This will produce the following NetCDF file:

netcdf simple {
    dim0 = 2 ;
    time = UNLIMITED ; // (10 currently)
    int time(time) ;
        time:units = "days since 2008-01-01" ;
    int temperature(time) ;
        temperature:units = "deg C" ;

// global attributes:
        :history = "Created for a test" ;

 time = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ;

 temperature = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ;

Compare this with the code necessary to do the same using common NetCDF libraries:

f = netcdf_file("", "w")

f.history = "Created for a test"

f.createDimension("dim0", 2)

f.createDimension("time", None)
time = f.createVariable("time", "i", ("time",))
time.units = "days since 2008-01-01"
time[:] = range(10)

temperature = f.createVariable("temperature", "i", ("time",))
temperature.units = "deg C"
temperature[:] = range(10)

By default it uses pupynere for creating files, but this can be overloaded; we can use the netCDF4 module, for example, which allows us to specify groups:

from netCDF4 import Dataset

class Test(NetCDF):
    loader = Dataset

    foo = Group(
        dim = Dimension(10),
        var = Variable(range(10)),
    )'', format='NETCDF4')


0.1.8:Ensure record dimensions are created first.
0.1.7:Convert strings to array of chars.
0.1.6:Fix bug in dimension name.
0.1.5:Added support for Groups when using netcdf4.
0.1.4:Added support for masked arrays.
0.1.3:Pass keyword arguments in save() to the loader.
0.1.2:Improved optional loader detection.
0.1.1:Added pupynere dependency.
0.1:Initial release.
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Puppy-0.1.8-py2.7.egg (5.3 kB) Copy SHA256 Checksum SHA256 2.7 Egg Dec 5, 2013
Puppy-0.1.8.tar.gz (3.6 kB) Copy SHA256 Checksum SHA256 Source Dec 5, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting