Skip to content

Add Offner et al. 2023 multiplicity models (unresolved + resolved) - #160

Open
jluastro wants to merge 37 commits into
synphot_updatefrom
cursor/offner-2023-multiplicity-ad2c
Open

Add Offner et al. 2023 multiplicity models (unresolved + resolved)#160
jluastro wants to merge 37 commits into
synphot_updatefrom
cursor/offner-2023-multiplicity-ad2c

Conversation

@jluastro

@jluastro jluastro commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Adds opt-in Offner et al. 2023 (PPVII) multiplicity for SPISEA. Default cluster generation is unchanged (MultiplicityUnresolved / MultiplicityResolvedDK). There is no MultiplicityOffner2023 alias: pick unresolved or resolved explicitly.

Models

  • MultiplicityUnresolvedOffner2023: companions-only (Table 1 logistic MF/CSF, error-weighted logistic γ(M)). No orbital API.
  • MultiplicityResolvedOffner2023: same plus Table 2 μ(a) (smooth broken power law) and σ(log10 a) (2-param logistic). Owns log_a_mean, a_mean, sigma_log_a, and the a/σ kwargs. Does not subclass MultiplicityResolvedDK.
  • Generic bases: MultiplicityLogistic (MF/CSF and γ(M) logistics) and MultiplicityPiecewisePowerLaw.

API

  • Cluster q path is calc_multidraw_companion_massesdraw_q(mass, rng=None, n_comp=1).
  • Deprecated random_q is only on the v2.5 classes. Offner random_q raises TypeError.
  • Unresolved Offner has no orbital methods. Resolved Offner owns log_a_mean / a_mean / sigma_log_a.
  • synthetic.py treats a multiplicity object as resolved if it implements orbital draws (Offner resolved is not a MultiplicityResolvedDK subclass).

Tests

  • test_offner_bd_q_shallower_than_v25 checks Offner vs v2.5 BD γ and mean q (no source-grep / inspect guards).
  • test_generate_cluster_offner2023 requires at least 5 BD companion q values (seed 7, M_cl=2e3) and mean(q_bd) > 0.5.
  • pytest --noconftest spisea/tests/test_multiplicity.py -k "not test_resolvedmult".
Open in Web Open in Cursor 

