Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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)
36 changes: 33 additions & 3 deletions mapcat/database/depth_one_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ 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
rho_path: str | None
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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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})"
)
12 changes: 6 additions & 6 deletions mapcat/pointing/poly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading