walk¶
- climlab.utils.walk.process_tree(top, name='top')[source]¶
Creates a string representation of the process tree for process top.
This method uses the
walk_processes()
method to create the process tree.- Parameters:
- Returns:
string representation of the process tree
- Return type:
- Example:
>>> import climlab >>> from climlab.utils import walk >>> model = climlab.EBM() >>> proc_tree_str = walk.process_tree(model, name='model') >>> print proc_tree_str model: <class 'climlab.model.ebm.EBM'> diffusion: <class 'climlab.dynamics.diffusion.MeridionalDiffusion'> LW: <class 'climlab.radiation.AplusBT.AplusBT'> albedo: <class 'climlab.surface.albedo.StepFunctionAlbedo'> iceline: <class 'climlab.surface.albedo.Iceline'> cold_albedo: <class 'climlab.surface.albedo.ConstantAlbedo'> warm_albedo: <class 'climlab.surface.albedo.P2Albedo'> insolation: <class 'climlab.radiation.insolation.P2Insolation'>
- climlab.utils.walk.walk_processes(top, topname='top', topdown=True, ignoreFlag=False)[source]¶
Generator for recursive tree of climlab processes
Starts walking from climlab process
top
and generates a complete list of all processes and sub-processes that are managed fromtop
process.level
indicades the rank of specific process in the process hierarchy:Note
- level 0:
top
process - level 1: sub-processes of
top
process level 2: sub-sub-processes of
top
process (=subprocesses of level 1 processes)
- level 1: sub-processes of
- level 0:
The method is based on os.walk().
- Parameters:
- Returns:
name (str), proc (process), level (int)
- Example:
>>> import climlab >>> from climlab.utils import walk >>> model = climlab.EBM() >>> for name, proc, top_proc in walk.walk_processes(model): ... print name ... top diffusion LW iceline cold_albedo warm_albedo albedo insolation