streamobs.model module#

Models for simulating streams.

class streamobs.model.BackgroundModel(config, **kwargs)[source]#

Bases: StreamModel

Background model.

Methods

complete_catalog(catalog[, columns_to_add, ...])

Complete only the requested columns in a catalog.

sample(size)

Sample stream stars and derived quantities.

class streamobs.model.ConfigurableModel(config, **kwargs)[source]#

Bases: object

Baseclass for models built from configs.

Methods

sample

sample(size)[source]#
class streamobs.model.DensityModel(config, **kwargs)[source]#

Bases: ConfigurableModel

Density along the stream; samples phi1 positions.

Methods

sample(size)

Draw phi1 samples.

sample(size)[source]#

Draw phi1 samples.

Parameters:

size (int) – Number of samples.

Returns:

Sampled phi1 values.

Return type:

numpy.ndarray

class streamobs.model.DistanceModel(config, **kwargs)[source]#

Bases: ConfigurableModel

Methods

sample

class streamobs.model.IsochroneModel(config, **kwargs)[source]#

Bases: ConfigurableModel

Isochrone wrapper using ugali for CMD sampling.

Methods

create_isochrone(config)

Construct the underlying ugali isochrone from configuration.

sample(nstars, distance_modulus, **kwargs)

Simulate magnitudes in g and r bands.

create_isochrone(config)[source]#

Construct the underlying ugali isochrone from configuration.

Parameters:

config (dict) – Isochrone factory configuration.

sample(nstars, distance_modulus, **kwargs)[source]#

Simulate magnitudes in g and r bands.

Parameters:
  • nstars (int) – Number of stars to simulate.

  • distance_modulus (float or array-like) – Distance modulus per star (broadcast if scalar).

Returns:

(mag_g, mag_r) arrays.

Return type:

tuple of numpy.ndarray

class streamobs.model.SplineStreamModel(config, **kwargs)[source]#

Bases: StreamModel

Spline-based stream model with linear-density component.

Methods

complete_catalog(catalog[, columns_to_add, ...])

Complete only the requested columns in a catalog.

sample(size)

Sample stream stars and derived quantities.

class streamobs.model.StreamModel(config, **kwargs)[source]#

Bases: ConfigurableModel

High-level object for the various components of the stream model.

Methods

complete_catalog(catalog[, columns_to_add, ...])

Complete only the requested columns in a catalog.

sample(size)

Sample stream stars and derived quantities.

complete_catalog(catalog, columns_to_add=None, size=None, inplace=False, save_path=None, verbose=True)[source]#

Complete only the requested columns in a catalog.

This method takes an input catalog (or a desired size when no catalog is provided) and fills in only the requested stream-model columns while preserving pre-existing non-null values. Columns are generated using the configured sub-models (density, track, distance modulus, isochrone, velocity) and only if those capabilities are available.

Parameters:
  • catalog (pandas.DataFrame or str or dict or None) – Input catalog. If a string, it is interpreted as a CSV filepath to read. If a dict, it will be converted to a DataFrame. If None, size must be provided to create an empty frame of that length.

  • columns_to_add (sequence of str or None, optional) – The columns to ensure in the output. Valid entries are {‘phi1’,’phi2’,’dist’,’mag_g’,’mag_r’,’mu1’,’mu2’,’rv’}. If None, all valid columns supported by the configured model are considered.

  • size (int or None, optional) – Required when catalog is None or an empty table; ignored otherwise.

  • inplace (bool, default False) – If True and a DataFrame or CSV path is provided, modify that object in place (for CSV, overwrite the input file).

  • save_path (str or None, optional) – If provided, write the completed catalog to this CSV path.

  • verbose (bool, default True) – If True, print progress/status messages.

Returns:

The completed catalog. If inplace is True and a DataFrame was provided, the same object is returned after modification.

Return type:

pandas.DataFrame

Raises:

ValueError – If size is required but not provided, or when dependencies are missing (e.g., requesting ‘phi2’ without available ‘phi1’).

Notes

  • Dependencies: ‘phi2’ and ‘dist’ require ‘phi1’. Magnitudes require ‘dist’ and an isochrone model. Velocities require ‘phi1’ and a velocity model.

  • Existing non-null values are preserved; only missing rows are filled, except for magnitudes and velocities where the method intentionally overwrites the whole columns to keep internal consistency (e.g., colors and kinematic coherence across rows).

  • When catalog is a CSV path and inplace is True, the original file is overwritten.

sample(size)[source]#

Sample stream stars and derived quantities.

Parameters:

size (int) – Number of stars to generate.

Returns:

Columns include: phi1, phi2, dist, mu1, mu2, rv, mag_g, mag_r (some may be None if the sub-model is absent).

Return type:

pandas.DataFrame

class streamobs.model.TrackModel(config, **kwargs)[source]#

Bases: ConfigurableModel

Transverse track model; samples phi2 given phi1.

Methods

sample(x)

Sample phi2 at given phi1 positions x.

sample(x)[source]#

Sample phi2 at given phi1 positions x.

Parameters:

x (array-like) – phi1 positions where to sample phi2.

Returns:

Sampled phi2 values.

Return type:

numpy.ndarray

class streamobs.model.VelocityModel(config, **kwargs)[source]#

Bases: ConfigurableModel

Placeholder for velocity model.

Methods

sample(phi1)

Placeholder

sample(phi1)[source]#

Placeholder