Inputs#
This module contains the objects used to organise input data to RAT to be fed into the C++ module.
Converts python models to the necessary inputs for the compiled RAT code.
- class ratapi.inputs.FileHandles(files=None)#
Class to defer creation of custom file handles.
- Parameters:
files (ClassList[CustomFile]) – A list of custom file models.
- copy()#
Create a copy of the FileHandles object.
- Returns:
The copy of this FileHandles object.
- Return type:
- get_handle(index)#
Return file handle for a given custom file.
- Parameters:
index (int) – The index of the custom file.
- ratapi.inputs.append_data_background(data, background)#
Append background data to contrast data.
- Parameters:
data (np.array) – The contrast data to which we are appending a background.
background (np.array) – The background data to append to the contrast.
- Returns:
The contrast data with background data appended as two additional columns.
- Return type:
np.array
- ratapi.inputs.check_indices(problem)#
Check the indices given in a problem’s contrasts lie within the range of the corresponding parameter lists.
- Parameters:
problem (RAT.rat_core.ProblemDefinition) – The problem input used in the compiled RAT code.
- Return type:
None
- ratapi.inputs.get_layer_details(project)#
Get parameter indices for all layers defined in the project.
- Parameters:
project (Project)
- Return type:
list[int]
- ratapi.inputs.get_python_handle(file_name, function_name, path='')#
Get the function handle from a function defined in a python module located anywhere within the filesystem.
- Parameters:
file_name (str) – The name of the file containing the function of interest.
function_name (str) – The name of the function we wish to obtain the handle for within the module.
path (str) – The path to the file containing the function (default is “”, which represent the working directory).
- Returns:
handle – The handle of the function defined in the python module file.
- Return type:
Callable
- ratapi.inputs.make_controls(input_controls)#
Convert the controls object to the format required by the compiled RAT code.
- Parameters:
input_controls (RAT.Controls) – The controls model, which defines algorithmic properties.
- Returns:
controls – The controls object used in the compiled RAT code.
- Return type:
RAT.rat_core.Control
- ratapi.inputs.make_data_present(project)#
Construct the “dataPresent” field of the problem input required for the compiled RAT code.
- Parameters:
project (RAT.Project) – The project model, which defines the physical system under study.
- Returns:
The “dataPresent” field of the problem input used in the compiled RAT code.
- Return type:
list[int]
- ratapi.inputs.make_input(project, controls)#
Construct the inputs required for the compiled RAT code using the data defined in the input project and controls.
- Parameters:
project (RAT.Project) – The project model, which defines the physical system under study.
controls (RAT.Controls) – The controls model, which defines algorithmic properties.
- Returns:
problem (RAT.rat_core.ProblemDefinition) – The problem input used in the compiled RAT code.
cpp_controls (RAT.rat_core.Control) – The controls object used in the compiled RAT code.
- Return type:
tuple[ProblemDefinition, Control]
- ratapi.inputs.make_problem(project)#
Construct the problem input required for the compiled RAT code.
- Parameters:
project (RAT.Project) – The project model, which defines the physical system under study.
- Returns:
problem – The problem input used in the compiled RAT code.
- Return type:
RAT.rat_core.ProblemDefinition
- ratapi.inputs.make_resample(project)#
Construct the “resample” field of the problem input required for the compiled RAT code.
- Parameters:
project (RAT.Project) – The project model, which defines the physical system under study.
- Returns:
The “resample” field of the problem input used in the compiled RAT code.
- Return type:
list[int]