measurement
DEFAULT_RESOLUTION_FWHM_PERCENTAGE = 5.0
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 | |
PercentageFwhm
Bases: ResolutionFunction
Source code in src/easyreflectometry/model/resolution_functions.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
__init__(constant=None)
Init function.
Source code in src/easyreflectometry/model/resolution_functions.py
60 61 62 63 64 | |
smearing(q)
Return per-point sigma values from the constant FWHM percentage.
constant is a FWHM percentage of q; it is converted to an
absolute sigma so the smearing() contract is sigma for all types.
Source code in src/easyreflectometry/model/resolution_functions.py
66 67 68 69 70 71 72 73 74 | |
as_dict(skip=None)
As dict.
Source code in src/easyreflectometry/model/resolution_functions.py
76 77 78 79 80 | |
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 | |
is_orso_file(fname)
Whether fname is an ORSO file: text with the ORSO banner line, or HDF5 (.orb).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fname
|
str
|
Path to the file. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when the file starts with the ORSO banner or the HDF5 magic bytes. |
Source code in src/easyreflectometry/orso_utils.py
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 | |
load_data_from_orso_file(fname)
Load data from an ORSO file (.ort text or .orb binary).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fname
|
str
|
Path to the file. |
required |
Returns:
| Type | Description |
|---|---|
sc.DataGroup
|
A scipp DataGroup with data, coords, and attrs. |
Raises:
| Type | Description |
|---|---|
ValueError :
|
If the file cannot be parsed as ORSO. Parse failures are not swallowed here; falling back to plain-text loading is the caller's decision and only valid when the file carries no ORSO banner. |
Source code in src/easyreflectometry/orso_utils.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
load(fname)
Load data from an ORSO file (.ort/.orb) or a plain text file.
The discriminator is the ORSO banner line (or the HDF5 magic for binary files), not the file extension: a file carrying the banner that fails to parse raises instead of being silently re-read as plain text (which would drop the entire header, including polarization).
For a plain text file the columns are read by position in the ORSO order
Qz, R, sR, sQz -- further numeric columns are ignored -- and the error
columns must hold standard deviations, not variances. See
:func:_load_txt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fname
|
Union[TextIO, str]
|
The file to be read. |
required |
Returns:
| Type | Description |
|---|---|
sc.DataGroup
|
The loaded data. |
Source code in src/easyreflectometry/data/measurement.py
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 | |
dataset_from_datagroup(data_group, data_key=None)
Build a DataSet1D from one dataset of a loaded DataGroup.
The ORSO header (when present) is attached to the returned dataset as the
orso_header attribute (a plain dict), so exporters can reuse the
original data_source/reduction provenance.
The measured q-resolution, when the data carry one (positive sQz), is set
as the dataset's resolution_function (see
:func:resolution_from_dataset), so fitting smears the dataset with the
widths it was measured with. Otherwise it stays None and the model's
resolution applies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_group
|
sc.DataGroup
|
A DataGroup as returned by :func: |
required |
data_key
|
Optional[str]
|
The data entry to use (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
DataSet1D
|
The dataset. |
Source code in src/easyreflectometry/data/measurement.py
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 | |
load_as_dataset(fname, data_group=None)
Load data from an ORSO .ort file as a DataSet1D.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fname
|
Union[TextIO, str]
|
The file to be read. |
required |
data_group
|
Optional[sc.DataGroup]
|
Pre-loaded DataGroup for fname (avoids re-parsing the file). By default, None. |
None
|
Returns:
| Type | Description |
|---|---|
DataSet1D
|
The (first) dataset in the file. |
Source code in src/easyreflectometry/data/measurement.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
extract_orso_title(data_group, data_name)
Extract orso title.
Source code in src/easyreflectometry/data/measurement.py
123 124 125 126 127 128 129 130 131 132 133 | |
_load_txt(fname)
Load data from a simple txt file.
Columns are read by position, following the ORSO order: Qz, R, sR, sQz. Any further numeric columns (e.g. wavelength) are ignored -- the whole file is still parsed as numbers before the leading columns are taken, so a trailing text column, or rows of differing width, remain an error.
The error columns are taken to be standard deviations (sigma), matching
the ORSO default, and are squared to obtain the stored variances; a file
carrying variances instead would be mis-scaled. Plain text carries no
convention marker, so this is a requirement on the caller and not something
the loader can check -- unlike an ORSO file, which declares value_is and
whose FWHM errors are converted to sigma on load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fname
|
Union[TextIO, str]
|
The path for the file to be read. |
required |
Source code in src/easyreflectometry/data/measurement.py
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 | |
resolution_from_dataset(dataset)
The measured q-resolution of a dataset, or None when it carries none.
A dataset carries its resolution as the xe column, the variance of
Qz (sQz²) at every point. When any of it is positive a
:class:Pointwise resolution is built from it; an absent, empty, all-zero
or all-NaN column gives None, meaning the model's resolution applies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
DataSet1D
|
The dataset. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Pointwise]
|
The per-point resolution, or |
Source code in src/easyreflectometry/data/measurement.py
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 | |
merge_datasets(datasets, name=None, fill_resolution=None)
Combine several measurements of one contrast into a single dataset.
A contrast is often measured as several curves -- one per incident angle
or wavelength band -- each with its own q-resolution. This concatenates
them, sorted by Qz, into one dataset that keeps every point's own
resolution, so the fit smears each point with the width it was measured
with. Overlapping q ranges are kept as they are: the merged dataset may
hold the same Qz twice with different widths, which
:meth:Pointwise.smearing honours when evaluated at the data points.
Each input contributes the widths of its own resolution_function,
evaluated at its points -- the measured :class:Pointwise set by the
file loaders, or whatever was assigned explicitly -- so merging does not
change the resolution a measurement is fitted with. An input whose
resolution_function is None (the model's resolution applies) has
no widths of its own; its xe column is not consulted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
Sequence[DataSet1D]
|
The measurements to combine; at least one. The model, labels and ORSO header of the first one are kept. |
required |
name
|
Optional[str]
|
Name of the merged dataset. By default the input names joined by ' + '. |
None
|
fill_resolution
|
Optional[ResolutionFunction]
|
Resolution assumed for the points of a dataset that carries no
resolution when others do, so the merged resolution covers every
point. By default the 5% FWHM default resolution. A warning is
emitted in that case. When no dataset carries a resolution, the
merged dataset has none either and |
None
|
Returns:
| Type | Description |
|---|---|
DataSet1D
|
The merged dataset. When any input carried a resolution, its
|
Raises:
| Type | Description |
|---|---|
ValueError
|
No datasets were given. |
Source code in src/easyreflectometry/data/measurement.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 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 | |
merge_datagroups(*data_groups)
Merge multiple DataGroups into a single DataGroup.
Source code in src/easyreflectometry/data/measurement.py
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 | |