Scientific.IO.NetCDF.NetCDFVariable

Package Scientific :: Package IO :: Module NetCDF :: Class NetCDFVariable |
[frames] | no frames]

# Class NetCDFVariable

Variable in a netCDF file

NetCDFVariable objects are constructed by calling the method 'createVariable' on the NetCDFFile object.

NetCDFVariable objects behave much like array objects defined in module Numeric, 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 using the methods 'getValue' and 'assignValue'. NetCDFVariable objects also have attribute "shape" 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 NetCDFVariable object.

Note: If a file open for reading is simultaneously written by another program, the size of the unlimited dimension may change. Every time the shape of a variable is requested, the current size will be obtained from the file. For reading and writing, the size obtained during the last shape request is used. This ensures consistency: foo[-1] means the same thing no matter how often it is evaluated, as long as the shape is not re-evaluated in between.

Instance Methods
__init__(self, *args) |
assignValue(self, value) Assign a new value to the variable. |
getValue(self) Return the value of the variable. |
`str` |
typecode(self) Returns: the variable's type code |

Method Details

### assignValue(self, value) |
Assign a new value to the variable. This method allows assignment to scalar variables, which cannot be indexed. Parameters: `value` - the new value for the variable

### getValue(self) |
Return the value of the variable. This method allows access to scalar variables, which cannot be indexed. Returns: the current value of the variable

### typecode(self) |
Returns: `str` the variable's type code