Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions beast/physicsmodel/model_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -226,14 +229,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:
Expand Down
5 changes: 4 additions & 1 deletion docs/beast_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading