scipy.io.netcdf_variable#
- class scipy.io.netcdf_variable(data, typecode, size, shape, dimensions, attributes=None, maskandscale=False)[source]#
A data object for netcdf files.
netcdf_variable
objects are constructed by calling the methodnetcdf_file.createVariable
on thenetcdf_file
object.netcdf_variable
objects behave much like array objects defined in numpy, except that their data resides in a file. Data is read by indexing and written by assigning to an indexed subset; the entire array can be accessed by the index[:]
or (for scalars) by using the methodsgetValue
andassignValue
.netcdf_variable
objects also have attributeshape
with the same meaning as for arrays, but the shape cannot be modified. There is another read-only attribute dimensions, whose value is the tuple of dimension names.All other attributes correspond to variable attributes defined in the NetCDF file. Variable attributes are created by assigning to an attribute of the
netcdf_variable
object.- Parameters:
- dataarray_like
The data array that holds the values for the variable. Typically, this is initialized as empty, but with the proper shape.
- typecodedtype character code
Desired data-type for the data array.
- sizeint
Desired element size for the data array.
- shapesequence of ints
The shape of the array. This should match the lengths of the variable’s dimensions.
- dimensionssequence of strings
The names of the dimensions used by the variable. Must be in the same order of the dimension lengths given by
shape
.- attributesdict, optional
Attribute values (any type) keyed by string names. These attributes become attributes for the netcdf_variable object.
- maskandscalebool, optional
Whether to automatically scale and/or mask data based on attributes. Default is False.
- Attributes:
- dimensionslist of str
List of names of dimensions used by the variable object.
- isrec, shape
Properties
Methods
assignValue
(value)Assign a scalar value to a
netcdf_variable
of length one.getValue
()Retrieve a scalar value from a
netcdf_variable
of length one.itemsize
()Return the itemsize of the variable.
typecode
()Return the typecode of the variable.
__getitem__