Snapshots creates figures automatically from Lpy models using the python API
The module makes it possible to call a L-system from the user API and to plot figures
Snapshot creates figures automatically from L-Py models using the python API.
corresponding to simulations obtained by varying some model parameters.
The module makes it possible to call a L-system from the user API and to plot figures corresponding to simulations obtained by varying some model parameters.
Two parameters at most can be varied to create the figure.
Two parameters at most can be varied to create the figure.
The lscene_snapshot library offers 2 main functions:
The `lscene_snapshot` library offers 2 main functions:
suffix is an array of strings to store the computed images.
suffix is an array of strings to store the computed images.
TODO: explain ...
TODO: explain ...
...
@@ -46,119 +47,121 @@ TODO: explain ...
...
@@ -46,119 +47,121 @@ TODO: explain ...
It is possible to select a pair of variables for which we want to create a figure by giving them different values.
It is possible to select a pair of variables for which we want to create a figure by giving them different values.
`(x1,y1)(x2,y2), ... (xn,yn)`
`(x1,y1)(x2,y2), ... (xn,yn)`
For this, we first need to identify the pair of variables selected variable that we want to browse. This is done by defining the list `free_variable_list`
For this, we first need to identify the pair of variables selected variable that we want to browse.
free_variable_list containing the list of free variables to vary for launching the set of simulations:
This is done by defining the list `free_variable_list`.
`free_variable_list` containing the list of free variables to vary for launching the set of simulations:
free_variable_list = ['diam','age']
```python
free_variable_list=['diam','age']
The first variable `diam` is considered as the x variable, while the second variable is the y variable (x will vary on the horizontal axis of the figure and y on the vertical axis.
```
The first variable `diam` is considered as the x variable, while the second variable is the y variable (x will vary on the horizontal axis of the figure and y on the vertical axis).
Other extern variables of the model can be given a constant value different from that they have in the L-system file by listing them in the list fixed_variables_dict, and then redefining their value:
Other extern variables of the model can be given a constant value different from that they have in the L-system file by listing them in the list `fixed_variables_dict`, and then redefining their value:
fixed_variables_dict = {'length', 'name'}
```python
fixed_variables_dict={'length','name'}
```
All the other extern variables will keep constant and defined with the value given in the L-system file.
All the other extern variables will keep constant and defined with the value given in the L-system file.
Finally, to define the list of pairs of values of the free variables x and y (here `diam` and `age`), a dictionary is defined as follaws:
Finally, to define the list of pairs of values of the free variables x and y (here `diam` and `age`), a dictionary is defined as follows:
Meaning that (diam,age) values `(1,10), (2,10),(3,10),(4,10),(1,20),(2,20),(3,20),...,(5,30)` will be used to launch 11 simulations.
Meaning that (diam,age) values `(1,10), (2,10),(3,10),(4,10),(1,20),(2,20),(3,20),...,(5,30)` will be used to launch 11 simulations.
Note that the y-arrays need not be of the same size nor have the same values.
Note that the y-arrays need not be of the same size nor have the same values.
### Redefining variable name to be printed in figures
### Redefining variable name to be printed in figures
The dictionary variable_short_names can be set to give a short name to each
The dictionary `variable_short_names` can be set to give a short name to each variable (extern or intern) that will be used to the label the small images.
variable (extern or intern) that will be used to the label the small images.
Only names in this list will be used to construct small image labels:
Only names in this list will be used to construct small image labels:
This camdict can be read directly from a LPy camera file using
This camdict can be read directly from a LPy camera file using
```python
camdict = read_camera('my_camera.txt')
camdict=read_camera('my_camera.txt')
```
Alternatively, if the camera parameters depend on the values of the free variables,
Alternatively, if the camera parameters depend on the values of the free variables, on can define a function of the two free variables, that will return a dictionary corresponding to each pair of free variables values:
on can define a function of the two free variables, that will return a dictionary corresponding to each pair of free variables values:
```python
defcam_setting_fun1(x,y):
def cam_setting_fun1(x,y):
'''
'''
Function that defines the camera setting values for each pair of parameter values (x,y)
Function that defines the camera setting values for each pair of parameter values (x,y)