Skip to content

Commit caa40e2

Browse files
committed
refactored backgrounds and resolutions to use source parameter
1 parent 4d08b5d commit caa40e2

File tree

16 files changed

+439
-313
lines changed

16 files changed

+439
-313
lines changed

RATapi/examples/absorption/absorption.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@
140140
"problem.background_parameters.append(name=\"Background parameter 3\", min=1.0e-06, value=9.01e-06, max=9.0e-05, fit=True)\n",
141141
"problem.background_parameters.append(name=\"Background parameter 4\", min=1.0e-06, value=5.61e-06, max=9.0e-05, fit=True)\n",
142142
"\n",
143-
"problem.backgrounds.append(name=\"Background 1\", type=\"constant\", value_1=\"Background parameter 1\")\n",
144-
"problem.backgrounds.append(name=\"Background 2\", type=\"constant\", value_1=\"Background parameter 2\")\n",
145-
"problem.backgrounds.append(name=\"Background 3\", type=\"constant\", value_1=\"Background parameter 3\")\n",
146-
"problem.backgrounds.append(name=\"Background 4\", type=\"constant\", value_1=\"Background parameter 4\")\n",
143+
"problem.backgrounds.append(name=\"Background 1\", type=\"constant\", source=\"Background parameter 1\")\n",
144+
"problem.backgrounds.append(name=\"Background 2\", type=\"constant\", source=\"Background parameter 2\")\n",
145+
"problem.backgrounds.append(name=\"Background 3\", type=\"constant\", source=\"Background parameter 3\")\n",
146+
"problem.backgrounds.append(name=\"Background 4\", type=\"constant\", source=\"Background parameter 4\")\n",
147147
"\n",
148148
"# Make the resolution fittable\n",
149149
"problem.resolution_parameters.set_fields(0, fit=True)\n"

RATapi/examples/absorption/absorption.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ def absorption():
6868
name="Background parameter 4", min=1.0e-06, value=5.61e-06, max=9.0e-05, fit=True
6969
)
7070

71-
problem.backgrounds.append(name="Background 1", type="constant", value_1="Background parameter 1")
72-
problem.backgrounds.append(name="Background 2", type="constant", value_1="Background parameter 2")
73-
problem.backgrounds.append(name="Background 3", type="constant", value_1="Background parameter 3")
74-
problem.backgrounds.append(name="Background 4", type="constant", value_1="Background parameter 4")
71+
problem.backgrounds.append(name="Background 1", type="constant", source="Background parameter 1")
72+
problem.backgrounds.append(name="Background 2", type="constant", source="Background parameter 2")
73+
problem.backgrounds.append(name="Background 3", type="constant", source="Background parameter 3")
74+
problem.backgrounds.append(name="Background 4", type="constant", source="Background parameter 4")
7575

7676
# Make the resolution fittable
7777
problem.resolution_parameters.set_fields(0, fit=True)

RATapi/examples/languages/setup_problem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ def make_example_problem():
8282
)
8383

8484
# And add the two new constant backgrounds
85-
problem.backgrounds.append(name="Background SMW", type="constant", value_1="Background parameter SMW")
86-
problem.backgrounds.append(name="Background H2O", type="constant", value_1="Background parameter H2O")
85+
problem.backgrounds.append(name="Background SMW", type="constant", source="Background parameter SMW")
86+
problem.backgrounds.append(name="Background H2O", type="constant", source="Background parameter H2O")
8787

8888
# And edit the other one
89-
problem.backgrounds.set_fields(0, name="Background D2O", value_1="Background parameter D2O")
89+
problem.backgrounds.set_fields(0, name="Background D2O", source="Background parameter D2O")
9090

9191
# Finally modify some of the other parameters to be more suitable values for a solid / liquid experiment
9292
problem.scalefactors.set_fields(0, value=1.0, min=0.5, max=2.0, fit=True)

RATapi/examples/non_polarised/DSPC_custom_XY.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ def DSPC_custom_XY():
9090
problem.background_parameters.append(name="Background parameter H2O", min=0.0, value=1.0e-7, max=1.0e-5, fit=True)
9191

9292
# And add the two new constant backgrounds
93-
problem.backgrounds.append(name="Background SMW", type="constant", value_1="Background parameter SMW")
94-
problem.backgrounds.append(name="Background H2O", type="constant", value_1="Background parameter H2O")
93+
problem.backgrounds.append(name="Background SMW", type="constant", source="Background parameter SMW")
94+
problem.backgrounds.append(name="Background H2O", type="constant", source="Background parameter H2O")
9595

9696
# And edit the other one
97-
problem.backgrounds.set_fields(0, name="Background D2O", value_1="Background parameter D2O")
97+
problem.backgrounds.set_fields(0, name="Background D2O", source="Background parameter D2O")
9898

9999
# Finally modify some of the other parameters to be more suitable values for a solid / liquid experiment
100100
problem.scalefactors.set_fields(0, value=1.0, min=0.5, max=2.0, fit=True)

RATapi/examples/non_polarised/DSPC_custom_layers.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,11 @@
534534
"problem.background_parameters.append(name=\"Background parameter H2O\", min=1.0e-10, value=1.0e-7, max=1.0e-5, fit=True)\n",
535535
"\n",
536536
"# And add the two new constant backgrounds\n",
537-
"problem.backgrounds.append(name=\"Background SMW\", type=\"constant\", value_1=\"Background parameter SMW\")\n",
538-
"problem.backgrounds.append(name=\"Background H2O\", type=\"constant\", value_1=\"Background parameter H2O\")\n",
537+
"problem.backgrounds.append(name=\"Background SMW\", type=\"constant\", source=\"Background parameter SMW\")\n",
538+
"problem.backgrounds.append(name=\"Background H2O\", type=\"constant\", source=\"Background parameter H2O\")\n",
539539
"\n",
540540
"# And edit the other one\n",
541-
"problem.backgrounds.set_fields(0, name=\"Background D2O\", value_1=\"Background parameter D2O\")\n",
541+
"problem.backgrounds.set_fields(0, name=\"Background D2O\", source=\"Background parameter D2O\")\n",
542542
"\n",
543543
"# Finally modify some of the other parameters to be more suitable values for a solid / liquid experiment\n",
544544
"problem.scalefactors.set_fields(0, value=1.0, min=0.5, max=2.0, fit=True)"

