SileCDF¶
-
class
sisl.io.SileCDF(filename, mode='r', lvl=0, access=1, _open=True)[source]¶ Base class for NetCDF files
Attributes
fileFilename of the current SileMethods
__init__(filename[, mode, lvl, access, _open])Creates/Opens a SileCDF close()exist()Query whether the file exists isDataset(obj)Return true if objis an instance of the NetCDF4DatasettypeisDimension(obj)Return true if objis an instance of the NetCDF4DimensiontypeisGroup(obj)Return true if objis an instance of the NetCDF4GrouptypeisRoot(obj)Return true if objis an instance of the NetCDF4DatasettypeisVariable(obj)Return true if objis an instance of the NetCDF4Variabletypeiter([group, dimension, variable, levels, root])Iterator on all groups, variables and dimensions. read(*args, **kwargs)Generic read method which should be overloaded in child-classes write(*args, **kwargs)Generic write method which should be overloaded in child-classes -
exist()¶ Query whether the file exists
-
classmethod
isDataset(obj)[source]¶ Return true if
objis an instance of the NetCDF4DatasettypeThis is just a wrapper for
isinstance(obj, netCDF4.Dataset).
-
classmethod
isDimension(obj)[source]¶ Return true if
objis an instance of the NetCDF4DimensiontypeThis is just a wrapper for
isinstance(obj, netCDF4.Dimension).
-
classmethod
isGroup(obj)[source]¶ Return true if
objis an instance of the NetCDF4GrouptypeThis is just a wrapper for
isinstance(obj, netCDF4.Group).
-
classmethod
isRoot(obj)¶ Return true if
objis an instance of the NetCDF4DatasettypeThis is just a wrapper for
isinstance(obj, netCDF4.Dataset).
-
classmethod
isVariable(obj)[source]¶ Return true if
objis an instance of the NetCDF4VariabletypeThis is just a wrapper for
isinstance(obj, netCDF4.Variable).
-
iter(group=True, dimension=True, variable=True, levels=-1, root=None)[source]¶ Iterator on all groups, variables and dimensions.
This iterator iterates through all groups, variables and dimensions in the
DatasetThe generator sequence will _always_ be:
- Group
- Dimensions in group
- Variables in group
As the dimensions are generated before the variables it is possible to copy groups, dimensions, and then variables such that one always ensures correct dependencies in the generation of a new
SileCDF.Parameters: group :
bool(True)whether the iterator yields Group instances
dimension :
bool(True)whether the iterator yields Dimension instances
variable :
bool(True)whether the iterator yields Variable instances
levels :
int(-1)number of levels to traverse, with respect to
rootvariable, i.e. number of sub-groups this iterator will return.root :
str(None)the base root to start iterating from.
Examples
Script for looping and checking each instance.
>>> for gv in self.iter(): ... if self.isGroup(gv): ... # is group ... elif self.isDimension(gv): ... # is dimension ... elif self.isVariable(gv): ... # is variable
-
read(*args, **kwargs)¶ Generic read method which should be overloaded in child-classes
Parameters: **kwargs :
keyword arguments will try and search for the attribute
read_<>and call it with the remaining**kwargsas arguments.
-
write(*args, **kwargs)¶ Generic write method which should be overloaded in child-classes
Parameters: **kwargs :
keyword arguments will try and search for the attribute write_ and call it with the remaining
**kwargsas arguments.
-