From 8d6dc09b7534232e72f8702ad914b5507c49cc55 Mon Sep 17 00:00:00 2001 From: Christina Willecke Lindberg Date: Fri, 10 Jul 2026 16:59:32 -0400 Subject: [PATCH 1/2] Accept explicit >3-value distance lists for non-uniform distance grids Enables variable-resolution distance sampling (e.g. Gaussian-density grids concentrated at the target distance). 3-element lists remain min/max/step for backward compatibility. Co-Authored-By: Claude Fable 5 --- beast/physicsmodel/model_grid.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/beast/physicsmodel/model_grid.py b/beast/physicsmodel/model_grid.py index 22b1980e..75c7ce29 100644 --- a/beast/physicsmodel/model_grid.py +++ b/beast/physicsmodel/model_grid.py @@ -226,14 +226,24 @@ def make_spectral_grid( # Construct the distances array. Turn single value into # 1-element list if single distance is given. + # A list of >3 values is used as an explicit (possibly non-uniform) + # distance grid, e.g. for variable-resolution distance sampling. + # NOTE: an explicit grid of exactly 3 values cannot be expressed + # (3 values are always interpreted as min, max, step) -- pad with a + # duplicate-free 4th value in that case. _distance = np.atleast_1d(distance) if len(_distance) == 3: mindist, maxdist, stepdist = _distance distances = np.arange(mindist, maxdist + stepdist, stepdist) elif len(_distance) == 1: distances = np.array(_distance) + elif len(_distance) > 3: + distances = np.sort(np.array(_distance, dtype=float)) else: - raise ValueError("distance needs to be (min, max, step) or single number") + raise ValueError( + "distance needs to be (min, max, step), a single number, " + "or an explicit list of >3 values" + ) # calculate the distances in pc if distance_unit == units.mag: From 26d179c1b280d7d25577a231c74b14e1f39b82d7 Mon Sep 17 00:00:00 2001 From: Christina Willecke Lindberg Date: Thu, 27 Aug 2026 13:19:52 -0400 Subject: [PATCH 2/2] Document explicit distance grids Update the make_spectral_grid docstring and the beast_setup docs to describe the explicit >3-value distance list, and note that a three-element list is always read as [min, max, step]. --- beast/physicsmodel/model_grid.py | 5 ++++- docs/beast_setup.rst | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/beast/physicsmodel/model_grid.py b/beast/physicsmodel/model_grid.py index 75c7ce29..9a03e66f 100644 --- a/beast/physicsmodel/model_grid.py +++ b/beast/physicsmodel/model_grid.py @@ -165,7 +165,10 @@ def make_spectral_grid( distance: float or list of float distances at which models should be shifted, specified as a - single number or as [min, max, step] + single number, as [min, max, step], or as an explicit list of + more than three values giving a (possibly non-uniform) grid. + An explicit grid of exactly three values cannot be expressed, + since three values are always read as [min, max, step]. 0 means absolute magnitude. diff --git a/docs/beast_setup.rst b/docs/beast_setup.rst index ee26bddb..eea02146 100644 --- a/docs/beast_setup.rst +++ b/docs/beast_setup.rst @@ -51,7 +51,10 @@ General Parameters * ``n_subgrid``: number of sub-grids to use (1 means no subgrids), useful for when the physics model grid is too large to read into memory. * ``velocity`` : heliocentric velocity of a galaxy (e.g., -300 km/s for M31). -* ``distances``: distance grid range parameters. ``[min, max, step]``, or ``[fixed number]``. +* ``distances``: distance grid range parameters. ``[min, max, step]``, ``[fixed number]``, + or an explicit list of more than three values for a non-uniform grid (e.g. sampling + concentrated near the target distance). A list of exactly three values is always + interpreted as ``[min, max, step]``. * ``distance_unit``: specify magnitude (``units.mag``) or a length unit. * ``distance_prior_model``: specify a prior for distance parameter.