Functions for processing data¶
Standard operators¶
For documented standard operators see Standard operators and functions
Functions returning CliMAF objects¶
For functions which looks like CLiMAF operators, see : Functions returning CliMAF objects
Non-standard operators¶
See ..know which CliMAF operators are available and what they do
Functions for creating new processing functions, or tuning their behaviour¶
cscript : define a new CliMAF operator¶
Defining a new CliMAF operator also defines a new Python function, with the same name
fixed_fields : when operators need auxilliray data fields (e.g. grid, mesh, mask)¶
And you may need to tell how an operator will receive some fixed fields ‘behind the curtain’ (in addition to the datasets, which are provided as arguments)
cmacro : define a macro¶
- climaf.cmacro.macro(name, cobj, lobjects=[])[source]¶
Define a CliMAF macro from a CliMAF compound object.
Transform a Climaf object in a macro, replacing all datasets, and the objects of lobjects, by a dummy argument. Register it in dict cmacros, if name is not None
- Parameters:
name (string) – the name you want to give to the macro; a Python function with the same name will be defined
cobj (CliMAF object, or string) – any CliMAF object, usually the result of a series of operators, that you would like to repeat using other input datasets; alternatively, you can provide the macro formula as a string (when accustomed to the syntax)
lobjects (list, optional) – for expert use- a list of objects, which are sub-objects of cobject, and which should become arguments of the macro
- Returns:
a python function is also defined in module cmacros and in main namespace, and you may use it in the same way as a CliMAF operator. All the datasets involved in
cobjbecome arguments of the macro, which allows you to re-do the same computations and easily define objects similar tocobjs- Return type:
a macro; the returned value is usualy not used ‘as is’
Example:
>>> # First use and combine CliMAF operators to get some interesting result using some dataset(s) >>> january_ta=ds(project='example',simulation='AMIPV6ALB2G',variable='ta',frequency='monthly',period='198001') >>> ta_europe=llbox(january_ta,latmin=40,latmax=60,lonmin=-15,lonmax=25) >>> ta_ezm=ccdo(ta_europe,operator='zonmean') >>> fig_ezm=plot(ta_ezm) >>> # >>> # Using this result as an example, define a macro named 'eu_cross_section', >>> # which arguments will be the datasets involved in this result >>> cmacro('eu_cross_section',fig_ezm) >>> # >>> # You can of course apply a macro to another dataset(s) (even here to a 2D variable) >>> pr=ds(project='example',simulation='AMIPV6ALB2G', variable='pr', frequency='monthly', period='198001') >>> pr_ezm=eu_cross_section(pr) >>> # >>> # All macros are registered in dictionary climaf.cmacro.cmacros, >>> # which is imported by climaf.api; you can list it by : >>> cmacros
Note : macros are automatically saved in file ~/.climaf.macros, and can be edited
See also much more explanations in the example at
macro.py