Skip to main content

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')

Test.save('simple.nc')

This will produce the following NetCDF file:

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

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

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

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

By default it uses pupynere for creating files, but this can be overloaded:

from netCDF4 import Dataset

class Test(NetCDF):
    loader = Dataset
    ...
Test.save('simple.nc', format='NETCDF4')

Changelog:

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.

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

Puppy-0.1.4.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

Puppy-0.1.4-py2.6.egg (4.3 kB view details)

Uploaded Source

File details

Details for the file Puppy-0.1.4.tar.gz.

File metadata

  • Download URL: Puppy-0.1.4.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Puppy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0ef1385203456afe75d889be6c3afc0ea6ba8ab8f04e78c3daab823a0ba68a30
MD5 fc00cf955ccd677405f541e42a2b36f3
BLAKE2b-256 2e1738d5555ffb60705351f519e5f8d170c70a62b1ea18752882f59a313fbbc1

See more details on using hashes here.

Provenance

File details

Details for the file Puppy-0.1.4-py2.6.egg.

File metadata

  • Download URL: Puppy-0.1.4-py2.6.egg
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Puppy-0.1.4-py2.6.egg
Algorithm Hash digest
SHA256 5f254401a73e19513a25f8c80220578947a59bd2924d54a622ab82d47e2d6031
MD5 8f706ef64d28ff69b1736e2f37b6e3dd
BLAKE2b-256 a9fd5f47bb247c05b33b605ba09d3aac1e740a77e55e5783285d539e9a9c5289

See more details on using hashes here.

Provenance

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