These instructions target the development installation. If you are using the standard / operational installation we provide a recording from the first public AvaFrame workshop . You will find a demo starting at around the 17:25min mark.
After the installation, the next sections describe on how to get started. The sections configuration and logging describe the general methods we use, this is helpful to understand how you can change model parameters and similar.
Follow these steps to run your first simulation:
change into your
AvaFramedirectory (replace [YOURDIR] with your path from the installation steps):
a similar output should show up:
logUtils - INFO - Started logging at: 03.11.2020 22:42:04 logUtils - INFO - Also logging to: data/avaParabola/runCom1DFA.log runCom1DFA - INFO - MAIN SCRIPT runCom1DFA - INFO - Current avalanche: data/avaParabola ...
This will perform a dense flow avalanche simulation using the
The results are saved to
data/avaParabola/Outputs/com1DFA. For a first
look at the results, got to the folder
reports, there you can find
a markdown report of the simulations performed including some plots of the results.
To display markdown files in a nice way use a markdown viewer of your choice. Some other options are:
Use the Atom editor with a markdown plugin
If you have pandoc installed use this to convert it to pdf/html
Some browsers have markdown extensions you can install easily
The following example should make it easier for you to find your way in AvaFrame and setup your own AvaFrame workflow after you did the full setup. There is also a directory with examples for different workflows, see more here: Examples.
Make sure you change to your
AvaFrame directory by:
[YOURDIR] with the directory from your installation step.
To create the folder where the input data lies and where the
output results will be saved, specify the full path to the folder
local_avaframeCfg.ini (which is a copy of
avaframeCfg.ini that you need to create). So:
cd avaframe cp avaframeCfg.ini local_avaframeCfg.ini
local_avaframeCfg.ini with your favorite text editor and adjust the
This will create a new directory with the input required by AvaFrame structured as described in Initialize Project.
Check the input data required by the different modules you want to use and fill
Inputs/ inside the
[avalancheDir] folder from the initialize step accordingly.
For example the
com1DFA module needs input as described in
Input. You can also have a look at the default setting for
the module you want to use (for example
com1DFACfg.ini for module com1DFA).
If you want to use different settings, create a
local_ copy of the
file and modify the desired parameters.
More information about the configuration can be found here: Configuration
Building your run script¶
Create your own workflow by taking the
runOperational.py script as
We suggest you copy it and adjust it to your liking. There are annotations in the code that should help you to understand the structure.
A lot more examples can be found in the
runScripts directory (see also Examples).
In order to set the configurations required by all the modules within Avaframe, the python module configparser is used.
This is done in two steps. The first step fetches the main settings:
from avaframe.in3Utils import cfgUtils # Load avalanche directory from general configuration file cfgMain = cfgUtils.getGeneralConfig() avalancheDir = cfgMain['MAIN']['avalancheDir']
In the second step the specific settings to a given module are imported:
from avaframe.tmp1Ex import tmp1Ex # Load all input Parameters from config file # get the configuration of an already imported module # Write config to log file cfg = cfgUtils.getModuleConfig(tmp1Ex)
The py:func:in3Utils.cfgUtils.getModuleConfig function reads the settings from a configuration file (
in our example) and writes these settings to the log file. The default settings can be found in the
configuration file provided within each module.
It is possible to modify these settings, there are two options:
provide the path to your own configuration file when calling
cfgUtils.getModuleConfig(moduleName, path to config file)
create a copy of the module configuration file called
local_followed by the name of the original configuration file and set the desired values of the individual parameters.
So the order is as follows:
if there is a path provided, configuration is read from this file.
if there is no path provided, the
local_...configuration file is read if it exists.
if there is no
getModuleConfigfunction reads the settings from the default configuration file with the default settings.
In the configuration file itself, there are multiple options to vary a parameter:
replace the default parameter value with desired value
provide a number of parameter values separated by
provide a number of parameter values using
relTh=1.:3.:3)) - a single value can be added by appending
In order to generate simulation logs and to control what is prompted to the terminal, we use the python module logging.
Let’s have a look at the simple example in runTmp1Ex.py and tmp1Ex.py on how this is used within AvaFrame.
In your main script call:
from avaframe.in3Utils import logUtils # log file name; leave empty to use default runLog.log logName = 'runTmp1Ex' # specify the working directory avalancheDir = './' # --------------------------------------------- # Start logging log = logUtils.initiateLogger(avalancheDir, logName)
This will configure the logging (it sets the console output as well as the log file). In your modules/subscripts add:
import logging log = logging.getLogger(__name__)
So you can use:
log.debug('Should be here') log.info('DEM : %s',variable)
To get output that looks like this in your console:
tmp1Ex:DEBUG - Should be here tmp1Ex:INFO - DEM : /path/to/DEM
and something similar in the
.log file which is saved in
./runTmp1Ex.log in this example.
The logging configuration is set in
You can modify this
logging.conf file to modify the levels or format of the messages to display
(python doc will help you).