Skip to content

Commit 8698f4a

Browse files
committed
Adds resolutions to inputs and outputs
1 parent 7f5cc01 commit 8698f4a

File tree

4 files changed

+902
-6
lines changed

4 files changed

+902
-6
lines changed

RATapi/inputs.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def make_problem(project: RATapi.Project, checks: Checks) -> ProblemDefinition:
247247
background = project.backgrounds[contrast.background]
248248
contrast_background_types.append(background.type)
249249
contrast_background_param = []
250+
250251
if background.type == TypeOptions.Data:
251252
contrast_background_param.append(project.data.index(background.source, True))
252253
if background.value_1 != "":
@@ -275,17 +276,37 @@ def make_problem(project: RATapi.Project, checks: Checks) -> ProblemDefinition:
275276

276277
contrast_background_params.append(contrast_background_param)
277278

278-
# contrast data has exactly six columns to include background data if relevant
279-
all_data.append(np.column_stack((data, np.zeros((data.shape[0], 6 - data.shape[1])))))
280-
281-
# Set resolution parameters, with -1 used to indicate a data resolution
282-
contrast_resolution_param = []
279+
# set resolution parameters
283280
resolution = project.resolutions[contrast.resolution]
284281
contrast_resolution_types.append(resolution.type)
285-
if resolution.source:
282+
contrast_resolution_param = []
283+
if resolution.type == TypeOptions.Data:
284+
# The source field is empty for a data resolution
285+
pass
286+
elif resolution.type == TypeOptions.Function:
287+
contrast_resolution_param.append(project.custom_files.index(resolution.source, True))
288+
contrast_resolution_param.extend(
289+
[
290+
project.resolution_parameters.index(value, True)
291+
for value in [
292+
resolution.value_1,
293+
resolution.value_2,
294+
resolution.value_3,
295+
resolution.value_4,
296+
resolution.value_5,
297+
]
298+
if value != ""
299+
]
300+
)
301+
302+
else:
286303
contrast_resolution_param.append(project.resolution_parameters.index(resolution.source, True))
304+
287305
contrast_resolution_params.append(contrast_resolution_param)
288306

307+
# contrast data has exactly six columns to include background data if relevant
308+
all_data.append(np.column_stack((data, np.zeros((data.shape[0], 6 - data.shape[1])))))
309+
289310
problem = ProblemDefinition()
290311

291312
problem.TF = project.calculation

RATapi/outputs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class Results:
8181
simulation: list
8282
shiftedData: list
8383
backgrounds: list
84+
resolutions: list
8485
layerSlds: list
8586
sldProfiles: list
8687
resampledLayers: list
@@ -239,6 +240,7 @@ def make_results(
239240
simulation=output_results.simulation,
240241
shiftedData=output_results.shiftedData,
241242
backgrounds=output_results.backgrounds,
243+
resolutions=output_results.resolutions,
242244
layerSlds=output_results.layerSlds,
243245
sldProfiles=output_results.sldProfiles,
244246
resampledLayers=output_results.resampledLayers,
@@ -260,6 +262,7 @@ def make_results(
260262
simulation=output_results.simulation,
261263
shiftedData=output_results.shiftedData,
262264
backgrounds=output_results.backgrounds,
265+
resolutions=output_results.resolutions,
263266
layerSlds=output_results.layerSlds,
264267
sldProfiles=output_results.sldProfiles,
265268
resampledLayers=output_results.resampledLayers,

0 commit comments

Comments
 (0)