core
Classes¤
Core ¤
Core(
working_dir="",
distribution_file="generator.in",
run_file="photo_track.in",
log_dir="log",
log_file_name="log.log",
console_log=False,
logger_name=None,
)
Bases: object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
working_dir |
str
|
Name of the working directory (can be relative path). Defaults to "". |
''
|
distribution_file |
str
|
Name of the ASTRA distribution file. Defaults to "generator.in". |
'generator.in'
|
run_file |
str
|
Name of the ASTRA run file. Defaults to "photo_track.in". |
'photo_track.in'
|
log_dir |
str
|
Name of the log directory, that will be created inside the working directory (can be relative path). Defaults to "log". |
'log'
|
log_file_name |
str
|
Name of the log file. Defaults to "log.log". |
'log.log'
|
console_log |
bool
|
If False, the log will not be written to the console. Defaults to False. |
False
|
logger_name |
str | None
|
Name of the logger for possible logger sharing. If set to None, new logger will be created. Defaults to None. |
None
|
Source code in common/core.py
Functions¤
_parameter_values_initialization ¤
_parameter_values_initialization(
parameter,
values=None,
start=None,
end=None,
step=None,
n_steps=None,
)
Method to initialise the scan settings. To be used internally within methods of child classes. 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 points above is well inputed), the rest of inputed values 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
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary fully defining the scanning parameter. "parameter": Parameter name, "start": Start of the scan, "end": End of the scan, "values": Values of the scan, "step": Size of constant step, "steps": List of all steps, "n_steps": number of steps |
Source code in common/core.py
acquire_fileLock ¤
Method to obtain the lock of a file for multithreading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fileName |
str
|
Name of the file to be locked. |
required |
Returns:
Type | Description |
---|---|
FileLock
|
filelock.FileLock: Filelock instance for the file. |
Source code in common/core.py
get_first_free_run_number ¤
Method to obtain the first free run number in the working directory.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Number of first free run number. |
Source code in common/core.py
get_output_file_handler ¤
Method to obtain the output file handler for writing to the run output file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
working_dir |
str | Path
|
Path to the working dir. |
required |
output_file_name |
str
|
Name of the output file to be written to. Defaults to "output_file.xlsx". |
'output_file.xlsx'
|
Returns:
Type | Description |
---|---|
OutputFileHandler
|
output_file_handler.OutputFileHandler: Instance of the output file handler. |
Source code in common/core.py
setup_logger ¤
Function to setup internal logger
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_dir |
str | None
|
Name of the log directory, that will be created inside the working directory. If set to None, log dir and logging file will not be used. |
required |
log_file_name |
str
|
Name of log file, if None, there will be no log file. |
required |
console_log |
bool
|
If False, the log is not written to the console |
required |
Source code in common/core.py
Created: October 31, 2023