Skip to content

Accept explicit distance grids in make_spectral_grid - #869

Open
christinawlindberg wants to merge 3 commits into
BEAST-Fitting:masterfrom
christinawlindberg:explicit-distance-grid
Open

christinawlindberg wants to merge 3 commits into
BEAST-Fitting:masterfrom
christinawlindberg:explicit-distance-grid

Conversation

@christinawlindberg

Copy link
Copy Markdown
Contributor

Closes #868

What this does

Allows distance to be given as an explicit list of more than three values,
which is then used directly (sorted) as the distance grid. This enables
non-uniform, variable-resolution distance sampling — for example a grid whose
density follows the expected line-of-sight distribution of a galaxy.

Backward compatibility

Unchanged for every currently valid input:

input behaviour
60000 (scalar) single distance, as before
[min, max, step] (3 values) uniform np.arange grid, as before
>3 values new — used as the explicit grid, sorted
2 values ValueError, as before (message expanded)

A three-element list is still always read as [min, max, step], so an explicit
grid of exactly three distances cannot be expressed. That ambiguity is inherent
in the existing API; it is called out in the docstring and the docs rather than
resolved, to avoid changing what existing settings files mean.

Also included

  • make_spectral_grid docstring updated for the new form
  • docs/beast_setup.rst entry for distances updated to match

Context

Came out of building a shared physics-model grid for two SMC fields, where a
Gaussian-density distance grid gave the same effective resolution in 47 planes
instead of 66.

christinawlindberg and others added 2 commits August 27, 2026 13:19
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 <noreply@anthropic.com>
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].
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.59%. Comparing base (b847aae) to head (26d179c).

Files with missing lines Patch % Lines
beast/physicsmodel/model_grid.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #869      +/-   ##
==========================================
- Coverage   38.60%   38.59%   -0.01%     
==========================================
  Files         110      110              
  Lines       10615    10617       +2     
==========================================
  Hits         4098     4098              
- Misses       6517     6519       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@karllark karllark added the stars label Sep 15, 2026
@karllark

Copy link
Copy Markdown
Member

Can you please update the docs as appropriate for this change?

@christinawlindberg

Copy link
Copy Markdown
Contributor Author

Docs should already be updated in ‎docs/beast_setup.rst‎

  • 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].

@karllark

Copy link
Copy Markdown
Member

Sorry about that. Must have missed that you'd updated the docs.

@karllark

Copy link
Copy Markdown
Member

One other question. Will having more than 3 entries in the distance parameter run through the beast settings verify step? Checking you have confirmed that this works.

distances was never checked by verify_input_format: it was absent from
parameters_names, so no format or range validation ran on it at all.

Add check_distance, which accepts the three forms make_spectral_grid
parses -- a single value, [min, max, step], and an explicit list of more
than three values -- and rejects the cases that cannot be built: a
two-element list, duplicate values in an explicit grid, negative
distances, and non-numeric entries. Three values remain [min, max, step],
matching make_spectral_grid.

distances is routed through its own branch rather than list_float_grid so
that a fourth element is read as a grid point and not as the log/lin
spacing flag that avs, rvs and fAs use. Integers are accepted alongside
floats, since [60] and [50, 70, 5] run correctly today and a stricter
check would reject working settings files. A missing or undefined
distances warns through the existing path rather than raising.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make_spectral_grid cannot take an explicit (non-uniform) distance grid

2 participants