Package solvcon :: Package io :: Module netcdf :: Class NetCDF
[hide private]
[frames] | no frames]

Class NetCDF

source code

object --+
         |
        NetCDF
Known Subclasses:

Wrapper for the netCDF library by using ctypes. Mainly designed for reading. Native functions remains to be nc_*. NC_* are class members for constants defined in the header file.

Instance Methods [hide private]
 
__init__(self, path=None, omode=None, libname='libnetcdf.so')
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__getattr__(self, key) source code
int
open_file(self, path, omode=None)
Open a NetCDF file.
source code
 
close_file(self)
Close the associated NetCDF file.
source code
int
get_dim(self, name)
Get the dimension of the given name.
source code
numpy.ndarray
get_array(self, name, shape, dtype)
Load ndarray from netCDF file.
source code
numpy.ndarray
get_lines(self, name, shape)
Load string from netCDF file.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  NC_NAT = 0
  NC_BYTE = 1
  NC_CHAR = 2
  NC_SHORT = 3
  NC_INT = 4
  NC_LONG = 4
  NC_FLOAT = 5
  NC_DOUBLE = 6
  NC_UBYTE = 7
  NC_USHORT = 8
  NC_UINT = 9
  NC_INT64 = 10
  NC_UINT64 = 11
  NC_STRING = 12
  NC_VLEN = 13
  NC_OPAQUE = 14
  NC_ENUM = 15
  NC_COMPOUND = 16
  NC_FILL_BYTE = -127
  NC_FILL_CHAR = 0
  NC_FILL_SHORT = -32767
  NC_FILL_INT = -2147483647
  NC_FILL_FLOAT = 9.96920996839e+36
  NC_FILL_DOUBLE = 9.96920996839e+36
  NC_FILL_UBYTE = 255
  NC_FILL_USHORT = 65535
  NC_FILL_UINT = 4294967295
  NC_FILL_INT64 = -9223372036854775806
  NC_FILL_UINT64 = 18446744073709551614
  NC_FILL_STRING = ''
  NC_MAX_BYTE = 127
  NC_MIN_BYTE = -128
  NC_MAX_CHAR = 255
  NC_MAX_SHORT = 32767
  NC_MIN_SHORT = -32768
  NC_MAX_INT = 2147483647
  NC_MIN_INT = -2147483648
  NC_MAX_FLOAT = 3.402823466e+38
  NC_MIN_FLOAT = -3.402823466e+38
  NC_MAX_DOUBLE = 1.79769313486e+308
  NC_MIN_DOUBLE = -1.79769313486e+308
  NC_MAX_UBYTE = 255
  NC_MAX_USHORT = 65535
  NC_MAX_UINT = 4294967295
  NC_MAX_INT64 = 9223372036854775807
  NC_MIN_INT64 = -9223372036854775808
  NC_MAX_UINT64 = 18446744073709551615
  X_INT64_MAX = 9223372036854775807
  X_INT64_MIN = -9223372036854775808
  X_UINT64_MAX = 18446744073709551615
  _FillValue = '_FillValue'
  NC_FILL = 0
  NC_NOFILL = 256
  NC_NOWRITE = 0
  NC_WRITE = 1
  NC_CLOBBER = 0
  NC_NOCLOBBER = 4
  NC_64BIT_OFFSET = 512
  NC_NETCDF4 = 4096
  NC_CLASSICAL_MODE = 256
  NC_SHARE = 2048
  NC_MPIIO = 8192
  NC_MPIPOSIX = 16384
  NC_PNETXCDF = 32768
  NC_LOCK = 1024
  NC_FORMAT_CLASSIC = 1
  NC_FORMAT_64BIT = 2
  NC_FORMAT_NETCDF4 = 3
  NC_FORMAT_NETCDF4_CLASSIC = 4
  NC_SIZEHINT_DEFAULT = 0
  NC_ALIGN_CHUNK = -1
  NC_UNLIMITED = 0
  NC_GLOBAL = -1
  NC_MAX_DIMS = 1024
  NC_MAX_ATTRS = 8192
  NC_MAX_VARS = 8192
  NC_MAX_NAME = 256
  NC_MAX_VAR_DIMS = 1024
  NC_ENDIAN_NATIVE = 0
  NC_ENDIAN_LITTLE = 1
  NC_ENDIAN_BIG = 2
  NC_CHUNKED = 0
  NC_CONTIGUOUS = 1
  NC_NOCHECKSUM = 0
  NC_FLETCHER32 = 1
  NC_NOSHUFFLE = 0
  NC_SHUFFLE = 1
  NC_NOERR = 0
  NC2_ERR = -1
  NC_EBADID = -33
  NC_ENFILE = -34
  NC_EEXIST = -35
  NC_EINVAL = -36
  NC_EPERM = -37
  NC_ENOTINDEFINE = -38
  NC_EINDEFINE = -39
  NC_EINVALCOORDS = -40
  NC_EMAXDIMS = -41
  NC_ENAMEINUSE = -42
  NC_ENOTATT = -43
  NC_EMAXATTS = -44
  NC_EBADTYPE = -45
  NC_EBADDIM = -46
  NC_EUNLIMPOS = -47
  NC_EMAXVARS = -48
  NC_ENOTVAR = -49
  NC_EGLOBAL = -50
  NC_ENOTNC = -51
  NC_ESTS = -52
  NC_EMAXNAME = -53
  NC_EUNLIMIT = -54
  NC_ENORECVARS = -55
  NC_ECHAR = -56
  NC_EEDGE = -57
  NC_ESTRIDE = -58
  NC_EBADNAME = -59
  NC_ERANGE = -60
  NC_ENOMEM = -61
  NC_EVARSIZE = -62
  NC_EDIMSIZE = -63
  NC_ETRUNC = -64
  NC_EAXISTYPE = -65
  NC_EDAP = -66
  NC_ECURL = -67
  NC_EIO = -68
  NC_ENODATA = -69
  NC_EDAPSVC = -70
  NC_EDAS = -71
  NC_EDDS = -72
  NC_EDATADDS = -73
  NC_EDAPURL = -74
  NC_EDAPCONSTRAINT = -75
  NC4_FIRST_ERROR = -100
  NC_EHDFERR = -101
  NC_ECANTREAD = -102
  NC_ECANTWRITE = -103
  NC_ECANTCREATE = -104
  NC_EFILEMETA = -105
  NC_EDIMMETA = -106
  NC_EATTMETA = -107
  NC_EVARMETA = -108
  NC_ENOCOMPOUND = -109
  NC_EATTEXISTS = -110
  NC_ENOTNC4 = -111
  NC_ESTRICTNC3 = -112
  NC_ENOTNC3 = -113
  NC_ENOPAR = -114
  NC_EPARINIT = -115
  NC_EBADGRPID = -116
  NC_EBADTYPID = -117
  NC_ETYPDEFINED = -118
  NC_EBADFIELD = -119
  NC_EBADCLASS = -120
  NC_EMAPTYPE = -121
  NC_ELATEFILL = -122
  NC_ELATEDEF = -123
  NC_EDIMSCALE = -124
  NC_ENOGRP = -125
  NC_ESTORAGE = -126
  NC_EBADCHUNK = -127
  NC_ENOTBUILT = -128
  NC4_LAST_ERROR = -128
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, path=None, omode=None, libname='libnetcdf.so')
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • path (str) - the file to open.
  • omode (int) - opening mode.
Overrides: object.__init__

open_file(self, path, omode=None)

source code 

Open a NetCDF file.

Parameters:
  • path (str) - the file to open.
  • omode (int) - opening mode.
Returns: int
ncid

close_file(self)

source code 

Close the associated NetCDF file.

Returns:
nothing

get_dim(self, name)

source code 

Get the dimension of the given name.

Parameters:
  • name (str) - the name of the dimension.
Returns: int
the dimension (length).

get_array(self, name, shape, dtype)

source code 

Load ndarray from netCDF file.

Parameters:
  • name (str) - the data to be loaded.
  • shape (tuple) - the shape of ndarray.
  • dtype (str) - the dtype of ndarray.
Returns: numpy.ndarray
the loaded ndarray.

get_lines(self, name, shape)

source code 

Load string from netCDF file.

Parameters:
  • name (str) - the data to be loaded.
  • shape (tuple) - the shape of ndarray. Must be 1 or 2.
Returns: numpy.ndarray
the loaded ndarray.