CROC
- drama.croc.get_basic_config(framework='DRAMA', project=None)
Returns the base config read from the provided project or the default if no project is specified.
- Parameters:
framework (str) – defines whether DRAMA or DMF is using the wrapper
project (str) – Path to DRAMA project to use as baseline (directory or exported project). If
None
the default project is used.
- Returns:
The config dict as specified in parameter
config
inrun()
.
- drama.croc.run_lazy(config=None, dependent_variables=[], project=None, save_output_dirs=None, parallel=True, ncpus=None, timeout=None, logging_queue=None, log_level='DEBUG', log_group_id=None, framework='DRAMA', keep_output_files='summary', spell_check=True, **kwargs)
Run (parametric) CROC analysis and returns a dictionary with config and iterable results.
- Parameters:
config (dict or list) –
The (parametric) CROC run configuration. If a dictionary is provided it must be of the following format (lists are used for parametric analyses):
{ 'runId': str or list, 'comment1': str or list, 'comment2': str or list, 'functionalitySwitch': int [1,2,3], 'aspectAngleTheta': float or list [deg], 'aspectAnglePhi': float or list [deg], 'rotationAxisTheta': float or list [deg], 'rotationAxisPhi': float or list [deg], }
Alternatively,
config
can also be a list of config dictionaries, or any iterable. Each config dictionary in this case describes one run and thus can not contain any list to expand.dependent_variables (list of lists of strs) – Describe which parameters depend on each other in a parametric analysis. Each list of parameters defines one dependency. See the example below for details.
project (str) – Path to DRAMA project to use as baseline (directory or exported project). If
None
the default project is used.save_output_dirs – Save the output directories of all runs to this directory. Each run will have its own numbered directory. The path to it is stored in
output_dir
in each run’s config. IfNone
the output directories will be deleted.parallel (bool) – Define if simulations shall be run in parallel.
ncpus (int) – Number of CPUs to use if parallel is True. If not specified, the maximum available will be used.
keep_output_files (str or list) – If list, it contains the filenames of the output files that will be saved into the output_dir (shared list for reentry and risk analysis). If ‘all’ the whole output folder will be saved into the output_dir, if ‘summary’ (Default), only a default list of output files will be saved into the output_dir (valid only if output_dir is provided as input parameter).
timeout (int) – Timeout in seconds for each run.
logging_queue (manager.Queue) – thread safe queue, which aggregates log messages for the caller.
log_level (str) – the log level for the logger, can be DEBUG, INFO, WARNING, ERROR and CRITICAL.
log_group_id (str) – additional argument that is added to a log record.
framework (str) – defines whether DRAMA or DMF is using the wrapper.
spell_check (bool) – Specify if the case to run should contain only keywords that are present in the configuration file.
**kwargs – If
config
isNone
, the CROC run configuration values can be passed on as kwargs.
- Returns:
{ 'config': provided config of all runs, 'results': <generator object generic_run_lazy>, }
Examples
Direct call with one run:
from drama import croc results_lazy = croc.run_lazy(functionalitySwitch=1, aspectAngleTheta=0, aspectAngle_phi=0, rotationAxisTheta=20, rotationAxisPhi=60)
Multiple parametric runs passing a configuration dictionary (four runs with all possible combinations):
from drama import croc config = { 'functionalitySwitch': [1 ,1] 'aspectAngleTheta': [20, 40], 'aspectAnglePhi' : [30, 60], 'rotationAxisTheta' : [0, 0], 'rotationAxisPhi': [10,20], } results_lazy = croc.run_lazy(config) #store the cross section of each single run: cross_sections=[] for res in results_lazy['results']: for single_run_res in res: cross_sections.append(single_run_res['cross_section'])
Two runs with dependent variables (
aspectAngleTheta = 20, aspectAnglePhi = 5
andaspectAngleTheta = 40, aspectAnglePhi = 10
):from drama import croc config = { 'aspectAngleTheta': [20, 40], 'aspectAnglePhi': [5, 10], } dependent_variables = [['aspectAngleTheta', 'aspectAnglePhi']] results_lazy = croc.run_lazy(config, dependent_variables) #print the status of each single run: for res in results_lazy['results']: for single_run_res in res: print(single_run_res['status'])
- drama.croc.run(config=None, dependent_variables=[], project=None, json=None, save_output_dirs=None, parallel=True, ncpus=None, timeout=None, logging_queue=None, log_level='DEBUG', log_group_id=None, framework='DRAMA', keep_output_files='summary', tmpfile_path=None, spell_check=True, **kwargs)
Run (parametric) CROC analysis and return the results.
- Parameters:
config (dict or list) –
The (parametric) CROC run configuration. If a dictionary is provided it must be of the following format (lists are used for parametric analyses):
{ 'runId': str or list, 'comment1': str or list, 'comment2': str or list, 'functionalitySwitch': integer [1,2,3], 'aspectAngleTheta': float or list, 'aspectAnglePhi': float or list, 'rotationAxisTheta': float or list, 'rotationAxisPhi': float or list, }
Alternatively,
config
can also be a list of config dictionaries, or any iterable. Each config dictionary in this case describes one run and thus can not contain any list to expand.dependent_variables (list of lists of strs) – Describe which parameters depend on each other in a parametric analysis. Each list of parameters defines one dependency. See the example below for details.
json (dict) – Python object holding the resemblance of the JSON file containing all required fields needed for a run. It should conform with the ares_input.schema.json.
project (str) – Path to DRAMA project to use as baseline (directory or exported project). If
None
the default project is used.save_output_dirs – Save the output directories of all runs to this directory. Each run will have its own numbered directory. The path to it is stored in
output_dir
in each run’s config. IfNone
the output directories will be deleted.parallel (bool) – Define if simulations shall be run in parallel.
ncpus (int) – Number of CPUs to use if parallel is True. If not specified, the maximum available will be used.
keep_output_files (str or list) – If list, it contains the filenames of the output files that will be saved into the output_dir (shared list for reentry and risk analysis). If ‘all’ the whole output folder will be saved into the output_dir, if ‘summary’ (Default), only a default list of output files will be saved into the output_dir (valid only if output_dir is provided as input parameter).
timeout (int) – Timeout in seconds for each run.
logging_queue (manager.Queue) – thread safe queue, which aggregates log messages for the caller.
log_level (str) – the log level for the logger, can be DEBUG, INFO, WARNING, ERROR and CRITICAL.
log_group_id (str) – additional argument that is added to a log record.
framework (str) – defines whether DRAMA or DMF is using the wrapper.
tmpfile_path (ValueProxy) – hands back the tmp file path used by the analysis module so that it can be checked continuously in a separate thread.
spell_check (bool) – Specify if the case to run should contain only keywords that are present in the configuration file.
**kwargs – If
config
isNone
, the CROC run configuration values can be passed on as kwargs.
- Returns:
{ 'config': {}, # provided config of all runs, 'errors': [ # info on erroneous runs { 'config': config of single erroneous run, 'status': 'error <details>', 'output': stdout and stderr of croc process, 'logfile': croc logfile content, }, ... ], 'results': [ { 'config': config of single successful run, 'status': 'success', 'output': stdout and stderr of croc process, 'logfile': croc logfile content, 'cross_section': calculated cross section of the geometry, }, ... ], }
Examples
Direct call with one run:
from drama import croc results = croc.run(functionalitySwitch=1, aspectAngleTheta=0, aspectAnglePhi=0, rotationAxisTheta=20, rotationAxisPhi=60)
Multiple parametric runs passing a configuration dictionary (four runs with all possible combinations):
from drama import croc config = { 'functionalitySwitch': [1 ,1] 'aspectAngleTheta': [20, 40], 'aspectAnglePhi' : [30, 60], 'rotationAxisTheta' : [0, 0], 'rotationAxisPhi': [10,20], } results = croc.run(config)
Two runs with dependent variables (
aspectAngleTheta = 20, aspectAnglePhi = 5
andaspectAngleTheta = 40, aspectAnglePhi = 10
):from drama import croc config = { 'aspectAngleTheta': [20, 40], 'aspectAnglePhi': [5, 10], } dependent_variables = [['aspectAngleTheta', 'aspectAnglePhi']] results = croc.run(config, dependent_variables)
- drama.croc.get_progress(tmpfile_path)
Retrieves the current progress of CROC, when the tmpfile_path already exists
- drama.plot_croc.plot_cross_section_variation(results, variables, target='cross_section', plotfile_name='croc', x_label=None, y_label=None, framework='DRAMA')
Generates the colored splot with ‘target’ variable from the provided ‘results’ from CROC.
- Parameters:
results (list) – List of dict of CROC results. Each dictionary must contain the ‘target’ key.
target (str) – The target variable
plotfile_name (str) – file name (without extension) for the output file.
x_label (str) – label for the x axis
y_label (str) – label for the y axis
framework (str) – defines whether DRAMA or DMF is using the wrapper.
Note
- Creates
{plotfile_name}.png
file the heatmap plot for the ‘target’ variable.