vibesketcher.document.measured_patterns¶
Measured powder patterns from simple two-column text files (#207).
Only plain text is read: whitespace-separated XY (.xy, .xye,
.dat, .txt) and comma- or semicolon-separated CSV (.csv). The
x axis must be stated by the caller (two_theta_deg, d_angstrom or
q_inv_angstrom), never guessed from the numbers, and so must the
intensity unit. Vendor and binary formats (Bruker RAW/BRML, PANalytical
XRDML, Rigaku RAS, GSAS, …) are refused with the reason; convert them to
XY with the instrument software, which keeps their licensing out of this
package.
The provenance of every import is kept: the SHA-256 and size of the
original bytes, the file name as given (no directory), the format, the
stated axis, intensity unit and wavelength, instrument fields exactly as
given, and the file’s own comment lines. A third column is read as the
intensity standard uncertainty (esd) when present.
Functions
|
Convert x values between 2theta (degrees), d (angstrom) and Q = 2 pi / d (1/angstrom). |
|
Points and provenance of a measured pattern, or |
|
|
Classes
|
What the caller states about a measured file; nothing is inferred. |
Exceptions
The file or its stated axis cannot be read faithfully. |
- exception vibesketcher.document.measured_patterns.MeasuredPatternRefused[source]¶
Bases:
ValueErrorThe file or its stated axis cannot be read faithfully.
- class vibesketcher.document.measured_patterns.MeasuredSettings(*, axis, intensity_unit='counts', wavelength_angstrom=None, format=None, instrument=<factory>, sample=None)[source]¶
Bases:
BaseModelWhat the caller states about a measured file; nothing is inferred.
- Parameters:
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- intensity_unit: Literal['counts', 'counts_per_second', 'arbitrary']¶
- wavelength_angstrom: float | None¶
Wavelength of the measurement in angstrom, when known (required to convert a 2theta axis to d or Q, and to overlay in 2theta).
- vibesketcher.document.measured_patterns.read_measured(data, filename, settings)[source]¶
Points and provenance of a measured pattern, or
MeasuredPatternRefused.
- vibesketcher.document.measured_patterns.read_measured_file(path, settings)[source]¶
read_measured()for a file on disk (bounded read).- Parameters:
path (str)
settings (MeasuredSettings)
- Return type:
- vibesketcher.document.measured_patterns.convert_axis(values, source, target, wavelength)[source]¶
Convert x values between 2theta (degrees), d (angstrom) and Q = 2 pi / d (1/angstrom).
Bragg’s law
lambda = 2 d sin(theta); a 2theta axis on either side needs the wavelength, and a d or Q beyond the wavelength’s reach is refused.