Skip to content

MOSFiT v2.1.0

Choose a tag to compare

@guillochon guillochon released this 23 Sep 16:39
· 27 commits to master since this release
72830f9

A feature release. MOSFiT can now act as a source model for external
light-curve simulators such as LightCurveLynx:
it reports a rest-frame SED and leaves cadence, noise, redshift and dust to the
simulator. Existing fits give the same results as 2.0.1.

Added

Rest-frame SED output: --lynx (#252)

Normally MOSFiT takes a model all the way to observed photometry: it redshifts
the SED, reddens it, integrates it through bandpasses and compares against data.
--lynx stops before any of that and reports flux density in nJy at 10 pc,
in the rest frame, on a wavelength grid you choose:

mosfit -m slsn --lynx --lynx-wavelengths 1000 25000 100 -N 50

Redshift, luminosity distance, explosion time and extinction are pinned so that
the calling simulator owns them and nothing is applied twice. Phases are days
since explosion. Output goes to products/lynx_seds.h5, a flat
(realization, phase, wavelength) block with the grids, units and the unit-cube
coordinates behind each realization, and to products/lynx_manifest.json.

For calling MOSFiT once per sample rather than through the CLI, use
mosfit.lynx.LynxSource:

from mosfit.lynx import LynxSource

source = LynxSource(model='slsn', phases=phases, wavelengths=wavelengths)
sed = source.compute_sed(parameters={'mejecta': 5.0, 'vejecta': 1.0e4})  # (T, N), nJy

Parameters can be physical values or unit-cube fractions. Names are MOSFiT's
own and case sensitive (Pspin, Bfield, …).

Alongside it:

  • Model.parameter_manifest() lists every parameter's prior range, units,
    log flag, and fixed or free status, plus its position in the walker vector.
    An external sampler can use it to map its own draws onto MOSFiT's unit cube.
  • Model.minwave() / maxwave() / minphase() / maxphase() report
    where a model is defined, so a caller knows when to extrapolate.

Units and the 10 pc convention are cross-checked against MOSFiT's own
photometry: the AB magnitude derived from the rest-frame SED matches the absolute
magnitude the normal path reports to about 0.01 mag.

A lightweight lynx install

The lynx dependency group in pyproject.toml installs only what the
rest-frame SED path needs. It leaves out dynesty, numba and llvmlite. To
use it, run these from a source checkout:

uv pip install --no-deps -e .
uv pip install --group lynx

The tde model still needs numba for its viscous transform. A CI job
installs exactly this set and runs --lynx against it. See the
installation docs
for details.

Changed

  • MOSFiT no longer writes a modules/ directory into your working
    directory.
    Building any photometric model used to create
    ./modules/observables/filters. Filters downloaded from SVO are now cached
    under $MOSFIT_CACHE_DIR/filters, or ~/.mosfit/filters if that isn't set.
    The launch-time copy now scaffolds only models/ and jupyter/. A
    ./modules/ directory you create yourself is still picked up for custom
    modules and filterrules.json. MOSFiT just doesn't create it anymore.
  • Lighter imports. Submodules are imported on first access, and the fitter
    imports its samplers only once it has chosen one. import mosfit.lynx pulls
    in neither the plotting stack nor the sampling stack. The Viscous
    transform's numba kernels load only when that transform runs.
  • --lynx defaults to the ensembler when no sampler is given, because
    rest-frame SEDs are prior draws with no likelihood to nest against. An
    explicit -D still takes precedence.

Full changelog: v2.0.1...v2.1.0