diff --git a/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py b/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py new file mode 100644 index 0000000..bc86f0c --- /dev/null +++ b/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py @@ -0,0 +1,32 @@ +"""Remove requirement for intensity map, add flux and snr + +Revision ID: 46575bc0d660 +Revises: a1b2c3d4e5f6 +Create Date: 2026-05-20 16:08:14.624772 + +""" + +from collections.abc import Sequence + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "46575bc0d660" +down_revision: str | None = "a1b2c3d4e5f6" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + with op.batch_alter_table("depth_one_maps") as batch_op: + batch_op.add_column(sa.Column("flux_map", sa.String(), nullable=True)) + batch_op.add_column(sa.Column("snr_map", sa.String(), nullable=True)) + batch_op.alter_column("map_path", existing_type=sa.String(), nullable=True) + + +def downgrade() -> None: + with op.batch_alter_table("depth_one_maps") as batch_op: + batch_op.drop_column("flux_map") + batch_op.drop_column("snr_map") + batch_op.alter_column("map_path", existing_type=sa.String(), nullable=False) diff --git a/mapcat/database/depth_one_map.py b/mapcat/database/depth_one_map.py index bb8f7f6..cd653d3 100644 --- a/mapcat/database/depth_one_map.py +++ b/mapcat/database/depth_one_map.py @@ -27,7 +27,7 @@ class DepthOneMapTable(SQLModel, table=True): Unique map identifiers. Internal to SO map_name : str Name of depth 1 map - map_path : str + map_path : str | None Non-localized path to intensity map ivar_path : str | None Non-localized path to inverse-variance map @@ -35,6 +35,10 @@ class DepthOneMapTable(SQLModel, table=True): Non-localized path to the match-filtered 'rho' map kappa_path: str | None Non-localized path to the match-filtered 'kappa' map + flux_map: str | None + Non-localized path to the flux map. + snr_map: str | None + Non-localized path to the signal-to-noise map. start_time_path : str Non-localized path to the start time map. Each pixel represents the earliest time the pixel was observed. @@ -76,10 +80,12 @@ class DepthOneMapTable(SQLModel, table=True): map_id: int = Field(primary_key=True) map_name: str = Field(index=True, unique=True, nullable=False) - map_path: str - ivar_path: str | None + map_path: str | None = None + ivar_path: str | None = None rho_path: str | None = None kappa_path: str | None = None + flux_map: str | None = None + snr_map: str | None = None start_time_path: str | None = None mean_time_path: str | None @@ -116,3 +122,27 @@ class DepthOneMapTable(SQLModel, table=True): link_model=DepthOneToCoaddTable, ) notes: dict[str, Any] | None = Field(default=None, sa_type=JSON) + + @property + def coverage_path(self) -> str: + """ + Return a path to a map that can be used for coverage checking. + This is required because we generally use the intensity map for + coverage checking but it is not always available. We return the + first available of: intensity, rho, flux. + + Raises + ------ + ValueError + If no coverage-compatible map path is available. + """ + + if self.map_path is not None: + return self.map_path + if self.rho_path is not None: + return self.rho_path + if self.flux_map is not None: + return self.flux_map + raise ValueError( + f"No coverage map available for map {self.map_name} (id {self.map_id})" + ) diff --git a/mapcat/pointing/poly.py b/mapcat/pointing/poly.py index a78bd75..38d200a 100644 --- a/mapcat/pointing/poly.py +++ b/mapcat/pointing/poly.py @@ -103,12 +103,12 @@ def build_model( ra_weights = np.asarray(ra_weights) dec_weights = np.asarray(dec_weights) - assert ( - len(ra_weights) == n - ), "Length of ra_weights must match number of positions" - assert ( - len(dec_weights) == n - ), "Length of dec_weights must match number of positions" + assert len(ra_weights) == n, ( + "Length of ra_weights must match number of positions" + ) + assert len(dec_weights) == n, ( + "Length of dec_weights must match number of positions" + ) ras = measured_positions.ra.to_value(u.deg) decs = measured_positions.dec.to_value(u.deg) diff --git a/pyproject.toml b/pyproject.toml index 1e56354..d485494 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ mapcat = ["alembic/*", "alembic.ini", "alembic/versions/*"] [project] name = "mapcat" -version = "0.2.4" +version = "0.3.0" requires-python = ">=3.10" dependencies = [ "astropydantic",