RATapi/examples/non_polarised/DSPC_custom_layers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ def DSPC_custom_layers():
7474
)
7575

7676
# And add the two new constant backgrounds
77-
problem.backgrounds.append(name="Background SMW", type="constant", value_1="Background parameter SMW")
78-
problem.backgrounds.append(name="Background H2O", type="constant", value_1="Background parameter H2O")
77+
problem.backgrounds.append(name="Background SMW", type="constant", source="Background parameter SMW")
78+
problem.backgrounds.append(name="Background H2O", type="constant", source="Background parameter H2O")
7979

8080
# And edit the other one
81-
problem.backgrounds.set_fields(0, name="Background D2O", value_1="Background parameter D2O")
81+
problem.backgrounds.set_fields(0, name="Background D2O", source="Background parameter D2O")
8282

8383
# Finally modify some of the other parameters to be more suitable values for a solid / liquid experiment
8484
problem.scalefactors.set_fields(0, value=1.0, min=0.5, max=2.0, fit=True)

RATapi/examples/non_polarised/DSPC_custom_xy.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@
175175
"problem.background_parameters.append(name=\"Background parameter H2O\", min=0.0, value=1.0e-7, max=1.0e-5, fit=True)\n",
176176
"\n",
177177
"# And add the two new constant backgrounds\n",
178-
"problem.backgrounds.append(name=\"Background SMW\", type=\"constant\", value_1=\"Background parameter SMW\")\n",
179-
"problem.backgrounds.append(name=\"Background H2O\", type=\"constant\", value_1=\"Background parameter H2O\")\n",
178+
"problem.backgrounds.append(name=\"Background SMW\", type=\"constant\", source=\"Background parameter SMW\")\n",
179+
"problem.backgrounds.append(name=\"Background H2O\", type=\"constant\", source=\"Background parameter H2O\")\n",
180180
"\n",
181181
"# And edit the other one\n",
182-
"problem.backgrounds.set_fields(0, name=\"Background D2O\", value_1=\"Background parameter D2O\")\n",
182+
"problem.backgrounds.set_fields(0, name=\"Background D2O\", source=\"Background parameter D2O\")\n",
183183
"\n",
184184
"# Finally modify some of the other parameters to be more suitable values for a solid / liquid experiment\n",
185185
"problem.scalefactors.set_fields(0, value=1.0, min=0.5, max=2.0, fit=True)\n",

RATapi/examples/non_polarised/DSPC_standard_layers.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@
184184
"problem.background_parameters.append(name=\"Background parameter D2O\", min=5.0e-10, value=2.23e-06, max=7.0e-06, fit=True)\n",
185185
"problem.background_parameters.append(name=\"Background parameter SMW\", min=1.0e-10, value=3.38e-06, max=4.99e-06, fit=True)\n",
186186
"\n",
187-
"problem.backgrounds.append(name=\"D2O Background\", type=\"constant\", value_1=\"Background parameter D2O\")\n",
188-
"problem.backgrounds.append(name=\"SMW Background\", type=\"constant\", value_1=\"Background parameter SMW\")"
187+
"problem.backgrounds.append(name=\"D2O Background\", type=\"constant\", source=\"Background parameter D2O\")\n",
188+
"problem.backgrounds.append(name=\"SMW Background\", type=\"constant\", source=\"Background parameter SMW\")"
189189
]
190190
},
191191
{

RATapi/examples/non_polarised/DSPC_standard_layers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ def DSPC_standard_layers():
147147
fit=True,
148148
)
149149

150-
problem.backgrounds.append(name="D2O Background", type="constant", value_1="Background parameter D2O")
151-
problem.backgrounds.append(name="SMW Background", type="constant", value_1="Background parameter SMW")
150+
problem.backgrounds.append(name="D2O Background", type="constant", source="Background parameter D2O")
151+
problem.backgrounds.append(name="SMW Background", type="constant", source="Background parameter SMW")
152152

153153
# Now add the data
154154
data_path = pathlib.Path(__file__).parents[1] / "data"

RATapi/inputs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def make_problem(project: RATapi.Project, checks: Checks) -> ProblemDefinition:
235235
if background.type == TypeOptions.Data:
236236
contrast_background_params.append([-1])
237237
else:
238-
contrast_background_params.append([project.background_parameters.index(background.value_1, True)])
238+
contrast_background_params.append([project.background_parameters.index(background.source, True)])
239239

240240
# Set resolution parameters, with -1 used to indicate a data resolution
241241
all_data = []
@@ -248,7 +248,7 @@ def make_problem(project: RATapi.Project, checks: Checks) -> ProblemDefinition:
248248
if resolution.type == TypeOptions.Data:
249249
contrast_resolution_params.append(-1)
250250
else:
251-
contrast_resolution_params.append(project.resolution_parameters.index(resolution.value_1, True))
251+
contrast_resolution_params.append(project.resolution_parameters.index(resolution.source, True))
252252

253253
data_index = project.data.index(contrast.data)
254254
data = project.data[data_index].data

0 commit comments

Comments
 (0)