API
Perion Commands
- class Perion.Perion(config_file='')
A class to represent a wrapped Kalithea job.
- __init__(config_file='')
Initializes a Perion object based on the specified Kalithea binary.
- Parameters:
config_file (
str) – Optional path to the configuration file.- Raises:
PerionError – If neither the given nor the default config_file can be read.
The config_file has to be in JSON format and needs to contain the two objects
"binary"and"dependencies". The former holds the path to the Kalithea binary, the latter a list with paths to directories that need to be included into%PATH%in order to run the binary. If the config_file is omitted, the default config.json in%APPDATA%/Perion(Windows) or/home/$username/.config/Perion(Linux) is used.
- static createDispFile(json_emitter_file_name, disp_file_name, shift=None, target_crs=None)
Creates an additional input file holding information about kind and position of warning devices for perceptibility calculations.
- Parameters:
json_emitter_file_name (
str) – The path to a (Geo)JSON file containing information about the warning devices and their positions.disp_file_name (
str) – The file path to the input file to be created.shift (
Optional[list[float]]) – Optional coordinate vector that is added to each warning device position.target_crs (
Union[str,int,None]) – Optional specification of the target CRS of the warning devices.Nonekeeps the given coordinates.
- Return type:
- Returns:
A dictionary of collected meta data for each warning device.
- static createInput(json_calc_args, input_file_name)
Creates a Kalithea input file from a dictionary.
- static createSTL(extrusion_height, json_layout_file_name, stl_file_name, shift=None, outer_bound=False, reverse=False, binary=True, target_crs=None)
Creates a 3D model in STL format from a 2D layout by using data from
LayoutManager.get3DLayout().- Parameters:
extrusion_height (
float) – The model’s spacial extent along the z-axis in units of the coordinate systemjson_layout_file_name (
str) – The path to the GeoJSON file holding the 2D layout.stl_file_name (
str) – The file path of the STL file to be created.shift (
Optional[list[float]]) – Optional coordinate vector that is added to each vertix of the 3D model.outer_bound (
bool) – Optional flag signaling the inversion of the inside and outside of the 3D model. If outer_bound isTrueall obstacles in the 2D layout will become open spaces in the 3D model and vice versa.reverse (
bool) – Optional flag to trigger the reversal of the polygons’ vertix ordering in the 2D layout.binary (
bool) – Optional flag to switch between ASCII or binary STL output.target_crs (
Union[str,int,None]) – Optional specification of the target CRS of the 3D model.Nonekeeps the given coordinates.
- Return type:
tuple[Optional[ndarray[Any,dtype[TypeVar(ScalarType, bound=generic, covariant=True)]]],Optional[int]]- Returns:
A tuple (centroid, city_model_crs). centroid is the original center of the created 3D model if a shift is applied. Otherwise it’s
None. city_model_crs is the coordinate reference system of the newly created STL.
- launchCalculation(input_file, stdout_file='', stderr_file='', cwd=None)
Runs the Kalithea binary in a new process and redirects the command line outputs to files if requested.
- Parameters:
input_file (str) – The Kalithea input file. Can be created with
Perion.createInput().stdout_file (str) – A file to save the Kalithea command line output. If nothing is specified, the outputs are discarded.
stderr_file (str) – A file to save the Kalithea command line errors. If nothing is specified, the error messages are discarded.
- Returns:
The spawned Kalithea process.
- Return type:
subprocess.Popen object