From dab3e7192f6ea0432fb6d0e584bd4826933802fd Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Wed, 20 May 2026 16:09:42 -0400 Subject: [PATCH 1/4] Remove requirement for intensity map --- ...0_remove_requirement_for_intensity_map_.py | 33 +++++++++++++++++ mapcat/database/depth_one_map.py | 36 +++++++++++++++++-- 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py 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..325ea1d --- /dev/null +++ b/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py @@ -0,0 +1,33 @@ +"""Remove requirement for intensity map, add flux and snr + +Revision ID: 46575bc0d660 +Revises: a1b2c3d4e5f6 +Create Date: 2026-05-20 16:08:14.624772 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '46575bc0d660' +down_revision: Union[str, None] = 'a1b2c3d4e5f6' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[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) + pass + + +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) \ No newline at end of file diff --git a/mapcat/database/depth_one_map.py b/mapcat/database/depth_one_map.py index bb8f7f6..6167ffc 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})" + ) \ No newline at end of file From 9deefe052c2a1ff11cb24df03d4fbafe9983cf49 Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Wed, 20 May 2026 16:10:51 -0400 Subject: [PATCH 2/4] Formatting --- ...5bc0d660_remove_requirement_for_intensity_map_.py | 10 +++++----- mapcat/database/depth_one_map.py | 2 +- mapcat/pointing/poly.py | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py b/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py index 325ea1d..50abac6 100644 --- a/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py +++ b/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py @@ -5,15 +5,15 @@ Create Date: 2026-05-20 16:08:14.624772 """ + from typing import Sequence, Union -from alembic import op import sqlalchemy as sa - +from alembic import op # revision identifiers, used by Alembic. -revision: str = '46575bc0d660' -down_revision: Union[str, None] = 'a1b2c3d4e5f6' +revision: str = "46575bc0d660" +down_revision: Union[str, None] = "a1b2c3d4e5f6" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None @@ -30,4 +30,4 @@ 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) \ No newline at end of file + 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 6167ffc..cd653d3 100644 --- a/mapcat/database/depth_one_map.py +++ b/mapcat/database/depth_one_map.py @@ -145,4 +145,4 @@ def coverage_path(self) -> str: return self.flux_map raise ValueError( f"No coverage map available for map {self.map_name} (id {self.map_id})" - ) \ No newline at end of file + ) 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) From 516b171a1cd69a7685f718027f57943358f2a696 Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Wed, 20 May 2026 16:13:02 -0400 Subject: [PATCH 3/4] Remove 'optional' --- ...46575bc0d660_remove_requirement_for_intensity_map_.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py b/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py index 50abac6..bc86f0c 100644 --- a/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py +++ b/mapcat/alembic/versions/46575bc0d660_remove_requirement_for_intensity_map_.py @@ -6,16 +6,16 @@ """ -from typing import Sequence, Union +from collections.abc import Sequence import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision: str = "46575bc0d660" -down_revision: Union[str, None] = "a1b2c3d4e5f6" -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None +down_revision: str | None = "a1b2c3d4e5f6" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None def upgrade() -> None: @@ -23,7 +23,6 @@ def upgrade() -> None: 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) - pass def downgrade() -> None: From ce1c45ca7e0589b7e44204f35894607376de453b Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Thu, 21 May 2026 08:35:27 -0400 Subject: [PATCH 4/4] Rev version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",