Repository navigation
rietx 1.5.0
rietx 1.5.0
The window-into-a-run milestone. A fit used to be opaque until it returned.
Now every fit records itself to disk as it goes, and rietx watch shows you any
of them while they run: the pattern, the parameter trajectory, the event
console. You can stop a run from that page, or open it in the GUI without
disturbing it. Around that sit a structure written back out to the format
another program reads, a measured blank entering as data with its own error
bars, and a set of corrections to numbers the package stated about itself.
Two things change numbers you already have. A project with a fixed
background curve now refines that curve's scale under every shipped plan, and
constant_wavelength_neutron(fwhm_deg=...) seeds a different starting width.
Both are in Upgrading. Everything else in the forward model is
untouched: recording a fit returns a bit-identical Rwp, and the sinθ/λ symbol
rename moved no computed value.
Install
pip install --upgrade rietxWatch a fit while it runs
rietx watchNo arguments. It scans the working directory for runs — .rietx/runs, where
fits now record themselves, and any project's live/ — lists what it finds, and
draws the one you pick. Give it a directory to scan somewhere else, or a
directory that is itself a run to open straight onto it. The page keeps your zoom
across a stage boundary, so you can hold a peak in view while the fit works on
it.
In 1.4.0 this verb served one LiveSession directory that you had to set up
yourself, by passing events=LiveSession("live/") to the fit. That is no longer
necessary, because of the next section.
Two verbs sit on each row. Stop asks a running fit to stop, through the same
cancel token the solver already reads between residual evaluations, so the
in-flight stage is abandoned cleanly and the completed ones are kept. GUI
opens the run's project in rietx gui on a byte-for-byte scratch copy, because
there is no read-only way to open a project and looking should not change one.
rietx watch --read-only # clears both verbsEvery fit records itself
fit, run_stage, refine and refine_sequential now write a run directory
without being asked: the event log, a per-stage snapshot.json, summary.txt,
meta.json, status.json and a held run.lock. A five-stage LaB₆ fit costs
204 kB.
result = ref.fit(data) # records
result = ref.fit(data, telemetry=False) # does notRIETX_TELEMETRY=0 switches it off for a process, telemetry=<path> moves the
root, and a .gitignore of * goes into the root so runs stay out of
git status.
It is on by default because the measurement said so. Three of three subagents
asked to instrument a fit switched telemetry off when it was opt-in, and the
cost is 1–3 % of a fit. Every configuration returns a bit-identical Rwp.
Recording cannot break your fit. Every recorder method latches one-shot on
BaseException, records why in status.json, and warns once per process. A
callback you passed through events= is still yours and still runs outside
every try block, so a monitoring hook that crashes the refinement remains a bug
you get to see.
ref.fit(data, label="Ni foil, 400 °C") # names the run in the listWrite a structure back out
1.4.0 could read a TOPAS .inp or a FullProf .pcr. It could not write one.
Nine new calls close that:
rx.write_topas_inp(structure, "refined.inp")
rx.write_fullprof_pcr(structure, "refined.pcr")
rx.write_gsas_prm(instrument, "refined.prm")A structure carries out exactly what the reader reads back in: the space group,
the six cell parameters, and every atom's coordinates, occupancy and
displacement.
Each parameter's own vary is written as the format's @/! flag, so your
refine flags survive the round trip without a symbol table. The instrument is a
separate file in these formats and has its own writers.
The writers are write_topas_inp, write_fullprof_pcr, write_gsas_exp,
write_gsas_prm, write_gsas2_instprm and write_gsas2_phase_cif; the new
readers are read_gsas_exp, read_gsas2_gpx and read_gsas2_instprm. Each
writer's docstring names what does not carry — for TOPAS that is
extinction, preferred orientation and sample broadening, none of which the
reader builds.
A .prm stating two wavelengths now comes back with both emission lines, the
second weighted by the file's own KRATIO. It used to be refused, on a reason
that turned out to be an artefact of reading the record by splitting on
whitespace.
A measured background, with its own error bars
BackgroundFixedPlusChebyshev held a curve and added it with an implicit
coefficient of exactly 1.0. It now has the other form, the one TOPAS writes as
bkg_file("f.xy", @, s):
bg = BackgroundFixedPlusChebyshev.from_pattern(blank, n_terms=1)scale is a refinable multiplier on the curve, fixed_sigma carries the
curve's own counting statistics into the channel weight as σ² + s²·σ_f², and
fixed_source records where the curve came from.
Free the scale against a low-order polynomial. Measured on a synthetic blank
built at 0.85, one Chebyshev term recovers 0.8378(42) while six recover
0.6479(182), with Rwp falling monotonically across that row. The scale is a
measurement only where the polynomial cannot describe the curve itself.
Smaller changes worth knowing
help.py's Lp entry was wrong and is fixed. It stated a formula 0.508× of
the one the code computes at 2θ = 90° for K = 0.99, with the ratio varying
across the range. Two further entries were corrected in the same pass.sinθ/λissin equations andstolin python. Both renamed signatures
are internal, every call site passes positionally, and every refined number is
bit-identical.- A degenerate cell is refused by name.
d_spacingsraises
DegenerateCellErrorwhere it produced aRuntimeWarningand a silent NaN.
StageResult.n_degenerate_cell_probesand theCELL_DEGENERATE_PROBE
diagnostic count how often a stage reached one. RefinementResult.tick_hklpairs each tick with its reflection, by index.
A result written before this release opens with the mapping empty.- The GUI, the watcher and
rietx compareshare one set of colours and one
theme, which any of the three may set.
Contract versions
capabilities() reports six. One moved: schema_version 0.19 → 0.22, in
three steps — the degenerate-cell probe count, the measured background's fields,
and tick_hkl. Every new field defaults to the state its member was already in,
so no stored document changes meaning. The other five are unchanged:
event_schema_version 2, project_format_version 1.3,
report_thresholds_version 1.5, indexing_thresholds_version 1.3 and
textdoc_format_version 1.
Upgrading
Who has to do something, and what.
-
Your project has a fixed background curve. Every shipped plan preset frees
instrument.background.*, and the curve'sscaleis a parameter of the
background, so that glob now reaches it. Such a project refines one parameter
more than it did and its numbers move. To hold the curve exactly where you set
it, freeinstrument.background.c*instead. This was not made opt-in because
the P-spline'sair_scatterhas always been reached by the same glob, and a
measured background whose scale the shipped plans cannot free would need a
hand-written plan to do the one thing the feature is for. -
Your fixed background curve stops short of your fit range.
interpolate_fixedwas barenp.interp, which clamps to the end values
outside the curve's range with no warning. A blank measured over 0.5–50°
under a specimen scanned to 70° contributed twenty degrees of flat invented
counts and nothing said so. It now raises, naming both ranges and both ways
out: crop the fit withtwo_theta_min/two_theta_max, or supply a curve
that covers it. A curve frombackground.estimateorauto_backgroundis
already on the pattern's own grid and is unaffected. -
You build an instrument with
constant_wavelength_neutron(fwhm_deg=...).
It seededw = (0.5·fwhm)²andx = fwhmtogether, double-counting the
width and climbing with angle: atfwhm_deg=0.3the seeded FWHM was 1.179° at
2θ = 150, which is 3.93× the width you asked for. It now seedsw = fwhm²and
leavesxalone, holding the seeded width within 1.4 % across 20–150°. Your
starting widths move; your converged fit does not, since these terms refine.
To get the old seed back, setwandxon the profile directly. A
fwhm_degabove 1.0° now raises,w's default upper bound being 1.0 and the
seed beingfwhm_deg²; declare a coarser instrument by setting
instrument.profile.wexplicitly, with its own bounds. -
You catch
RuntimeWarningaround a cell that can go degenerate. It is a
crystallography.lattice.DegenerateCellErrornow, which is aValueError.
Inside a refinement you will not see it: the solver-side guard neutralises
such a reach and counts it instead. -
You fit on a shared filesystem, or in someone else's repository. Fits now
leave a run directory behind.RIETX_TELEMETRY=0,telemetry=Falseor
telemetry=<path>each decline it. -
You passed
events=LiveSession(...)to get a live view.LiveSessionno
longer writesfit.html; it writessnapshot.jsonper stage, which is what
rietx watchreads.rietx htmlstill writes a page on demand. A project's
live/now holds one directory per run rather than one session's files.
The measured record
docs/milestones/v1.5.md
carries this milestone's acceptance rows. Unlike every record before it, they
were written after the work shipped rather than at the open, because the
milestone was opened 496 commits behind its own body. The record says so, and
says what that is worth.