streamobs.utils module

streamobs.utils module#

Utils for streamobs

streamobs.utils.canonical_survey_bands(surveys, bands)[source]#

Sort (survey, band) pairs to a deterministic canonical order.

Sorting key is (survey.name, band) so any permutation of the same inputs produces identical output. Use this whenever building file paths, column names, or ordered survey/band sequences that must be commutative.

Parameters:
  • surveys (list of Survey) – One Survey per band (may repeat the same instance).

  • bands (sequence of str) – Band name for each survey, parallel to surveys.

Returns:

  • surveys_sorted (list of Survey)

  • bands_sorted (tuple of str)

  • dir_name (str) – Canonical directory name for storage paths, e.g. 'lsst' or 'lsst_roman' (survey names deduplicated, underscore-joined).

  • bands_str (str) – Canonical band string for file names, e.g. 'gr' or 'gF158'.

Examples

>>> canonical_survey_bands([roman, lsst], ['F158', 'g'])
([lsst, roman], ('g', 'F158'), 'lsst_roman', 'gF158')
streamobs.utils.load_catalog(catalog)[source]#

Load a catalog as a pandas.DataFrame.

Parameters:

catalog (pd.DataFrame or str) – A DataFrame (returned as-is) or a path to a parquet or CSV file.

Return type:

pd.DataFrame

Raises:

ValueError – If catalog is neither a DataFrame nor a recognised file path.

streamobs.utils.parse_config(config)[source]#

Parse a yaml formatted file or string into a dict.

Parameters:

config (yaml formatted string or file path)

Return type:

dict