Skip to content

cosmotron_mcp.tools.catalogue

inspect_catalogue

inspect_catalogue(fits_path: str) -> dict

Inspect a catalogue file and return metadata without loading full arrays.

Supports FITS, HDF5 (.h5, .hdf5), CSV, and ASCII formats.

Parameters:

Name Type Description Default
fits_path str

Path to the catalogue file.

required

Returns:

Type Description
dict

A summary dict (columns, row count, format) suitable for passing to

dict

an LLM as context.

Source code in cosmotron_mcp/server.py
@mcp.tool()
@sync_budget_guard
def inspect_catalogue(fits_path: str) -> dict:
    """Inspect a catalogue file and return metadata without loading full arrays.

    Supports FITS, HDF5 (.h5, .hdf5), CSV, and ASCII formats.

    Args:
        fits_path: Path to the catalogue file.

    Returns:
        A summary dict (columns, row count, format) suitable for passing to
        an LLM as context.
    """
    return _inspect_catalogue(fits_path)

write_standardised_catalogue

write_standardised_catalogue(input_path: str, output_path: str, ra_col: str, dec_col: str, z_col: str | None = None, weight_col: str | None = None, z_min: float | None = None, z_max: float | None = None, e1_col: str | None = None, e2_col: str | None = None) -> dict

Read a raw catalogue via memmap, normalise, write standardised FITS.

PREFER ingest_to_session@data_ingestor calls ONLY that; this is the low-level primitive it's built on, for scripts/CLI use.

Memory-efficient: in-place normalisation, BinTableHDU write (no Table copy). For a shear catalogue pass BOTH e1_col and e2_col — the output gains E1/E2 columns and the stats include sigma_e_measured (Heymans+2012).

Parameters:

Name Type Description Default
input_path str

Path to the raw catalogue file.

required
output_path str

Destination standardised FITS path.

required
ra_col str

Right-ascension column name in the raw catalogue.

required
dec_col str

Declination column name in the raw catalogue.

required
z_col str | None

Redshift column name; omit if the catalogue has none.

None
weight_col str | None

Weight column name; omit to fill weight=1.

None
z_min float | None

Optional inclusive-lower redshift bound to slice on.

None
z_max float | None

Optional exclusive-upper redshift bound to slice on.

None
e1_col str | None

First shear-ellipticity column; pass together with e2_col for a shear catalogue.

None
e2_col str | None

Second shear-ellipticity column; pass together with e1_col for a shear catalogue.

None

Returns:

Type Description
dict

dict with n_objects, z_min, z_max, z_median,

dict

weight_sum, weight_sq_sum, ra_range, dec_range (plus

dict

sigma_e_measured for shear).

Source code in cosmotron_mcp/server.py
@mcp.tool()
@sync_budget_guard
def write_standardised_catalogue(
    input_path: str,
    output_path: str,
    ra_col: str,
    dec_col: str,
    z_col: str | None = None,
    weight_col: str | None = None,
    z_min: float | None = None,
    z_max: float | None = None,
    e1_col: str | None = None,
    e2_col: str | None = None,
) -> dict:
    """Read a raw catalogue via memmap, normalise, write standardised FITS.

    PREFER `ingest_to_session` — `@data_ingestor` calls ONLY that; this is
    the low-level primitive it's built on, for scripts/CLI use.

    Memory-efficient: in-place normalisation, BinTableHDU write (no Table copy).
    For a shear catalogue pass BOTH e1_col and e2_col — the output gains E1/E2
    columns and the stats include sigma_e_measured (Heymans+2012).

    Args:
        input_path: Path to the raw catalogue file.
        output_path: Destination standardised FITS path.
        ra_col: Right-ascension column name in the raw catalogue.
        dec_col: Declination column name in the raw catalogue.
        z_col: Redshift column name; omit if the catalogue has none.
        weight_col: Weight column name; omit to fill weight=1.
        z_min: Optional inclusive-lower redshift bound to slice on.
        z_max: Optional exclusive-upper redshift bound to slice on.
        e1_col: First shear-ellipticity column; pass together with
            `e2_col` for a shear catalogue.
        e2_col: Second shear-ellipticity column; pass together with
            `e1_col` for a shear catalogue.

    Returns:
        ``dict`` with ``n_objects``, ``z_min``, ``z_max``, ``z_median``,
        ``weight_sum``, ``weight_sq_sum``, ``ra_range``, ``dec_range`` (plus
        ``sigma_e_measured`` for shear).
    """
    return _write_standardised_catalogue(
        input_path,
        output_path,
        ra_col,
        dec_col,
        z_col=z_col,
        weight_col=weight_col,
        z_min=z_min,
        z_max=z_max,
        e1_col=e1_col,
        e2_col=e2_col,
    )