parallel_scan
Classes¤
ParallelScan ¤
ParallelScan(
scanning_parameter=None,
start=None,
end=None,
step=None,
working_dir="",
distribution_file="generator.in",
run_file="photo_track.in",
n_parallel=3,
log_dir="log",
initial_run_number=None,
console_log=True,
)
Bases: Core
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scanning_parameter |
str | list
|
Name of the parameters to be scanned. If multiple parameters are to be scanned, they must be must be inserted as a list of strings. Scanning parameters options can be added later by the |
None
|
start |
float | list
|
Starting value of the scan. If the scan is performed for a single parameter, type is |
None
|
end |
float | list
|
Final value of the scan. If the scan is performed for a single parameter, type is |
None
|
step |
float | list
|
Scanning step. If the scan is performed for a single parameter, type is |
None
|
working_dir |
str | Path
|
description. Defaults to "". |
''
|
distribution_file |
str | Path
|
Name of the ASTRA distribution file. Defaults to "generator.in". |
'generator.in'
|
run_file |
str | Path
|
Name of the ASTRA run file. Defaults to "photo_track.in". |
'photo_track.in'
|
n_parallel |
int
|
Number of parallel ASTRA simulations to be run. Defaults to 3. |
3
|
log_dir |
str | Path
|
Name of the log directory, that will be created inside the working directory (can be relative path). Defaults to "log". |
'log'
|
initial_run_number |
int
|
Starting number of run that will be used by ASTRA to identify different runs. If left to None (by default), the run number will be assigned automatically. Defaults to None. |
None
|
console_log |
bool
|
If False, the log will not be written to the console. Defaults to False. |
True
|
Source code in astra/parallel_scan.py
Functions¤
add_scanning_parameter ¤
add_scanning_parameter(
parameter,
values=None,
start=None,
end=None,
step=None,
n_steps=None,
**kwargs
)
Method to add a parameter to scan. Based on what parameters are specified, the method calculates the rest of them.
For to method not to raise Exception, the parameter must be fully defined. This can be achieved by the following:
1. Full values list (values
)
2. Start and end values (start
, end
) + step size (step
)
3. Start and end values (start
, end
) + number of steps (n_steps
)
This list also corresponds to the order at which the definition of the parameter is checked.
Once the parameter is fully defined (one of the steps above is well inputed), the rest of inputed values may be discarded may be internally overwritten to match the calculated values from the full definition.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameter |
str
|
Name of the scanning parameter. |
required |
values |
list
|
Full list of values to be scanned. If specified, defines fully the parameter. Defaults to None. |
None
|
start |
float
|
Starting value of the scan. Will be taken into account only if |
None
|
end |
float
|
Final value of the scan. Will be taken into account only if |
None
|
step |
float | list
|
Step size to be performed. For constant step size, use |
None
|
n_steps |
int
|
Number of constant steps to be performed. Will be taken into account only if |
None
|
Raises:
Type | Description |
---|---|
Exception
|
Raised if neither number of steps (n_step) nor step size (step) is given. |
Source code in astra/parallel_scan.py
check_lost_particles ¤
Check for particles lost in the runs and logs it.
Source code in astra/parallel_scan.py
get_estimated_time_to_finish ¤
Calculates the estimated time to finish.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
XXh XXm format of time to finish. |
Source code in astra/parallel_scan.py
log_config_file ¤
Copies the config_file to the log directory
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_file |
(str, path)
|
Config file to be logged. |
required |
Source code in astra/parallel_scan.py
run_scan ¤
Runs the scan.
Source code in astra/parallel_scan.py
update_mean_runtime ¤
Updates the mean run time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
int
|
Time after the running process finished. |
required |
Source code in astra/parallel_scan.py
verify_initial_run_number ¤
Checks if run number is free. If not, the run number is set to first free run number.
Run number is considered as free, if all run number equal or higher than this are not taken.
Source code in astra/parallel_scan.py
Created: October 31, 2023