Changelog¶
All notable changes to spectracles are documented in this file.
The format follows Keep a Changelog, and this project adheres to Semantic Versioning.
[1.0.0] - 2026-11-03¶
Added¶
- Priors on parameters (
spectracles.priors:StdNormal,Normal,LogNormal,Laplace,Uniform). Give one withParameter(prior=...), or set them afterwards by glob withmodel.with_priors({...});get_priors()lists them and model summaries have a Prior column.FourierGPcoefficients have a standard-normal prior by default. - A latent space, likelihoods and a posterior (
spectracles.inference:LatentSpace,Likelihood,GaussianLikelihood,Posterior). Every free parameter gets a standard-normal latent, so one model gives the same posterior, in the same coordinates, to MGVI/geoVI (NIFTy.re), NUTS (BlackJAX) and MAP (optax).GaussianLikelihooddrops masked, non-finite and zero-weight data points. spectracles.nifty:to_nifty(posterior)andstages(...)for staged variational inference with NIFTy.re. NIFTy is an optional extra:pip install "spectracles[nifty]".- Results from any backend's samples:
Posterior.summary(with optional true values),draws(returningDrawsof parameter values, orModelDrawswithto="model"to evaluate any part of the model at every sample),map_samples,to_modelandto_params.Drawssummaries reduce over the sample axes only (axis=picks some;reduce(fn)takes any statistic). Posterior.fixandLatentSpace.fix: hold chosen parameters at given values for a whole fit.ShareModule.for_evaluation(): an evaluable copy of a model, with shared values filled in.ShareModule.setaccepts a dict from path to value;build_modelaccepts an instance as well as a class.- Physical units:
Domain(centre, extent)(orDomain.from_points(x, y)) describes the region the data cover, in the data's own units.FourierGPandFourierBasistakedomain=,padding=(0.15 of the extent on each side by default) andnufft_tol=. With a domain, length scales are in the coordinates' units. Positions outside the periodic box raise an error. Domain.grid((n, m), padding=0.0): a regular grid of points over the domain (or over a GP's whole box withpadding=gp.padding), e.g. to map a field after fitting.FourierGP(kernel, domain=...)chooses its own modes and padding for a tolerance (tol=1e-3by default) over the length-scale prior's 1% to 99% quantiles (orlength_scale=, orquantiles=). The choice is recorded ingp.design.n_modes=andpadding=can still be given by hand.spectracles.discretisation:discretisation_error(the truncation and aliasing errors of aFourierGP, or what they would be with other settings; an array of length scales gives a curve),required_modes,required_padding,realised_covariance,report(everyFourierGPin a model, latent space or posterior, optionally across samples) andplot_discretisation.- Kernels:
spectral_densityandcovariance, the continuous forms of the built-in kernels. - Fields:
FourierGP(..., mean=Parameter(...))adds a constant, andlink="identity" | "exp" | "softplus"(withlower=) transforms the field, e.g. for a positive line flux. With a mean, the GP's own k = 0 mode is dropped and the mean alone sets the field's average over the box. FieldFromRatio(a base field times 10 to the power of a log-ratio field) andFieldPlusScatter(a field plus independent scatter), exported fromspectraclesand built onmean=andlink=. The experimentallvm_modelskeeps its own versions.- Clear errors where mistakes are common: wrong
dims,n_modesthat aren't two odd integers, aPriorpassed positionally, wrong-sized per-spaxel, per-IFU or per-tile values (previously clamped silently), and a model passed toPosteriorasforward. - Documentation: Building models, Priors and inference, How it works, Geometry and discretisation and LVM data guides; a worked inference example; a roadmap; this changelog and a contributing guide. The code on the guide pages is run by the tests.
- Python 3.13 and 3.14 are tested in CI and listed in the package classifiers.
Changed¶
FourierGPtakes the kernel first:FourierGP(kernel, n_modes=..., ...). The oldFourierGP(n_modes, kernel)still works, with aDeprecationWarning.nufft_tol=onFourierGPandFourierBasisreplaces the module-levelFINUFFT_KWDS(the default accuracy, 1e-10, is unchanged).- A parameter with a prior and no initial value starts at the prior's median (it used to start at 0, possibly outside the prior's support).
SpatialDatais a base class thatSpatialDataGenericandSpatialDataLVMsubclass, so you can define your own spatial data classes. It used to be a type alias.spectracles.lvm_modelsis marked experimental: it is not covered by the API stability promise and is not type-checked.MultiFourierGPraisesNotImplementedErroruntil 1.1. Use oneFourierGPper field.- A
Parameterinside a list, tuple or dict raises a clearTypeError(support is planned for 1.1). - Models saved with
save_modelby earlier versions don't load correctly (models have new fields). - Summary tables wrap long parameter paths instead of truncating them.
- The package passes pyright with no errors (excluding
lvm_models).
Deprecated¶
FourierGP(n_modes, kernel): useFourierGP(kernel, n_modes=n_modes), or give adomainand leave outn_modes.zeromode=andFourierGP.zeromode: usemean=and.mean. Note that with a kernel that has a k = 0 mode (e.g. the Matérn kernels), azeromodenow drops that mode, asmean=does; it used to add a constant on top of it.ShareModule.get_locked_model(): usefor_evaluation(). It still works and warns.
Removed¶
- The module-level
FINUFFT_KWDSsetting (seenufft_tol=above).
Fixed¶
- Path patterns with
**inbuild_schedulecould match the wrong parameter:"gp.**.ls"matched"gp2.k.ls". Only patterns that matched wrongly are affected. save_modelworks on Python 3.15 for models whose classes are defined in a script.
[0.7.0] - 2026-10-26¶
Added¶
LogLogLinearkernel (inspectracles.model.kernels): a power spectrum that is linear in log-log space, with no k = 0 mode.FourierGP(..., zeromode=...): a constant added to the field, for kernels with no k = 0 mode.
Changed¶
- Requires Python 3.11 or later (3.10 is no longer tested).
- The documentation is deployed when a version is tagged, refreshed for changes since 0.5.5, and docstring examples render as code.
Fixed¶
- The zero mode of a Fourier GP had twice its intended prior variance, so the field's spatial mean varied more than the kernel says (≈0.3% of the variance at a length scale of 0.08 box units, ≈5% at 0.3). This changes results for every
FourierGP, and slightly forFourierBasis.
[0.6.5] - 2026-03-20¶
Added¶
- Experimental LVM models: fields that sum two fields or scale one, a blended-doublet line ratio model and an [O II] model.
[0.6.4] - 2026-03-11¶
Added¶
- Experimental LVM models:
LVMModelSingleusing the new field types; kinematics that need not be shared; line ratio model changes.
[0.6.3] - 2026-02-26¶
Added¶
WindowConstant: a constant confined to a wavelength window.PerTilePinned: a per-tile value with one tile held fixed, to remove a degeneracy between tiles.- Experimental LVM line ratio model: a separate continuum per line, a systematic velocity per line and wavelength calibration.
Fixed¶
FourierGP.prior_logpdfhad its log normalisation off by a factor of 2.- The log10-ratio convenience function in the LVM ratio model was missing its mean.
[0.6.2] - 2026-02-20¶
Added¶
- A custom loss-change criterion in the schedule builder.
[0.6.1] - 2026-02-03¶
Fixed¶
- Printing a model with shared
Knownparameters no longer fails, and the message about locked models is clearer. - Spacing and newlines in printed output.
[0.6.0] - 2026-02-02¶
Added¶
Known, for values that are never optimised.FourierBasis(unregularised sines and cosines) andMultiFourierGP.- LVM models (
spectracles.lvm_models): emission lines (EmissionLine,LinkedEmissionLine), field types built onFourierGP, a DRP nuisance model and a line ratio model. - The parameter-centric schedule builder (
build_schedule,fixed_in,free_in, ...). - Model inspection on
ShareModule:parameter_summary,get_parameter_paths,get_sharing_summary,get_shared_components,validate_sharing,fix_all/free_all,print_model_treeandplot_model_graphwith sharing levels, and Rich-based printing. - Python 3.10 support.
- Documentation with MkDocs Material and an API reference; tests in CI.
Changed¶
- Breaking:
ParameterandConstrainedParametertake the initial value first, thendims. OptimiserScheduleUnsaferenamed toManagedOptimiserSchedule.- networkx requirement relaxed to 3.4.
[0.5.5] - 2025-11-19¶
Changed¶
- Requires Python 3.10 or later (was 3.13).
[0.5.4] - 2025-08-14¶
Changed¶
- Model graphs draw links between components at the same level as curved arrows; old graphing code removed.
Fixed¶
- The JAX requirement is a minimum (
jax>=0.5.3) rather than pinned.
[0.5.3] - 2025-08-13¶
Changed¶
- Relaxed the JAX requirement.
[0.5.2] - 2025-08-13¶
Changed¶
- JAX is required without the
[cpu]extra, so you can install whichever JAX build you need. - Installation instructions, including the FFTW requirement for jax-finufft.
[0.5.1] - 2025-08-13¶
Changed¶
- Packaging for PyPI.
[0.5.0] - 2025-08-13¶
Initial release.