Introduce MultiplicityPiecewisePowerLaw plus unresolved/resolved Offner
2023 classes fitted to Table 1 MF/CF (including brown dwarfs). Companion
mass and separation draws now live on the multiplicity object; Lu+2013
defaults are unchanged.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
@jluastro
jluastro marked this pull request as ready for review August 13, 2026 16:36
cursoragent and others added 15 commits August 13, 2026 16:38
calc_multi now only delegates to the multiplicity object. random_q is
mass-aware so Offner γ_trunc applies to BD primaries instead of the
hardcoded Fontanive 6.1. random_companion_count owns the BD binaries-only
cap. synthetic.py duck-types resolved orbits on log_semimajoraxis,
random_e, and random_keplarian_parameters. Docs and IMF tests updated.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Replace the discontinuous 8-segment two-point Table 1 fit with a
3-segment broken power law continuous at 0.08 and 1.5 Msun. Add a
two-panel MF vs mass figure (Lu+2013 vs Offner vs Table 1) to the docs
and PR.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Offner et al. 2023 now subclasses MultiplicityLogistic instead of the
piecewise power law. MF/CSF use equal-weight Table 1 logistic coefficients;
the generic piecewise class remains for tests and other surveys.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Two-panel BD-zoom plus full-range plots of Table 1 gamma_trunc and
characteristic a, plus a mean-q companion panel. Curves come from the
multiplicity objects so they cannot drift from the code.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Two-panel plot of Table 2 separation scatter versus the Duchene-Kraus
linear-in-log-M fit. Offner holds sigma=0.7 for brown dwarfs; Lu DK
shows the 0.08 Msun blend dip.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Replace Table 1/2 log-mass interpolations with an error-weighted
logistic for gamma, a logcosh smooth broken power law for mu(a),
and a 2-parameter logistic for sigma(log10 a). Resolved draws use
those as loc and scale. MF/CSF logistic and Lu+2013 are unchanged.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Expand docs/multiplicity.rst with formulas for MF/CSF, gamma, mu(a),
and sigma(log a), plus the five Lu+2013 comparison figures. Point
imf.rst and the changelog at the opt-in Offner model.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
The comparison plots and docs describe Offner 2023 vs the default
MultiplicityUnresolved / MultiplicityResolvedDK that shipped in
SPISEA v2.5. Keep Lu et al. 2013 citations on the original classes.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Filenames, RST figure paths, and plot-script helpers now match the
SPISEA v2.5 comparison baseline.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Updated the documentation for the multiplicity object, clarifying its functions and usage in the IMF. Revised sections on companion evolution and recommended multiplicity classes.
Add Parameters and Returns (types and units) to every new helper,
class, and method in multiplicity.py. Expand modified methods that
already had a Parameters block but omitted units. No math changes.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Private helpers sit after the public classes and MultiplicityOffner2023
alias so Sphinx/source order documents the classes first. Table arrays
that call _offner2023_table1_geom_mass follow that helper. No behavior
change.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Evaluate the logistic and smooth broken power law on positive masses
only. Keep M>0 math unchanged. Tests and docs no longer treat M<=0
as mapping to the low-mass asymptote.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Comment thread docs/figures/plot_mf_offner_vs_spisea2.5.py
Comment thread docs/figures/plot_q_sep_offner_vs_spisea2.5.py
Comment thread docs/figures/sep_offner_vs_spisea2.5.png
Comment thread docs/multiplicity.rst
Comment thread docs/multiplicity.rst Outdated
Comment thread docs/multiplicity.rst Outdated
Comment thread docs/multiplicity.rst Outdated
Comment thread docs/multiplicity.rst Outdated
Comment thread docs/multiplicity.rst Outdated
Comment thread docs/multiplicity.rst Outdated
Comment thread spisea/imf/multiplicity.py Outdated
Comment thread spisea/imf/multiplicity.py Outdated
Comment thread spisea/imf/multiplicity.py Outdated
Comment thread spisea/imf/multiplicity.py
Comment thread spisea/imf/multiplicity.py Outdated
Comment thread spisea/tests/test_imf.py Outdated
Comment thread spisea/tests/test_multiplicity.py Outdated
Comment thread spisea/tests/test_multiplicity.py Outdated
Comment thread spisea/synthetic.py Outdated
cursoragent and others added 8 commits August 19, 2026 19:46
The comparison figure now evaluates the original object: the array
path for the dashed power law and the scalar path for the BD
staircase. Hardcoded 0.44 M**0.51 and 0/8%/16% helpers are gone.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Expose MultiplicityResolvedDK.log_a_mean, a_mean, and sigma_log_a as
the characteristic mean and width already used by log_semimajoraxis,
and generate each comparison PNG from a matching script that calls
the multiplicity objects rather than hardcoded functional forms.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Users must construct MultiplicityUnresolvedOffner2023 or
MultiplicityResolvedOffner2023 explicitly; there is no shorthand.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
docs/multiplicity.rst is now a short wiring intro plus autoclass
and one-line comparison figures. Formulas, coefficients, BD policy,
and Table 1 caveats live on the public multiplicity classes.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Keep docs/multiplicity.rst as a short landing page plus autoclass
and the five comparison figures. List the plot_* scripts used to
regenerate them. Align Piecewise/Logistic Notes with the other
classes.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Drop leftover piecewise-fit helper and Table 1/2 arrays that were
stored on the objects but never read. Keep sep_sig_mass / sep_sig
for the σ comparison plot.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Delete OFFNER2023_* and FONTANIVE2018_BD_Q_POWER module globals.
MultiplicityUnresolved takes bd_q_power=6.1; Offner classes take
the Table 1/2 logistic and smooth-break values as kwargs, stored
on self and used by q_power_at_mass / log_a_mean / sigma_log_a.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
List the Offner shape kwargs with hardcoded defaults on both
unresolved and resolved __init__s. Drop binary_only_mass_max so
companion_max is the only count cap. Add the CSF vs mass comparison
figure from companion_star_fraction on the multiplicity objects.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
@cursor cursor Bot changed the title Add opt-in Offner et al. 2023 multiplicity model (Table 1, including BDs) Add Offner et al. 2023 multiplicity models (unresolved + resolved) Aug 19, 2026
cursoragent and others added 13 commits August 19, 2026 22:44
log_semimajoraxis and random_keplarian_parameters now take rng=None
and default to a new numpy Generator. synthetic.py passes self.rng.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Five tests check that the same default_rng seed reproduces
random_companion_count, draw_n_companions, draw_companion_masses,
log_semimajoraxis, and random_keplarian_parameters.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
…ingUniverseLab/SPISEA into cursor/offner-2023-multiplicity-ad2c
Cluster companion-mass draws go calc_multi → draw_companion_masses
→ draw_q. The v2.5 class keeps the BD/stellar two-draw split;
Offner draws all primaries in one shot. random_q remains as a
deprecated inverse-CDF wrapper.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Deprecated random_q remains only on the v2.5 classes. Offner
overrides it to TypeError and no longer lists q_power on either
__init__. Logistic still receives q_power internally.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Unresolved Offner is companions-only (MF/CSF/q). log_a_mean,
a_mean, sigma_log_a and the a/σ kwargs now live only on
MultiplicityResolvedOffner2023.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
The mean-q check no longer skips when fewer than 5 BD companions
are drawn. Seed 7 with M_cl=2e3 already yields well above that.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Keep the γ and mean-q science checks; rename the test so it
describes the comparison rather than calc_multi string greps.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
Say Offner resolved is not a MultiplicityResolvedDK subclass.
No logic change.

Co-authored-by: Jessica Lu <jlu.astro@berkeley.edu>
…ingUniverseLab/SPISEA into cursor/offner-2023-multiplicity-ad2c
Comment thread docs/multiplicity.rst
and the ``COSMIC`` evolution model.
See the example jupyter notebook `Cluster_w_COSMIC.ipynb <https://github.com/MovingUniverseLab/spisea/blob/main/docs/Cluster_w_COSMIC.ipynb>`_ for an example.
Note that currently COSMIC due to being external evolution is significantly slower than the other evolution options.
Note that currently COSMIC, due to being external evolution is significantly slower (2-10x) than the other evolution options.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point, but it's much worse than this, more like 100x

csf = np.full(len(masses), 3.0)
n_comp = multi.draw_n_companions(masses, csf, mf, rng)
assert np.all(n_comp <= 1)
assert np.all(n_comp >= 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand some of the tests here. For example, why are both of these asserts happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants