Python
RiskScape allows user defined Python code to be used for risk modelling. This allows RiskScape to be extended by scientists/risk modellers without needing software developers.
Note
To use packages like numpy or scipy in your Python function, you need
to configure RiskScape to use CPython.
There are three main ways to use Python with RiskScape:
Python functions: you can customize your risk-modelling by defining your own RiskScape Functions in Python, which can then be integrated with your model. User-defined Python functions can be used from any RiskScape expression, the same as built-in RiskScape functions. Python functions will get called repeatedly for each row of data.
Tip
If you’re looking to integrate your own damage functions or vulnerability curves, then Python functions are most likely what you’re after.
CPython post-processing scripts: you can optionally run Python code at the end of your model run. This can take your model results and create custom model outputs, such as maps, bar graphs, or even custom PDF files.
The Python pipeline step: advanced users can pass all the pipeline data to Python for additional processing. This can be useful for modelling dependencies, such as for network models, where damage to one asset can affect other assets.
Note
The python() step can run at any point in the model pipeline. It runs before the results
files are saved, and can optionally pass the modified data back to the pipeline.
Whereas the post-processing script only runs at the end, after the main results files have been saved.