Skip to content

Commit

Permalink
Add ZTF crossmatch
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdstein committed Aug 20, 2024
1 parent 5b6318d commit e168e7a
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
1 change: 1 addition & 0 deletions mirar/catalog/kowalski/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from mirar.catalog.kowalski.gaia import Gaia, GaiaBright
from mirar.catalog.kowalski.ps1 import PS1, PS1STRM, PS1SGSc
from mirar.catalog.kowalski.tmass import TMASS
from mirar.catalog.kowalski.ztf import ZTF
34 changes: 34 additions & 0 deletions mirar/catalog/kowalski/ztf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Module for querying ZTF using Kowalski
"""

from mirar.catalog.kowalski.base_kowalski_catalog import BaseKowalskiXMatch


class ZTF(BaseKowalskiXMatch):
"""
ZTF Kowalski catalog
"""

catalog_name = "ZTF_alerts"
abbreviation = "ztf"
projection = {
"objectId": 1,
"ra": 1,
"dec": 1,
}

column_names = {
"objectId": "ztfname",
"ra": f"{abbreviation}ra",
"dec": f"{abbreviation}dec",
}

column_dtypes = {
"ztfname": str,
"ztfra": float,
"ztfdec": float,
}

ra_column_name = f"{abbreviation}ra"
dec_column_name = f"{abbreviation}dec"
3 changes: 2 additions & 1 deletion mirar/pipelines/winter/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from winterrb.model import WINTERNet

from mirar.catalog.kowalski import PS1, PS1STRM, TMASS, Gaia, GaiaBright, PS1SGSc
from mirar.catalog.kowalski import PS1, PS1STRM, TMASS, ZTF, Gaia, GaiaBright, PS1SGSc
from mirar.downloader.get_test_data import get_test_data_dir
from mirar.paths import (
BASE_NAME_KEY,
Expand Down Expand Up @@ -715,6 +715,7 @@
XMatch(catalog=PS1STRM(num_sources=3, search_radius_arcmin=0.5)),
XMatch(catalog=Gaia(num_sources=1, search_radius_arcmin=1.5)),
XMatch(catalog=GaiaBright(num_sources=1, search_radius_arcmin=1.5)),
XMatch(catalog=ZTF(num_sources=1, search_radius_arcmin=2.0 / 60.0)),
CustomSourceTableModifier(
modifier_function=winter_candidate_avro_fields_calculator
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "alert",
"doc": "avro alert schema for WINTER",
"fields": [
{"name": "schemavsn", "type": "string", "doc": "schema version used", "default": "0.3"},
{"name": "schemavsn", "type": "string", "doc": "schema version used", "default": "0.4"},
{"name": "publisher", "type": "string", "doc": "origin of alert packet", "default": "WINTER-mirar"},
{"name": "objectid", "type": "string", "doc": "name of parent source, e.g 'WNTR24aaaab'"},
{"name": "candid", "type": "long"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
{"name": "ruwegaia", "type": ["float", "null"], "doc": "Random Unit Weighted Error of closest source from Gaia EDR3 catalog; if exists within 90 arcsec [mas]"},
{"name": "distgaiabright", "type": ["float", "null"], "doc": "Distance to closest source from Gaia DR3 catalog brighter than magnitude 14; if exists within 90 arcsec [arcsec]"},
{"name": "plxgaiabright", "type": ["float", "null"], "doc": "Absolute (parallax/sigma) of closest source from Gaia EDR3 catalog brighter than magnitude 14; if exists within 90 arcsec [mag]"},
{"name": "ruwegaiabright", "type": ["float", "null"], "doc": "Random Unit Weighted Error of closest source from Gaia EDR3 catalog brighter than magnitude 14; if exists within 90 arcsec [mas]"}
{"name": "ruwegaiabright", "type": ["float", "null"], "doc": "Random Unit Weighted Error of closest source from Gaia EDR3 catalog brighter than magnitude 14; if exists within 90 arcsec [mas]"},
{"name": "ztfname", "type": ["string", "null"], "doc": "ZTF name of candidate if exists within 2 arcsec, e.g. ZTF20abzqkxg"},
{"name": "distztf", "type": ["float", "null"], "doc": "Distance to closest source from ZTF alert catalog; if exists within 2 arcsec [arcsec]"}
]
}
3 changes: 3 additions & 0 deletions mirar/pipelines/winter/generator/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ def winter_candidate_avro_fields_calculator(source_table: SourceBatch) -> Source
src_df["plxgaiabright"] = src_df["gaiabright_parallax_over_error1"]
src_df["ruwegaiabright"] = src_df["gaiabright_ruwe1"]

src_df["distztf"] = src_df["distztf1"]
src_df["ztfname"] = src_df["ztfname1"]

source.set_data(src_df)
new_batch.append(source)

Expand Down
7 changes: 7 additions & 0 deletions mirar/pipelines/winter/models/_candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ class CandidatesTable(WinterBase): # pylint: disable=too-few-public-methods
plxgaiabright = Column(Float, nullable=True)
ruwegaiabright = Column(Float, nullable=True)

# ZTF properties
ztfname = Column(VARCHAR(12), nullable=True)
distztf = Column(Float, nullable=True)


class Candidate(BaseDB):
"""
Expand Down Expand Up @@ -343,6 +347,9 @@ class Candidate(BaseDB):
plxgaiabright: float | None = Field(default=None)
ruwegaiabright: float | None = Field(ge=0, default=None)

ztfname: str | None = Field(default=None, max_length=12)
distztf: float | None = Field(ge=0, default=None)

def insert_entry(
self, duplicate_protocol, returning_key_names=None
) -> pd.DataFrame:
Expand Down

0 comments on commit e168e7a

Please sign in to comment.