atomica.cascade.sanitize_cascade¶
- atomica.cascade.sanitize_cascade(framework, cascade, fallback_used=False)[source]¶
Normalize cascade inputs
For convenience, users can specify cascades in one of several representations. To facilitate working with these representations on the backend, this function turns any valid representation into a dictionary mapping cascade stage names to a list of compartments/characs. It also returns the name of the cascade (if one is present) for use in plot titles.
As an example of the cascade dictionary, suppose the spreadsheet had stages
Stage 1 -
sus,vac,infStage 2 -
vac,inf
Then example usage would be:
>>> sanitize_cascade(framework,'main')[1] {'Stage 1':['sus','vac','inf'],'Stage 2':['vac','inf']
This function also validates the cascade, so it is not necessary to call
validate_cascade()separately.- Parameters:
framework – A
ProjectFrameworkinstancecascade –
Supported cascade representation. Could be - A string cascade nameP - An integer specifying the index of the cascade -
None, which maps to the first cascade in the framework - Alistof cascade stages - Adictdefining the cascade The first three input formats willresult in the cascade name also being returned (otherwise it will be assigned
None
- Return type:
- Returns:
A tuple with
(cascade_name,cascade_dict)- the cascade name isNoneif the cascade was specified as alistordict