Functions for managing numerical results¶
cfile : get the file value of a CliMAF object¶
-
climaf.driver.
cfile
(object, target=None, ln=None, hard=None, deep=None)[source] Provide the filename for a CliMAF object, or copy this file to target. Launch computation if needed.
Parameters: - object (CliMAF object) – either a dataset or a ‘compound’ object (e.g. the result of a CliMAF operator)
- target (str, optional) – name of the destination file in case you really need another filename; CliMAF will then anyway also store the result in its cache, either as a copy (default), or a sym- or a hard-link (see below);
- ln (logical, optional) – if True, CliMAF cache file is created as a symlink to the target; this allows to cross filesystem boundaries, while still saving disk space (wrt to a copy); CliMAF will manage the broken link cases (at the expense of a new computation)
- hard (logical, optional) – if True, CliMAF cache file is created as a hard link to the target; this allows to save disk space, but does not allow to cross filesystem boundaries
- deep (logical, optional) –
governs the use of cached values when computing the object:
- if missing, or None : use cache as much as possible (speed up the computation)
- False : make a shallow computation, i.e. do not use cached values for the top level operation
- True : make a deep computation, i.e. do not use any cached value
Returns: - if target is provided, returns this filename (or linkname) if computation is successful (‘target’ contains the result), and None otherwise;
- if target is not provided, returns the filename in CliMAF cache, which contains the result (and None if failure)
efile : create the file for an ensemble of CliMAF objects¶
-
climaf.driver.
efile
(obj, filename, force=False)[source] Create a single file for an ensemble of CliMAF objects (launch computation if needed).
This is a convenience function. Such files are not handled in CliMAF cache
Parameters: - obj (CliMAF object) – an ensemble of CliMAF objects (‘cens’ objet)
- filename (str) – output filename. It will include a field for each ensemble’s member, with a variable name suffixed by the member label (e.g. : tas_CNRM-CM, tas_IPSL-CM… ) (more formally : ‘var(obj.order[n])’_’obj.ens[order[n]]’)
- force (logical, optional) – if True, CliMAF will overwrite the file ‘filename’ if it already exists
cMA : get the Masked Array value of a CliMAF object¶
-
climaf.driver.
cMA
(obj, deep=None)[source] Provide the Masked Array value for a CliMAF object. Launch computation if needed.
Parameters: - obj (CliMAF object) – either a datset or a ‘compound’ object (like the result of a CliMAF standard operator)
- deep (logical, optional) –
governs the use of cached values when computing the object
- if missing, or None : use cache as much as possible
- False : make a shallow computation, i.e. do not use cached values for top level operation
- True : make a deep computation, i.e. do not use any cached value
Returns: a Masked Array containing the object’s value
cvalue : get the scalar value of a CliMAF scalar object¶
-
climaf.driver.
cvalue
(obj, index=0, deep=None, cost=None)[source] Return the value of the array for an object, at a given index, after MV flattening
Arg DEEP is used as for
climaf.driver.cfile()
If arg COST is True, a tuple is returned, which second element is the total compute cost for the value
Example, where the target object is a scalar (0d) field:
>>> data=ds(project='mine',variable='tas', ...) >>> data1=time_average(data) >>> data2=space_average(data1) >>> v=cvalue(data2)
Does use the file representation of the object