fitting
NON_BUMPS_ERROR = "Inequality constraints (constraints_factory) require the BUMPS engine; the selected minimizer uses '{package}'."
module-attribute
_EPS = 1e-30
module-attribute
DataSet1D
Bases: SerializerComponent
Source code in src/easyreflectometry/data/data_store.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
model
property
writable
Model function.
is_experiment
property
Is experiment.
is_simulation
property
Is simulation.
__init__(name='Series', x=None, y=None, ye=None, xe=None, model=None, x_label='x', y_label='y', auto_background=True, resolution_function=None)
Init function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution_function
|
Optional[ResolutionFunction]
|
The q-resolution this dataset was measured with (typically a
|
None
|
Source code in src/easyreflectometry/data/data_store.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
data_points()
Data points.
Source code in src/easyreflectometry/data/data_store.py
101 102 103 | |
__repr__()
Repr function.
Source code in src/easyreflectometry/data/data_store.py
105 106 107 | |
PolarizedDataSet
A polarized experiment: one dataset per measured spin channel, one shared model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the experiment. By default, 'PolarizedSeries'. |
'PolarizedSeries'
|
channels
|
dict[PolarizationChannel | str, DataSet1D]
|
The measured channels; at least one. Keys are 'pp', 'pm', 'mp', 'mm' (or the corresponding enum members). Two-channel NSF-only experiments simply provide 'pp' and 'mm'. |
None
|
model
|
Model
|
The model shared by all channels. By default, None. |
None
|
Source code in src/easyreflectometry/data/polarized.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
model
property
writable
The model shared by all channels.
channels
property
The measured channels, in canonical order (pp, pm, mp, mm).
Read-only view: use :meth:set_channel / :meth:remove_channel to
modify the channel set, so validation and model propagation apply.
available_channels
property
The measured channels, in canonical order (pp, pm, mp, mm).
is_experiment
property
Is experiment.
is_simulation
property
Is simulation.
set_channel(channel, dataset)
Add or replace one channel dataset.
The dataset is validated, adopts the shared model, and the canonical channel order is preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
Union[PolarizationChannel, str]
|
One of 'pp', 'pm', 'mp', 'mm' (or the corresponding enum member). |
required |
dataset
|
DataSet1D
|
The channel data. |
required |
Source code in src/easyreflectometry/data/polarized.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
remove_channel(channel)
Remove one channel dataset; the last remaining channel cannot be removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
Union[PolarizationChannel, str]
|
One of 'pp', 'pm', 'mp', 'mm' (or the corresponding enum member). |
required |
Source code in src/easyreflectometry/data/polarized.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
FitSettings
dataclass
Minimizer choice and its settings, as saved in a project.
Attributes:
| Name | Type | Description |
|---|---|---|
minimizer |
AvailableMinimizers
|
The engine and method. An alias member ( |
mode |
str
|
|
tolerance |
float | None
|
Generic convergence tolerance; None leaves it to the engine. |
max_evaluations |
int | None
|
Generic budget (BUMPS: optimizer steps); None leaves it to the engine. |
objective |
str
|
Zero-variance handling: |
engine_options |
dict[str, dict[str, Any]]
|
Method-specific options keyed by minimizer name, then option name, so values of one method are neither lost nor applied when switching. |
Source code in src/easyreflectometry/fit_settings.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
active_options()
Options of the selected minimizer.
Only :meth:validate and :meth:engine_kwargs read these, so every
option value reaching an engine has been validated.
Source code in src/easyreflectometry/fit_settings.py
220 221 222 223 224 225 226 | |
engine_kwargs()
The per-call keyword arguments for the selected minimizer.
LMFit: minimizer_kwargs with the options and the tolerance under its
method's keyword. DFO-LS: the options as plain keyword arguments.
BUMPS: none (its tolerance and budget are core fitter attributes).
Source code in src/easyreflectometry/fit_settings.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
set_option(name, value)
Set (or, with None, clear) an option of the selected minimizer.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the option is unknown or the value invalid; nothing is changed. |
Source code in src/easyreflectometry/fit_settings.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
validate()
Check every field; raises ValueError naming the first offending one.
Source code in src/easyreflectometry/fit_settings.py
262 263 264 265 266 267 268 269 270 | |
configure(fitter)
Write the minimizer and generic settings onto a core fitter.
The minimizer is switched only when it differs (core rebuilds it on
every switch). Tolerance and budget are written unconditionally, so a
field reset to None clears a previous override; LMFit's tolerance goes
per call instead (:meth:engine_kwargs), so the core fitter's stays None.
Source code in src/easyreflectometry/fit_settings.py
272 273 274 275 276 277 278 279 280 281 282 283 | |
to_dict()
Serializable form, as stored in a project file.
Source code in src/easyreflectometry/fit_settings.py
285 286 287 288 289 290 291 292 293 294 | |
from_dict(data)
classmethod
Settings from a project file, never raising on content.
Aliases are normalised, option keys included (the member's own key wins over its alias's). Content that is not a mapping, an unknown or unavailable minimizer, an invalid value or a sampling mode without BUMPS falls back to the default, and unknown or invalid options are dropped; each is reported.
Returns:
| Type | Description |
|---|---|
tuple[FitSettings, list[str]]
|
The settings and the warnings to show the user. |
Source code in src/easyreflectometry/fit_settings.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
Model
Bases: BaseCore
Model is the class that represents the experiment.
It is used to store the information about the experiment and to perform the calculations.
Source code in src/easyreflectometry/model/model.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
guide_field_angle
property
writable
Field angle about the beam axis in degrees (refl1d Aguide); only magnetic calculators use it.
applied_field
property
writable
Applied field in tesla (refl1d H); only magnetic calculators use it.
total_thickness
property
Read-only parameter: the summed thickness of the film layers.
The superphase (first layer of the sample) and the subphase (last layer) are semi-infinite and excluded. The parameter is dependent: it tracks the layer thicknesses, never enters a fit and cannot be set; it can be referenced from constraint expressions and inequality constraints like any other parameter.
has_magnetism
property
Whether any layer in the sample carries magnetic properties.
is_default
property
writable
Whether this model was created as a default placeholder.
resolution_function
property
writable
Return the resolution function.
__init__(sample=None, scale=None, background=None, resolution_function=None, name='Model', color=COLORS[0], unique_name=None, interface=None, guide_field_angle=None, applied_field=None)
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unique_name
|
Optional[str]
|
By default, None. |
None
|
color
|
str
|
By default, COLORS[0]. |
COLORS[0]
|
sample
|
Union[Sample, None]
|
The sample being modelled. By default, None. |
None
|
scale
|
Union[Parameter, Number, None]
|
Scaling factor of profile. By default, None. |
None
|
background
|
Union[Parameter, Number, None]
|
Linear background magnitude. By default, None. |
None
|
name
|
str
|
Name of the model. By default, 'Model'. |
'Model'
|
resolution_function
|
Union[ResolutionFunction, None]
|
Resolution function. By default, None. |
None
|
guide_field_angle
|
Union[Parameter, Number, None]
|
Field angle about the beam axis in degrees (refl1d |
None
|
applied_field
|
Union[Parameter, Number, None]
|
Applied field in tesla (refl1d |
None
|
interface
|
Calculator interface. By default, None. |
None
|
Source code in src/easyreflectometry/model/model.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
refresh_derived()
Re-derive the model's computed parameters from the current layer structure.
Cheap (a few string operations) and idempotent: the dependency is
only rebuilt when the set of contributing layers changed. Called on
every access to :attr:total_thickness, so layers added or removed
through any path (Model.add_assemblies, assembly.layers.append,
...) are picked up without explicit notification.
Source code in src/easyreflectometry/model/model.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
add_assemblies(*assemblies)
Add assemblies to the model sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*assemblies
|
list[BaseAssembly]
|
Assemblies to add to model sample. |
()
|
Source code in src/easyreflectometry/model/model.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
duplicate_assembly(index)
Duplicate a given item or layer in a sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the item or layer to duplicate. |
required |
Source code in src/easyreflectometry/model/model.py
285 286 287 288 289 290 291 292 293 294 295 | |
remove_assembly(index)
Remove an assembly from the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the item to remove. |
required |
Source code in src/easyreflectometry/model/model.py
297 298 299 300 301 302 303 304 305 306 307 308 | |
generate_bindings()
Propagate the interface over the sample tree, then register this model's resolution function on the calculator.
Runs on every interface assignment and on every engine switch (the project regenerates bindings on a fresh calculator then), so the new calculator always knows this model's resolution.
Source code in src/easyreflectometry/model/model.py
343 344 345 346 347 348 349 350 351 352 | |
to_dict(skip=None)
Serialize the model, encoding the resolution function and interface name.
Source code in src/easyreflectometry/model/model.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
as_dict(skip=None)
Compatibility alias for :meth:to_dict.
Source code in src/easyreflectometry/model/model.py
392 393 394 | |
as_orso()
The sample as an ORSO simple-model (sample.model) dictionary.
Slab representation: lengths in angstrom, SLDs in 1/angstrom^2,
repeating multilayers via the inline N ( ... ) stack syntax.
Returns:
| Type | Description |
|---|---|
dict
|
The ORSO model-language dictionary (the content of an .ort file's
|
Source code in src/easyreflectometry/model/model.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
from_dict(passed_dict)
classmethod
Create a Model from a dictionary.
Source code in src/easyreflectometry/model/model.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
Pointwise
Bases: ResolutionFunction
Pointwise resolution defined by a per-point resolution provided with the data.
The resolution is supplied as the variance of the Qz values (sQz) at the
measured Qz data points, which is the form produced by data reduction (e.g.
Qz_0.variances). The resolution width at each point is sqrt(sQz).
For a requested q the width is obtained by linearly interpolating onto
q, exactly as :class:LinearSpline does for explicitly provided widths.
This is a convenience wrapper around :class:LinearSpline that derives the
widths from the [Qz, R, sQz] triple loaded from a data file; the returned
widths are consumed by the calculators (refnx x_err / refl1d dq),
which perform the actual convolution against the model.
Serialization contract: as_dict/from_dict store sQz_data_points
as variances (sigma squared). This is deliberately unchanged by the
ORSO value_is: FWHM support — FWHM columns are converted to sigma at
load time, so stored values are always sigma squared and saved projects
round-trip without migration.
Source code in src/easyreflectometry/model/resolution_functions.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
__init__(q_data_points)
Init function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q_data_points
|
List[np.ndarray]
|
|
required |
Source code in src/easyreflectometry/model/resolution_functions.py
130 131 132 133 134 135 136 137 138 139 140 | |
smearing(q=None)
Return the resolution sigma interpolated onto q.
sQz is the variance of Qz, so the sigma at each data point is
sqrt(sQz); values are linearly interpolated onto the requested
q. This already satisfies the sigma smearing() contract, so no
FWHM conversion is applied. When q is None, or q is
exactly the stored data points, the per-point sigma values are
returned as they are: a dataset merged from several measurements can
hold the same Qz twice with different widths (overlapping angles),
which no function of q can represent but a per-point lookup can.
Source code in src/easyreflectometry/model/resolution_functions.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
as_dict(skip=None)
As dict.
Source code in src/easyreflectometry/model/resolution_functions.py
167 168 169 170 171 172 173 174 175 176 | |
ResolutionFunction
Source code in src/easyreflectometry/model/resolution_functions.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
smearing(q)
abstractmethod
Return the resolution as sigma (standard deviation) at each q.
Source code in src/easyreflectometry/model/resolution_functions.py
35 36 37 38 | |
from_dict(data)
classmethod
Smearing function.
Source code in src/easyreflectometry/model/resolution_functions.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
_ConstrainedEasyScienceMultiFitter
Bases: EasyScienceMultiFitter
EasyScience MultiFitter whose raw fit honours inequality constraints.
fit is a read-only property on the base class (it builds a fresh
callable per access), so the interception lives in an override rather
than a monkey-patch. An explicit constraints_factory keyword is
consumed here and enforced by this library — the core takes no such
argument and would swallow it through **kwargs. Without one, a call
running inside an active :meth:MultiFitter._constraints block passes
through untouched, leaving the outer factory in force.
Source code in src/easyreflectometry/fitting.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
FitScopeError
Bases: ValueError
The experiments asked for cannot be fitted together (none selected, or one has no model).
Source code in src/easyreflectometry/fitting.py
325 326 | |
FitPreconditionError
Bases: ValueError
A fit that cannot start: the minimizer needs finite bounds some free parameters lack.
Attributes:
| Name | Type | Description |
|---|---|---|
parameters |
list
|
The offending parameters, each once. |
Source code in src/easyreflectometry/fitting.py
329 330 331 332 333 334 335 336 337 338 339 340 | |
_FitInput
dataclass
One dataset (or spin channel) to fit, before zero-variance handling.
Source code in src/easyreflectometry/fitting.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
PreparedFit
dataclass
Everything one fit run needs, fixed when it is prepared.
Built by :meth:MultiFitter.prepare, the one place that applies the
zero-variance objective, decides which resolution each fit function is
bound to, and configures the core fitter. Settings edited afterwards do not
reach it.
Attributes:
| Name | Type | Description |
|---|---|---|
settings |
FitSettings | None
|
Snapshot of the settings; None for a fitter without settings. |
objective |
str
|
The resolved zero-variance objective. |
channels |
list
|
Spin channel per dataset (None when unpolarized); keys polarized results. |
original |
list[dict]
|
|
fitted |
list[dict]
|
|
stats |
list[dict]
|
Zero-variance handling counts per dataset. |
curve_funcs |
list[Callable]
|
Full-resolution evaluators, for model curves and classical metrics. |
fit_funcs |
list[Callable]
|
Evaluators bound to the fitted points' resolution, as executed. |
core_fitter |
EasyScienceMultiFitter
|
The fitter that is executed. |
fit_kwargs |
dict
|
Method-specific option keyword arguments for the engine. |
added_roots |
list[Parameter]
|
Free parameters the fitted models follow but do not own (a tie to a model left out of the fit), varied so the tie does not hold them fixed. |
experiments |
list
|
The project experiment behind each dataset (one entry per spin channel
of a polarized one), set by :meth: |
skipped |
list[str]
|
Experiments left out because they have no model ( |
Source code in src/easyreflectometry/fitting.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
call_kwargs(**kwargs)
The engine keyword arguments of this run merged with per-call ones (which win).
Source code in src/easyreflectometry/fitting.py
439 440 441 442 443 444 445 446 | |
execute(**kwargs)
Run the fit synchronously; kwargs go to the core fitter's fit.
Source code in src/easyreflectometry/fitting.py
448 449 450 | |
finalize(results)
Objective and classical metrics of a finished run, one dict per dataset.
The classical metrics are computed from the measured arrays and the full-resolution curves, not from the transformed fitted arrays.
Source code in src/easyreflectometry/fitting.py
452 453 454 455 456 457 458 459 460 461 | |
FitRun
dataclass
The record of one completed (or failed, or cancelled) fit, kept by the project.
It belongs to the run, not to a fitter, so it outlives a change of the current model; and it names its datasets, so it can be read after the experiments were rearranged.
Statistics (only for a completed run):
pooled:objective_chi2(the engine's, on the transformed fitted points),objective_n_points,objective_dof(points minus :attr:n_free_parameters),objective_reduced_chi2; and the same fourclassical_*values over the measured points with a positive variance. A reduced value is None when its dof is not positive.per_dataset, in :attr:inputsorder:objective_chi2,objective_n_points,objective_chi2_per_point,classical_chi2,classical_n_points,classical_chi2_per_point(None without points) andshare_of_objective(None when the pooled chi-square is zero). The per-dataset objective values add up to the pooled one: the engine's per-dataset results are disjoint slices of the pooled residuals.
A record is history: read it, do not write to its dictionaries.
Source code in src/easyreflectometry/fitting.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | |
from_results(prepared, results, status, minimizer, metrics=None, inputs=None)
classmethod
The record of a run; metrics is prepared.finalize(results) when already
computed, inputs the (key, name, channel) of each dataset (unnamed otherwise).
Source code in src/easyreflectometry/fitting.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
remapped(keys)
This record after experiments were re-keyed (old key -> new key; a removed one -> None).
Source code in src/easyreflectometry/fitting.py
544 545 546 547 | |
MultiFitter
Source code in src/easyreflectometry/fitting.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 | |
sampler
property
The Sampler behind the most recent :meth:mcmc_sample call, or None.
Holds the live BUMPS chain state, so the sampling run can be continued
with fitter.sampler.extend(additional_samples=...) instead of
starting a fresh chain.
chi2
property
Total chi-squared across all fitted datasets, or None if no fit has been performed.
These properties describe this fitter's latest fit; a run prepared through
:meth:Project.prepare_fit is recorded in :attr:Project.last_fit, which
outlives a change of the current model.
reduced_chi
property
Reduced chi-squared from the most recent fit, or None if no fit has been performed.
classical_chi2
property
Classical chi-squared using only points with positive variances.
classical_reduced_chi
property
Reduced classical chi-squared using only points with positive variances.
objective_chi2
property
Objective-space chi-squared returned by the minimizer.
objective_reduced_chi
property
Objective-space reduced chi-squared returned by the minimizer.
__init__(*args, objective='hybrid')
A convenience class for the class:
easyscience.Fitting.Fitting
which will populate the class:
sc.DataGroup appropriately
after the fitting is performed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Model
|
Reflectometry model(s). |
()
|
objective
|
str
|
Zero-variance handling strategy. One of
|
'hybrid'
|
Source code in src/easyreflectometry/fitting.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
for_experiments(experiments, objective='hybrid', constraints_factory_provider=None)
classmethod
Build a fitter for a mixed list of unpolarized and polarized experiments.
Every experiment contributes one fit function per dataset: an ordinary
experiment one, a polarized experiment one per measured spin channel,
each evaluating that channel's spin cross-section against the single
model the channels share. Structural parameters are therefore common to
all channels and the magnetic ones are constrained by all of them at
once, exactly as in :meth:fit_polarized — but here several experiments
(and several models) can be fitted together, which is what an
application's "fit everything that is loaded" action needs.
The resulting fitter is not run. :meth:prepare (with no inputs)
prepares a run over :attr:fit_datasets, which a GUI can then execute
from a worker thread. Each fit function is bound to its dataset's own
resolution. Inequality constraints are resolved at execution through
:attr:constraints_factory_provider — pass constraints_factory_provider
(e.g. project.build_constraints_factory) or set the attribute
before fitting; with none set, no inequality constraints are enforced.
The fitter starts from the core defaults (minimizer, tolerance, budget)
unless :attr:settings is set, as :meth:Project.prepare_fit does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiments
|
list[DataSet1D | PolarizedDataSet]
|
The loaded experiments, in the order they should be fitted. |
required |
objective
|
str
|
Zero-variance handling strategy, see :meth: |
'hybrid'
|
constraints_factory_provider
|
Callable[[], Callable | None] | None
|
Zero-argument callable returning the |
None
|
Returns:
| Type | Description |
|---|---|
MultiFitter
|
Fitter whose |
Source code in src/easyreflectometry/fitting.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
prepare(inputs=None, *, objective=None, action='fitting', extra_warning='')
Prepare one fit run: zero-variance handling, bindings, configured core fitter.
This is the only place those rules are applied; :meth:fit,
:meth:fit_single_data_set_1d, :meth:fit_polarized,
:meth:mcmc_sample and an application's worker all run what it returns.
Preparing never changes this fitter, so preparing again (with another
objective, say) starts from the measured data each time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
list[_FitInput] | None
|
Datasets to fit. By default the :attr: |
None
|
objective
|
str | None
|
Zero-variance objective; by default the settings' or this fitter's. |
None
|
action
|
str
|
Verb for the zero-variance warnings. By default, 'fitting'. |
'fitting'
|
extra_warning
|
str
|
Sentence appended to the Mighell warnings. By default, ''. |
''
|
Returns:
| Type | Description |
|---|---|
PreparedFit
|
The run, ready to execute. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the settings are invalid (however they were edited), or
|
FitPreconditionError
|
If a free parameter's bounds are unusable for the minimizer. |
Note
The run owns copies of the measured arrays, so editing a dataset afterwards changes neither what it fits nor its metrics. Model parameters and constraints stay live: they are what the fit changes.
Source code in src/easyreflectometry/fitting.py
827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 | |
fit(data, id=0, objective=None, constraints_factory=None)
Perform the fitting and populate the DataGroups with the result.
On a fitter built with the models, curve k (the k-th Qz_<n>
by number) is fitted with model k and its resolution. On a fitter
built with :meth:for_experiments, curve k is fitted as entry k
of :attr:fit_datasets: that dataset's model, spin channel and own
resolution, with the arrays taken from the DataGroup. Each
curve's model curve, SLD profile and model are written back for that
curve's own model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
sc.DataGroup
|
DataGroup to be fitted to and populated. For a
:meth: |
required |
id
|
int
|
Unused parameter kept for backward compatibility. By default, 0. |
0
|
objective
|
str | None
|
Per-call override for the zero-variance objective.
If |
None
|
constraints_factory
|
Callable | None
|
Inequality constraints to enforce (BUMPS engines only); see
:mod: |
None
|
Returns:
| Type | Description |
|---|---|
sc.DataGroup
|
A new DataGroup with fitted model curves, SLD profiles, and fit statistics. |
Raises:
| Type | Description |
|---|---|
ValueError
|
On a :meth: |
Source code in src/easyreflectometry/fitting.py
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 | |
fit_single_data_set_1d(data, objective=None, constraints_factory=None)
Perform fitting on a single 1D dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataSet1D
|
The 1D dataset to fit. Note that |
required |
objective
|
str | None
|
Per-call override for the zero-variance objective.
If |
None
|
constraints_factory
|
Callable | None
|
Inequality constraints to enforce (BUMPS engines only). Defaults
to what :attr: |
None
|
Returns:
| Type | Description |
|---|---|
FitResults
|
Fit results from the minimizer. |
Note
When data carries its own resolution_function the fit is
smeared with it rather than with the model's.
Source code in src/easyreflectometry/fitting.py
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 | |
fit_polarized(data, objective=None, constraints_factory=None)
Fit all measured spin channels of a polarized experiment simultaneously.
Each channel dataset gets its own fit function evaluating the
corresponding spin cross-section, while every channel shares the single
model — so structural parameters (thickness, roughness, nuclear SLD,
scale, background) are common, and the magnetic parameters
(rho_m/theta_m) are constrained by all channels at once. The refl1d
backend computes all four cross-sections in one kernel evaluation and
caches them per iteration, so fitting N channels costs about as much as
fitting one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
PolarizedDataSet
|
The polarized experiment (its model must be the model this fitter
was constructed with). Note that per-channel |
required |
objective
|
str | None
|
Per-call override for the zero-variance objective.
If |
None
|
constraints_factory
|
Callable | None
|
Inequality constraints to enforce (BUMPS engines only); see
:mod: |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, FitResults]
|
Fit results per channel, keyed 'pp', 'pm', 'mp', 'mm' (measured channels only, in that order). |
Note
Unlike :meth:for_experiments, this method does not populate
:attr:fit_datasets / :attr:fit_channels — those are set only by the
caller-driven, for_experiments-built flow.
Source code in src/easyreflectometry/fitting.py
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 | |
mcmc_sample(data=None, samples=10000, burn=2000, thin=10, population=None, objective=None, initializer=None, progress_callback=None, abort_test=None, constraints_factory=None)
Run Bayesian MCMC sampling on reflectometry data using the DREAM sampler.
Requires that the minimizer is a BUMPS instance (i.e. the minimizer was
switched to AvailableMinimizers.Bumps).
:param data: DataGroup with reflectivity data. May be left out for a
fitter built with :meth:for_experiments: the sampler then runs
on :attr:fit_datasets, each dataset (each spin channel of a
polarized experiment) smeared with its own resolution, exactly as
:meth:prepare fits them. With a DataGroup and such a fitter,
curve k must be dataset k; its arrays are sampled with that
dataset's model, channel and resolution.
:param samples: Number of retained DREAM samples requested from BUMPS.
:param burn: Burn-in steps.
:param thin: Thinning interval.
:param population: BUMPS DREAM population count for advanced users.
:param objective: Zero-variance handling strategy.
:param initializer: DREAM population initializer. One of 'eps',
'cov', 'lhs', or 'random'. By default, None (BUMPS
uses 'eps').
:param progress_callback: Optional callback for progress updates during
sampling. Forwarded to the core MultiFitter.
:param abort_test: Optional callable returning True to abort sampling.
:param constraints_factory: Inequality constraints to enforce (see
:mod:easyreflectometry.inequality_constraints); the posterior is
penalised in the infeasible region. Defaults to what
:attr:constraints_factory_provider returns.
:return: Dictionary with keys 'draws', 'param_names', 'state',
and 'logp'.
:raises RuntimeError: If the current minimizer is not a BUMPS instance.
:raises ValueError: Without data on a fitter not built with
:meth:for_experiments, or with a DataGroup whose curve count
differs from the fitter's datasets.
The sampler reads none of the generic settings (tolerance, budget): only the minimizer, which must be a BUMPS one.
The underlying :class:~easyscience.fitting.Sampler is retained on
:attr:sampler, so the chain can be continued without re-running the
burn-in::
fitter.mcmc_sample(data, samples=2000, burn=500, thin=10)
extended = fitter.sampler.extend(additional_samples=8000, thin=10)
Source code in src/easyreflectometry/fitting.py
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 | |
record_fit_results(results, metrics=None)
Adopt fit results produced elsewhere, so this fitter reports on them.
An application that executes a :class:PreparedFit itself — in a
worker thread, for instance — leaves the MultiFitter that owns the
goodness-of-fit properties none the wiser. Handing the results back
here makes :attr:chi2 / :attr:reduced_chi describe that fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[FitResults] | None
|
Results of the fit, one per fitted dataset. None clears them. |
required |
metrics
|
list[dict] | None
|
:meth: |
None
|
Source code in src/easyreflectometry/fitting.py
1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 | |
switch_minimizer(minimizer)
Switch the minimizer for the fitting.
A fitter with :attr:settings (one a project hands out) switches the
settings' minimizer, as its runs are configured from them; for a
project's fitter that is project.minimizer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
minimizer
|
AvailableMinimizers
|
Minimizer to be switched to. |
required |
Source code in src/easyreflectometry/fitting.py
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 | |
_constraints_applied(factory)
Attach factory's constraints to problems built inside the block.
A no-op when factory is None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factory
|
Optional[Callable]
|
Receives the |
required |
Source code in src/easyreflectometry/_bumps_constraints.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
_constraints_active()
Whether an :func:applied block is active in the current context.
Lets an inner wrapper (MultiFitter routes the raw
easy_science_multi_fitter.fit through the constraints machinery)
detect that an outer block already attached a factory — possibly an
explicit one that must not be overridden by re-resolving the provider.
Source code in src/easyreflectometry/_bumps_constraints.py
101 102 103 104 105 106 107 108 109 | |
_validate_objective(objective)
The zero-variance objective objective names ('auto' is 'hybrid').
Raises:
| Type | Description |
|---|---|
ValueError
|
If it names none. |
Source code in src/easyreflectometry/fit_settings.py
164 165 166 167 168 169 170 171 172 173 174 175 176 | |
requires_finite_bounds(minimizer)
Whether minimizer needs a finite min and max on every free parameter.
Source code in src/easyreflectometry/fit_settings.py
179 180 181 | |
_prepare_fit_arrays(x_vals, y_vals, variances, objective)
Prepare x, y_eff, and weights arrays for fitting based on the objective mode.
For legacy_mask, zero-variance points are removed from all arrays.
For hybrid, valid-variance points use standard WLS while zero-variance
points use Mighell-transformed y and weights.
For mighell, all points use the Mighell transform.
Note: variances here means σ² (the scipp convention), not σ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_vals
|
np.ndarray
|
Independent variable values. |
required |
y_vals
|
np.ndarray
|
Observed dependent variable values. |
required |
variances
|
np.ndarray
|
Variance (σ²) of each observed point. |
required |
objective
|
str
|
One of 'legacy_mask', 'hybrid', 'mighell'. |
required |
Returns:
| Type | Description |
|---|---|
tuple[np.ndarray, np.ndarray, np.ndarray, dict]
|
Tuple of (x_out, y_eff, weights, stats) where stats is a dict with keys 'valid', 'mighell_substituted', 'masked'. |
Source code in src/easyreflectometry/fitting.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
_compute_weighted_chi2(y_obs, y_calc, sigma)
Return weighted chi-square for finite, strictly positive uncertainties.
Source code in src/easyreflectometry/fitting.py
163 164 165 166 167 168 169 | |
_compute_reduced_chi2(chi2, n_points, n_params)
Return reduced chi-square or None when degrees of freedom are not positive.
Source code in src/easyreflectometry/fitting.py
172 173 174 175 176 177 | |
_fit_result_reduced_chi(result, n_points=None)
Return reduced chi-square from either supported FitResults attribute name.
Source code in src/easyreflectometry/fitting.py
180 181 182 183 184 185 186 187 188 189 190 | |
_bind_fit_func(func, unique_name)
Bind a model's fit function to its unique_name for EasyScienceMultiFitter.
EasyScienceMultiFitter calls each fit function positionally as
func(x, *extra_args); the model's interface.fit_func expects its
unique_name as that extra positional argument, so it has to be closed
over here rather than passed through the fitter's call signature.
Source code in src/easyreflectometry/fitting.py
193 194 195 196 197 198 199 200 201 202 203 204 205 | |
_resolution_for_fitted_points(resolution_function, x_vals, y_vals, variances, objective)
The dataset resolution restricted to the points :func:_prepare_fit_arrays keeps.
legacy_mask drops zero-variance points, so the fit evaluates the model
on a subset of x. A merged dataset can hold the same q twice with
different widths; looked up by q alone, the subset would lose which width
belongs to which point (:meth:Pointwise.smearing only keeps per-point
widths when evaluated on exactly its stored q). The widths are therefore
evaluated on the full grid and selected together with the points.
Source code in src/easyreflectometry/fitting.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
_emit_array_prep_warnings(stats, y_vals, label, *, action='fitting', extra='')
Warn about zero-variance handling applied by :func:_prepare_fit_arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stats
|
dict
|
The |
required |
y_vals
|
np.ndarray
|
The original (pre-transform) y values, used for the "all points" count. |
required |
label
|
str
|
Identifies what was fitted/sampled, e.g. |
required |
action
|
str
|
Verb describing the operation, e.g. |
'fitting'
|
extra
|
str
|
Extra sentence(s) appended to the Mighell-related warnings (e.g. a likelihood-validity caveat for MCMC). By default, ''. |
''
|
Source code in src/easyreflectometry/fitting.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
_classical_metrics_for(original, model_curve, result, n_points=None)
The classical (positive-variance-only) and objective-space chi-square of one dataset.
Reduced values are not given per dataset: their degrees of freedom belong
to the pooled fit (see :class:FitRun and the MultiFitter properties).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original
|
dict
|
Dict with keys |
required |
model_curve
|
np.ndarray
|
Model evaluated at the original x values. |
required |
result
|
FitResults
|
The minimizer's result for this dataset/channel. |
required |
n_points
|
int | None
|
Number of points actually fitted. If |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Keys |
Source code in src/easyreflectometry/fitting.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
_free_roots(models)
Free parameters that parameters of models follow, directly or through other
dependencies, but that no model in models owns: a tie to a model left out of
the fit. Leaving them out of the fit would hold them fixed.
Source code in src/easyreflectometry/fitting.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
_curve_ids(data)
The <n> of every Qz_<n> coordinate of a DataGroup, in numeric order.
Curve k is paired with model k (or dataset k) by this order, so it
follows the key numbers rather than the order the keys were inserted in,
and Qz_10 comes after Qz_2. Suffixes that are not numbers keep
their insertion order, after the numbered ones.
Source code in src/easyreflectometry/fitting.py
360 361 362 363 364 365 366 367 368 369 | |
_ratio(numerator, denominator)
Source code in src/easyreflectometry/fitting.py
464 465 | |
_flatten_list(this_list)
Flatten nested lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
this_list
|
list
|
List to be flattened. |
required |
Returns:
| Type | Description |
|---|---|
list
|
Flattened list. |
Source code in src/easyreflectometry/fitting.py
1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 | |