nook.quantities¶
Parsing of ENSDF-flavoured physical quantities.
This is the part of the package that actually earns its keep: ENSDF encodes uncertainties in a significant-digit convention, spin-parity as a small grammar of alternatives and limits, and half-lives either as times or as level widths. Everything here is pure, stdlib-only and unit-testable.
- nook.quantities.HBAR_LN2_MEV_S = 4.5623797e-22¶
hbar * ln(2) in MeV.s – converts a level width Gamma to a half-life.
- class nook.quantities.Uncertain(value, plus=None, minus=None, operator=None, raw='')[source]¶
Bases:
objectA value with an (optionally asymmetric) uncertainty.
operatorcarries ENSDF limit flags such asAP(approximately),GT/LT(greater/less than). When an operator is present the uncertainty is usually absent andvalueshould be read as a bound.- to_ufloat()[source]¶
Convert to an
uncertainties.ufloat(optional dependency).Use this when you want that package’s correlation tracking. It is lossy in both directions ENSDF cares about:
ufloatcarries a single scalar standard deviation, so asymmetric errors are symmetrised and limit operators are dropped. Both are reported.
- nook.quantities.parse_value_with_uncertainty(value_text, unc_text='')[source]¶
Parse an ENSDF value/uncertainty pair.
The uncertainty is expressed in units of the last significant digit of the value, so
("12.1", "11")means12.1 +/- 1.1. Asymmetric uncertainties are written"+5-3". Leading operators may sit in either field.
- nook.quantities.multiply(a, b, strict=False)[source]¶
Product of two values, each error branch propagated independently.
Relative errors add in quadrature per side, which assumes independence – see
DecayScheme.total_feeding()for the correlated case.
- nook.quantities.divide(a, b, strict=False)[source]¶
Quotient of two values, with the denominator’s error branches swapped.
- nook.quantities.add(*terms, strict=False)[source]¶
Sum of independent values, each error branch in quadrature.
Independence is assumed. Summing quantities that share a common scale factor – every intensity in one decay dataset shares
NRandBR– violates that; sum the unscaled values and apply the factor once.
- class nook.quantities.JPi(two_j, parity=None)[source]¶
Bases:
objectA single spin-parity assignment.
Spin is stored as
two_jso that half-integer values stay exact.parityis+1,-1orNonewhen unassigned.
- class nook.quantities.SpinParity(candidates=(), excluded=(), tentative=False, assumed=False, constraint=None, natural_parity=None, raw='')[source]¶
Bases:
objectAn ENSDF
Jfield (manual V.20) – a small language, not a number.Two traps, both silent when got wrong:
a parity attaches only where written, except after a closing parenthesis, which covers the group:
(3,4)-is 3- or 4-, but1,2+is “J=1 with unknown parity, or 2+”;NOTinverts the statement, so those values go toexcludedand must never be reported as the assignment.
- allows(two_j, parity=None)[source]¶
Whether the field permits this spin-parity.
Honours
NOTexclusions andNATURAL/UNNATURALparity, neither of which appear incandidates.
- nook.quantities.parse_spin_parity(text)[source]¶
Parse an ENSDF
Jfield into aSpinParity.A parity is attached to a value only where the file attaches it – there is no inheritance across a comma.
1,2+is “J=1 with unknown parity, or 2+”, not “1+ or 2+”. The one exception is a parity written after a closing parenthesis, which the manual defines as applying to the group.