Artists
- class Artists(model)[source]
This class is used to configure how the display environment works.
- Parameters:
model – The GEB model.
- draw_crop_farmers(model, agents, idx, color='#ff0000')[source]
This function is used to draw farmers. First it is determined what crop is grown by the farmer, then the we get the color used to display that crop from the model configuration.
- Parameters:
model – The GEB model.
agents – The farmer class to plot.
idx (
int
) – The farmer index.
- Returns:
portrayal – Portrayal of farmer.
- Return type:
dict
- get_array(attr, decompress=False)[source]
This function retrieves a NumPy array from the model based the name of the variable. Optionally decompresses the array.
- Parameters:
attr (
str
) – Name of the variable to retrieve. Name can contain “.” to specify variables are a “deeper” level.decompress (
bool
) – Boolean value whether to decompress the array. If True, the class to which the top variable name belongs to must have an equivalent function called decompress.
- Returns:
array – The requested array.
- Return type:
ndarray
Example
Read discharge from data.grid. Because
decompress=True
, data.grid must have a decompress method.>>> get_array(data.grid.discharge, decompress=True)
- get_background(minvalue=None, maxvalue=None, color='#1386FF')[source]
This function is called from the canvas class to draw the canvas background. The name of the variable to draw is stored in self.background_variable.
- Parameters:
minvalue (
Union
[float
,int
,None
]) – The minimum value for the display scale.maxvalue (
Union
[float
,int
,None
]) – The maximum value for the display scale.color (
str
) – The color to use to display the variable.
- Returns:
background – RGBA-array to display as background.
legend – Dictionary with data and formatting rules for background legend.
- Return type:
tuple
[ndarray
,dict
]
- get_background_variables()[source]
This function gets a list of variables that can be used to show in the background.
- Returns:
options – List of names for options to show in background.
- Return type:
list
- get_custom_plot()[source]
Here you can specify custom options for plotting the background.
- Returns:
custom_dict – Dictionary of dictionaries. The first level is the name of each of the variables, the second level the options for those variables.
- Return type:
dict
[dict
]
Example
{ 'HRU.crop_map': { 'type': 'discrete', 'nanvalue': -1, 'names': ['crop name 1', 'crop name 2'], 'colors': ['#00FF00', '#FF0000'] } }
- set_background_variable(option_name)[source]
This function is used to update the name of the variable to use for drawing the background of the map.
- Return type:
None
- set_variables()[source]
This function is used to get a dictionary of variables that can be shown as background variable. The dictionary
self.variables_dict
contains the name of each variable to display as key, and the actual variable as value.Checks are performed to see whether the data is the right size. Only compressed data can be shown. If a dataset has multiple dimensions, the dimensions can be shown seperately as variable[0], variable[1], ….
- Return type:
None