antares-devkit 0.11.1__tar.gz → 0.12.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/PKG-INFO +1 -1
  2. antares_devkit-0.12.0/antares_devkit/filters/gw_em_candidates/__init__.py +73 -0
  3. antares_devkit-0.12.0/antares_devkit/filters/simple_slsn_filter/__init__.py +356 -0
  4. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/utils.py +1 -0
  5. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/pyproject.toml +1 -1
  6. antares_devkit-0.11.1/antares_devkit/filters/simple_slsn_filter/__init__.py +0 -135
  7. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/LICENSE.txt +0 -0
  8. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/README.md +0 -0
  9. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/__init__.py +0 -0
  10. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/bad_detection/__init__.py +0 -0
  11. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/bad_seeing/__init__.py +0 -0
  12. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/crash_filter/__init__.py +0 -0
  13. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/decam_shadow/__init__.py +0 -0
  14. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/desi_target/__init__.py +0 -0
  15. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/dwarf_nova_outburst/__init__.py +0 -0
  16. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/ecl_transient_1/__init__.py +0 -0
  17. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/ecl_transient_2/__init__.py +0 -0
  18. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/extragalactic/__init__.py +0 -0
  19. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/highamp/__init__.py +0 -0
  20. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/highfluxchange/__init__.py +0 -0
  21. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/highsnr/__init__.py +0 -0
  22. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/if_anomaly_detection/__init__.py +0 -0
  23. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/if_anomaly_detection/data/__init__.py +0 -0
  24. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/if_anomaly_detection/data/paleo2_106IFmodel_472727objs_nest=1000_cont=0.001_transf.pkl +0 -0
  25. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/imbh/__init__.py +0 -0
  26. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/inm31/__init__.py +0 -0
  27. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/laiss_rfc_ad_filter/__init__.py +0 -0
  28. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/laiss_rfc_ad_filter/data/__init__.py +0 -0
  29. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/laiss_rfc_ad_filter/data/cls=binary_n_estimators=100_max_depth=35_rs=11_max_feats=35_cw=balanced.pkl +0 -0
  30. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/lantern/__init__.py +0 -0
  31. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/lantern/data/__init__.py +0 -0
  32. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/lantern/data/lantern_xgboost_t2.0.7.pkl +0 -0
  33. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/lsst_ddf/__init__.py +0 -0
  34. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/lsst_transient_quality_scimma/__init__.py +0 -0
  35. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/malanchev_anomaly_transient_dmdt/__init__.py +0 -0
  36. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/malanchev_anomaly_transient_dmdt/data/__init__.py +0 -0
  37. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/malanchev_anomaly_transient_dmdt/data/malanchev_ssiforest_v1.pickle +0 -0
  38. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/malanchev_features_v1/__init__.py +0 -0
  39. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/microlensing/__init__.py +0 -0
  40. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/novtest/__init__.py +0 -0
  41. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/nuclear_transient/__init__.py +0 -0
  42. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/nuttela_tao/__init__.py +0 -0
  43. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/passta_nearby_transients/__init__.py +0 -0
  44. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/persistent_dimmers/__init__.py +0 -0
  45. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/random_tagger_filter/__init__.py +0 -0
  46. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/recent_reddening/__init__.py +0 -0
  47. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/refitt_newsources_snrcut/__init__.py +0 -0
  48. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/rubin_NovTest_soraisam/__init__.py +0 -0
  49. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/sample_filter/__init__.py +0 -0
  50. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/shadow_virgo/__init__.py +0 -0
  51. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/siena_mag_coord_cut/__init__.py +0 -0
  52. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/sso/__init__.py +0 -0
  53. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/sub_lum/__init__.py +0 -0
  54. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/superphot_plus_v1/__init__.py +0 -0
  55. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/superphot_plus_ztf_v3/__init__.py +0 -0
  56. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/test_dev_all/__init__.py +0 -0
  57. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/test_dev_lsst/__init__.py +0 -0
  58. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/test_dev_ztf/__init__.py +0 -0
  59. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/uniform_random_sample/__init__.py +0 -0
  60. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/vpdf/__init__.py +0 -0
  61. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/vpdf/data/__init__.py +0 -0
  62. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/vpdf/data/matheson_percent_grid_v1 +0 -0
  63. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/young_extragalactic_candidate/__init__.py +0 -0
  64. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/filters/young_rubin_transients_soraisam/__init__.py +0 -0
  65. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/antares_devkit/models.py +0 -0
  66. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/Dockerfile +0 -0
  67. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/__init__.py +0 -0
  68. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/conftest.py +0 -0
  69. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/data/large_locus.py +0 -0
  70. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/data/small_locus.py +0 -0
  71. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/unit/antares_devkit/filters/test_test_dev_all.py +0 -0
  72. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/unit/antares_devkit/filters/test_test_dev_lsst.py +0 -0
  73. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/unit/antares_devkit/filters/test_test_dev_ztf.py +0 -0
  74. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/unit/antares_devkit/test_models.py +0 -0
  75. {antares_devkit-0.11.1 → antares_devkit-0.12.0}/test/unit/test_filters.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: antares-devkit
3
- Version: 0.11.1
3
+ Version: 0.12.0
4
4
  Summary: Provides tools and utility methods to write and debug ANTARES filters with Python.
5
5
  Keywords: antares,devkit,filter development
6
6
  Author-Email: NSF NOIRLab ANTARES Team <antares@noirlab.edu>
@@ -0,0 +1,73 @@
1
+ from antares_devkit.models import BaseFilter
2
+
3
+ class GW_EM_Candidates(BaseFilter):
4
+ SLACK_CHANNEL = "#filter-gw-em-candidates"
5
+
6
+ TRIGGERING_SURVEY = "all"
7
+
8
+ REQUIRED_ALERT_PROPERTIES = [
9
+ "ant_survey",
10
+ ]
11
+
12
+ # setting this class variable gives us all the alerts associated with *any*
13
+ # (including both retracted and non-retracted events) GW event within this
14
+ # localization contour
15
+ REQUIRED_GRAV_WAVE_PROB_REGION = 95.0 # set to 100 to get *all* alerts
16
+
17
+ OUTPUT_LOCUS_TAGS = [
18
+ {
19
+ "name": "gw_em_candidates",
20
+ "description": (
21
+ "Detection inside an active (10-day window), non-retracted "
22
+ "GW localization, and not a known SSO"
23
+ ),
24
+ }
25
+ ]
26
+
27
+ def _run(self, locus):
28
+ alert = locus.alert
29
+ props = alert.properties
30
+ survey = props.get("ant_survey")
31
+
32
+ # Detections only (skip ZTF upper limits)
33
+ if survey == 2:
34
+ return
35
+
36
+ # Not a known solar system object
37
+ if (
38
+ survey == 1 and
39
+ 'ztf_ssnamenr' in locus.properties and
40
+ locus.properties['ztf_ssnamenr'] != 'null'
41
+ ):
42
+ return
43
+
44
+ if (
45
+ survey == 4 and
46
+ 'survey' in locus.properties and
47
+ "lsst" in locus.properties["survey"] and
48
+ "ss_object_id" in locus.properties["survey"]["lsst"] and
49
+ len(locus.properties["survey"]["lsst"]["ss_object_id"])
50
+ ):
51
+ return
52
+
53
+ # Must match an active, non-retracted GW event.
54
+ # ANTARES drops notice metadata after 10 days, so a missing
55
+ # notice means the event is no longer active.
56
+ # But also, retracted events seem to remain associated even after
57
+ # they are no longer "active", so we still need to filter out retracted
58
+ # GW events
59
+ for event in alert.grav_wave_events:
60
+
61
+ # Only consider candidates where the transient is inside the credible region
62
+ if event["contour_level"] > self.REQUIRED_GRAV_WAVE_PROB_REGION:
63
+ continue
64
+
65
+ # ensure that the GW notice is not retracted
66
+ notice = locus.grav_wave_events_metadata.get(event["gracedb_id"])
67
+ if notice is None or notice.notice_type == "RETRACTION":
68
+ continue
69
+
70
+ # if it passes these filters for at least one GW event then we can tag it
71
+ # and move on to the next alert!
72
+ locus.tag("gw_em_candidates")
73
+ break
@@ -0,0 +1,356 @@
1
+ import numpy as np
2
+ from antares_devkit.models import BaseFilter
3
+
4
+
5
+ class SimpleSLSNPreFilter(BaseFilter):
6
+ """ZTF SLSN filter: new transients (<= 300 d before peak) reaching M <= -20."""
7
+
8
+ SLACK_CHANNEL = "#filter-simple-slsn-prefilter"
9
+ TRIGGERING_SURVEY = "ztf"
10
+
11
+ REQUIRED_LOCUS_PROPERTIES = []
12
+ REQUIRED_ALERT_PROPERTIES = ["ant_mjd", "ztf_magpsf", "ztf_sigmapsf", "ztf_fid"]
13
+ REQUIRED_TAGS = []
14
+
15
+ OUTPUT_LOCUS_PROPERTIES = [
16
+ {
17
+ "name": "eyoue_slsn_peak_apparent_mag",
18
+ "type": "float",
19
+ "description": "Brightest valid ZTF PSF magnitude.",
20
+ },
21
+ {
22
+ "name": "eyoue_slsn_peak_mag_error",
23
+ "type": "float",
24
+ "description": "Error of brightest ZTF measurement.",
25
+ },
26
+ {
27
+ "name": "eyoue_slsn_peak_mjd",
28
+ "type": "float",
29
+ "description": "MJD of brightest ZTF measurement.",
30
+ },
31
+ {
32
+ "name": "eyoue_slsn_peak_band",
33
+ "type": "str",
34
+ "description": "Band of brightest ZTF measurement.",
35
+ },
36
+ {
37
+ "name": "eyoue_slsn_duration_days",
38
+ "type": "float",
39
+ "description": "Days from first detection to peak.",
40
+ },
41
+ {
42
+ "name": "eyoue_slsn_late_detections",
43
+ "type": "int",
44
+ "description": "Positive detections > 500 d after peak.",
45
+ },
46
+ {
47
+ "name": "eyoue_slsn_galactic_latitude",
48
+ "type": "float",
49
+ "description": "Galactic latitude (deg).",
50
+ },
51
+ {
52
+ "name": "eyoue_slsn_nuclear_offset",
53
+ "type": "float",
54
+ "description": "Distance to nearest reference-image source (arcsec).",
55
+ },
56
+ {
57
+ "name": "eyoue_slsn_host_mag",
58
+ "type": "float",
59
+ "description": "PS1 r mag of nearest PS1 source (likely host).",
60
+ },
61
+ {
62
+ "name": "eyoue_slsn_host_redshift",
63
+ "type": "float",
64
+ "description": "Redshift from an ANTARES catalog match.",
65
+ },
66
+ {
67
+ "name": "eyoue_slsn_redshift_source",
68
+ "type": "str",
69
+ "description": "Catalog and column of the redshift.",
70
+ },
71
+ {
72
+ "name": "eyoue_slsn_peak_abs_mag",
73
+ "type": "float",
74
+ "description": "Peak absolute magnitude from the catalog redshift.",
75
+ },
76
+ {
77
+ "name": "eyoue_slsn_min_redshift_for_slsn",
78
+ "type": "float",
79
+ "description": "Redshift needed for the peak to reach M = -20.",
80
+ },
81
+ {
82
+ "name": "eyoue_slsn_prefilter_status",
83
+ "type": "str",
84
+ "description": "SLSN filter result.",
85
+ },
86
+ ]
87
+
88
+ OUTPUT_LOCUS_TAGS = [
89
+ {
90
+ "name": "eyoue_slsn_prefilter",
91
+ "description": "Candidate for downstream SLSN enrichment.",
92
+ },
93
+ {
94
+ "name": "eyoue_slsn_luminous",
95
+ "description": "Catalog redshift shows peak M <= -20 (SLSN).",
96
+ },
97
+ ]
98
+
99
+ REQUIRES_FILES = []
100
+
101
+ def setup(self):
102
+ # Light-curve cuts
103
+ self.minimum_valid_detections = 3
104
+ self.minimum_amplitude = 0.5 # mag, within one band
105
+ self.maximum_peak_mag_error = 0.30
106
+ self.min_drb, self.min_rb = 0.5, 0.55
107
+ # AGN / variable cuts
108
+ self.maximum_duration_days = 300.0 # activity before peak
109
+ self.max_post_peak_days = 500.0
110
+ self.max_late_detections = 5
111
+ self.max_negative_detections, self.max_negative_fraction = 3, 0.15
112
+ self.min_abs_galactic_latitude = 5.0
113
+ # Position cuts (arcsec / mag)
114
+ self.star_sgscore, self.star_max_distance = 0.8, 1.0
115
+ self.nuclear_max_distance, self.nuclear_max_magnitude = 0.5, 18.5
116
+ self.nuclear_host_max_distance, self.nuclear_host_max_mag = 0.6, 20.0
117
+ self.host_max_distance, self.max_host_abs_mag = 3.0, -22.0
118
+ # SLSN cutoff
119
+ self.slsn_abs_mag_cutoff = -20.0
120
+ self.abs_mag_tolerance = 0.2 # accepts M <= -19.8 (no K-corr / dust)
121
+
122
+ self.agn_catalogs = (
123
+ "milliquas",
124
+ "veron_agn",
125
+ "xmm",
126
+ "vii_274_bzcat",
127
+ "chandra",
128
+ )
129
+ self.star_catalogs = (
130
+ "asassn_variable",
131
+ "csdr2",
132
+ "vsx",
133
+ "gaia_dr3_variab",
134
+ "ztf_variables",
135
+ "gaia_edr3_distances",
136
+ "sdss_stars",
137
+ )
138
+ # Only catalogs whose ANTARES copies carry a redshift column
139
+ self.redshift_catalogs = ("tns", "ned", "sdss")
140
+ self.redshift_columns = (
141
+ "redshift",
142
+ "redshift_1", # NED (Redshift_1, lower-cased below)
143
+ "z",
144
+ "z_spec",
145
+ "zspec",
146
+ "specz",
147
+ "photo_z",
148
+ "photoz",
149
+ "z_phot",
150
+ "zphot",
151
+ )
152
+ self.ztf_band_names = {1: "g", 2: "r", 3: "i"}
153
+
154
+ # Distance modulus table, flat LCDM (H0=70, Om=0.3), simple K-correction
155
+ z = np.linspace(0.0, 3.0, 3001)
156
+ inv_e = 1.0 / np.sqrt(0.3 * (1 + z) ** 3 + 0.7)
157
+ steps = 0.5 * (inv_e[1:] + inv_e[:-1]) * np.diff(z)
158
+ dc = np.concatenate([[0.0], np.cumsum(steps)])
159
+ dl = (1 + z[1:]) * dc[1:] * (299792.458 / 70.0)
160
+ self.z_grid = z[1:]
161
+ self.dist_mod = 5 * np.log10(dl * 1e5) - 2.5 * np.log10(1 + z[1:])
162
+
163
+ def _run(self, locus):
164
+ def stop(reason):
165
+ locus.set_property("eyoue_slsn_prefilter_status", reason)
166
+
167
+ def col(name): # column as float array (NaN for masked); None if missing
168
+ if name not in ts.colnames:
169
+ return None
170
+ return np.ma.filled(np.ma.asarray(ts[name], dtype=float), np.nan)
171
+
172
+ def med(name, mask): # median of a ZTF column (ignores -999 "no value")
173
+ v = col(name)
174
+ v = v[mask] if v is not None else np.array([])
175
+ v = v[np.isfinite(v) & (v > -998)]
176
+ return float(np.median(v)) if v.size else np.nan
177
+
178
+ def dmod(z):
179
+ return float(np.interp(z, self.z_grid, self.dist_mod))
180
+
181
+ # Load ZTF light curve
182
+ ts = locus.timeseries("ztf")
183
+ mjd, mag = col("ant_mjd"), col("ztf_magpsf")
184
+ err, band = col("ztf_sigmapsf"), col("ztf_fid")
185
+ if any(x is None for x in (mjd, mag, err, band)):
186
+ return stop("Unable to evaluate ZTF data")
187
+
188
+ # Valid g/r/i photometry that passes real/bogus
189
+ valid = (
190
+ np.isfinite(mjd)
191
+ & np.isfinite(mag)
192
+ & np.isfinite(err)
193
+ & (err > 0)
194
+ & np.isin(band, [1, 2, 3])
195
+ )
196
+ drb, rb = col("ztf_drb"), col("ztf_rb")
197
+ has_drb = np.isfinite(drb) if drb is not None else np.zeros(len(mjd), bool)
198
+ if drb is not None:
199
+ valid &= ~(has_drb & (drb < self.min_drb))
200
+ if rb is not None:
201
+ valid &= ~(~has_drb & (rb < self.min_rb))
202
+
203
+ # Positive vs negative subtractions
204
+ if "ztf_isdiffpos" in ts.colnames:
205
+ raw = np.ma.filled(np.ma.asarray(ts["ztf_isdiffpos"]).astype(str), "")
206
+ sign = np.char.lower(raw.astype(str))
207
+ else:
208
+ sign = np.full(len(mjd), "t")
209
+ negative = np.isin(sign, ["f", "0", "false", "0.0"])
210
+ positive = valid & ~negative
211
+
212
+ # Require >= 3 detections and >= 0.5 mag variation within one band
213
+ if positive.sum() < self.minimum_valid_detections:
214
+ return stop("Rejected: too few valid measurements")
215
+ p_mag, p_band = mag[positive], band[positive].astype(int)
216
+ amps = [
217
+ np.ptp(p_mag[p_band == b])
218
+ for b in np.unique(p_band)
219
+ if (p_band == b).sum() >= 2
220
+ ]
221
+ if not amps or max(amps) < self.minimum_amplitude:
222
+ return stop("Rejected: insufficient brightness variation")
223
+
224
+ # Peak (brightest positive detection)
225
+ i = np.flatnonzero(positive)[np.argmin(p_mag)]
226
+ peak_mag, peak_err, peak_mjd = float(mag[i]), float(err[i]), float(mjd[i])
227
+ if peak_err > self.maximum_peak_mag_error:
228
+ return stop("Rejected: excessive peak uncertainty")
229
+ peak_band = self.ztf_band_names.get(int(band[i]), "unknown")
230
+ locus.set_property("eyoue_slsn_peak_apparent_mag", peak_mag)
231
+ locus.set_property("eyoue_slsn_peak_mag_error", peak_err)
232
+ locus.set_property("eyoue_slsn_peak_mjd", peak_mjd)
233
+ locus.set_property("eyoue_slsn_peak_band", peak_band)
234
+
235
+ # AGN / long-term variables: activity long before peak, or long after it
236
+ duration = float(peak_mjd - mjd[valid].min())
237
+ late = positive & (mjd > peak_mjd + self.max_post_peak_days)
238
+ n_late = int(late.sum())
239
+ locus.set_property("eyoue_slsn_duration_days", duration)
240
+ locus.set_property("eyoue_slsn_late_detections", n_late)
241
+ if duration > self.maximum_duration_days:
242
+ return stop("Rejected: activity spans too long (> 300 d before peak)")
243
+ if n_late > self.max_late_detections:
244
+ return stop("Rejected: still active long after peak (persistent variable)")
245
+
246
+ # Negative subtractions before/around peak => variable source
247
+ early = valid & (mjd <= peak_mjd + 30)
248
+ n_neg = int((early & negative).sum())
249
+ neg_fraction = n_neg / max(early.sum(), 1)
250
+ if (
251
+ n_neg >= self.max_negative_detections
252
+ and neg_fraction > self.max_negative_fraction
253
+ ):
254
+ return stop("Rejected: repeated negative subtractions (variable source)")
255
+
256
+ # Galactic plane
257
+ b = float(locus.location.galactic.b.deg)
258
+ locus.set_property("eyoue_slsn_galactic_latitude", b)
259
+ if abs(b) < self.min_abs_galactic_latitude:
260
+ return stop("Rejected: Galactic plane")
261
+
262
+ # Catalog matches: AGN and stars
263
+ catalogs = {str(k): (v or []) for k, v in dict(locus.catalog_objects).items()}
264
+ for name, objs in catalogs.items():
265
+ if objs and name.lower().startswith(self.agn_catalogs):
266
+ return stop(f"Rejected: AGN/QSO catalog match ({name})")
267
+ if objs and name.lower().startswith(self.star_catalogs):
268
+ return stop(f"Rejected: star / variable-star catalog match ({name})")
269
+
270
+ # Position checks: PS1 star, bright nucleus, nuclear in bright galaxy
271
+ pre_peak = positive & (mjd <= peak_mjd) # later refs can contain the SN
272
+ sgscore = med("ztf_sgscore1", positive)
273
+ dist_ps1 = med("ztf_distpsnr1", positive)
274
+ dist_nr = med("ztf_distnr", pre_peak)
275
+ mag_nr = med("ztf_magnr", pre_peak)
276
+ host_mag = med("ztf_srmag1", positive)
277
+ if np.isfinite(dist_nr):
278
+ locus.set_property("eyoue_slsn_nuclear_offset", dist_nr)
279
+ if host_mag > 0:
280
+ locus.set_property("eyoue_slsn_host_mag", host_mag)
281
+ if sgscore >= self.star_sgscore and dist_ps1 <= self.star_max_distance:
282
+ return stop("Rejected: coincident with PS1 star")
283
+ if (
284
+ dist_nr <= self.nuclear_max_distance
285
+ and mag_nr <= self.nuclear_max_magnitude
286
+ ):
287
+ return stop("Rejected: nuclear in bright point-like source (likely AGN)")
288
+ if (
289
+ dist_ps1 <= self.nuclear_host_max_distance
290
+ and 0 < host_mag <= self.nuclear_host_max_mag
291
+ and sgscore < 0.5
292
+ ):
293
+ return stop(
294
+ f"Rejected: nuclear in bright galaxy (host r={host_mag:.1f}, "
295
+ "likely AGN/TDE)"
296
+ )
297
+
298
+ # Redshift needed to reach the SLSN cutoff
299
+ z_needed = float(
300
+ np.interp(
301
+ peak_mag - self.slsn_abs_mag_cutoff,
302
+ self.dist_mod,
303
+ self.z_grid,
304
+ left=np.nan,
305
+ right=np.nan,
306
+ )
307
+ )
308
+ if np.isfinite(z_needed):
309
+ locus.set_property("eyoue_slsn_min_redshift_for_slsn", z_needed)
310
+
311
+ # Catalog redshift (first match, in catalog priority order)
312
+ redshift = source = None
313
+ for prefix in self.redshift_catalogs:
314
+ for name, objs in catalogs.items():
315
+ if not name.lower().startswith(prefix):
316
+ continue
317
+ for obj in objs:
318
+ lower = {str(k).lower(): v for k, v in obj.items()}
319
+ for key in self.redshift_columns:
320
+ try:
321
+ z = float(lower.get(key))
322
+ except (TypeError, ValueError):
323
+ continue
324
+ if redshift is None and 0.001 < z < 3.0:
325
+ redshift, source = z, f"{name}:{key}"
326
+
327
+ # With redshift: tag once the peak reaches the cutoff
328
+ if redshift is not None:
329
+ abs_mag = peak_mag - dmod(redshift)
330
+ locus.set_property("eyoue_slsn_host_redshift", redshift)
331
+ locus.set_property("eyoue_slsn_redshift_source", source)
332
+ locus.set_property("eyoue_slsn_peak_abs_mag", abs_mag)
333
+ if abs_mag > self.slsn_abs_mag_cutoff + self.abs_mag_tolerance:
334
+ return stop(f"Not yet SLSN: peak M={abs_mag:.2f} at z={redshift:.3f}")
335
+ stop(f"SLSN: peak M={abs_mag:.2f} at z={redshift:.3f}")
336
+ return locus.tag("eyoue_slsn_luminous")
337
+
338
+ # Without redshift: reject if the host would be too bright at SLSN distance
339
+ if (
340
+ np.isfinite(z_needed)
341
+ and host_mag > 0
342
+ and dist_ps1 <= self.host_max_distance
343
+ and not sgscore >= self.star_sgscore
344
+ ):
345
+ host_abs = host_mag - dmod(z_needed)
346
+ if host_abs < self.max_host_abs_mag:
347
+ return stop(
348
+ "Rejected: host too bright for an SLSN distance "
349
+ f"(host M={host_abs:.1f})"
350
+ )
351
+
352
+ stop(
353
+ "Passed pre-filter; requires downstream NED enrichment "
354
+ f"(SLSN if z >= {z_needed:.3f})"
355
+ )
356
+ locus.tag("eyoue_slsn_prefilter")
@@ -56,6 +56,7 @@ def get_filters_path():
56
56
  "UniformRandomSample": "antares_devkit.filters.uniform_random_sample",
57
57
  "Lantern": "antares_devkit.filters.lantern",
58
58
  "SimpleSLSNPreFilter": "antares_devkit.filters.simple_slsn_filter",
59
+ "GW_EM_Candidates": "antares_devkit.filters.gw_em_candidates",
59
60
  }
60
61
 
61
62
 
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "antares-devkit"
9
- version = "0.11.1"
9
+ version = "0.12.0"
10
10
  description = "Provides tools and utility methods to write and debug ANTARES filters with Python."
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.9"
@@ -1,135 +0,0 @@
1
- from antares_devkit.models import BaseFilter
2
-
3
-
4
- class SimpleSLSNPreFilter(BaseFilter):
5
- """ZTF pre-filter for downstream SLSN host/redshift enrichment."""
6
-
7
- SLACK_CHANNEL = "#filter-simple-slsn-prefilter"
8
- TRIGGERING_SURVEY = "ztf"
9
-
10
- REQUIRED_LOCUS_PROPERTIES = []
11
- REQUIRED_ALERT_PROPERTIES = [
12
- "ant_mjd",
13
- "ztf_magpsf",
14
- "ztf_sigmapsf",
15
- "ztf_fid",
16
- ]
17
- REQUIRED_TAGS = []
18
-
19
- OUTPUT_LOCUS_PROPERTIES = [
20
- {
21
- "name": "eyoue_slsn_peak_apparent_mag",
22
- "type": "float",
23
- "description": "Brightest valid ZTF PSF magnitude.",
24
- },
25
- {
26
- "name": "eyoue_slsn_peak_mag_error",
27
- "type": "float",
28
- "description": "Error of brightest ZTF measurement.",
29
- },
30
- {
31
- "name": "eyoue_slsn_peak_mjd",
32
- "type": "float",
33
- "description": "MJD of brightest ZTF measurement.",
34
- },
35
- {
36
- "name": "eyoue_slsn_peak_band",
37
- "type": "str",
38
- "description": "Band of brightest ZTF measurement.",
39
- },
40
- {
41
- "name": "eyoue_slsn_prefilter_status",
42
- "type": "str",
43
- "description": "SLSN pre-filter result.",
44
- },
45
- ]
46
-
47
- OUTPUT_LOCUS_TAGS = [
48
- {
49
- "name": "eyoue_slsn_prefilter",
50
- "description": "Candidate for downstream SLSN enrichment.",
51
- }
52
- ]
53
-
54
- REQUIRES_FILES = []
55
-
56
- def setup(self):
57
- # False-positive rejection thresholds
58
- self.minimum_valid_detections = 5
59
- self.minimum_bands = 2
60
- self.minimum_amplitude = 0.5 # mag
61
- self.maximum_duration_days = 300.0
62
- self.maximum_peak_mag_error = 0.30
63
- self.ztf_band_names = {1: "g", 2: "r", 3: "i"}
64
-
65
- def _run(self, locus):
66
- import numpy as np
67
-
68
- def stop(reason):
69
- locus.set_property("eyoue_slsn_prefilter_status", reason)
70
- return None
71
-
72
- # Load ZTF light curve
73
- try:
74
- ts = locus.timeseries("ztf")
75
- mjd = np.asarray(ts["ant_mjd"].data, dtype=float)
76
- mag = np.asarray(ts["ztf_magpsf"].data, dtype=float)
77
- err = np.asarray(ts["ztf_sigmapsf"].data, dtype=float)
78
- band = np.asarray(ts["ztf_fid"].data, dtype=float)
79
- except Exception:
80
- return stop("Unable to evaluate ZTF data")
81
-
82
- # Keep valid g/r/i photometry
83
- valid = (
84
- np.isfinite(mjd)
85
- & np.isfinite(mag)
86
- & np.isfinite(err)
87
- & (err > 0)
88
- & np.isfinite(band)
89
- & np.isin(band, [1.0, 2.0, 3.0])
90
- )
91
-
92
- if np.sum(valid) < self.minimum_valid_detections:
93
- return stop("Rejected: too few valid measurements")
94
-
95
- mjd, mag, err, band = (
96
- mjd[valid],
97
- mag[valid],
98
- err[valid],
99
- band[valid].astype(int),
100
- )
101
-
102
- # Require >=2 bands
103
- if len(np.unique(band)) < self.minimum_bands:
104
- return stop("Rejected: fewer than two bands")
105
-
106
- # Require >=0.5 mag variability
107
- if np.ptp(mag) < self.minimum_amplitude:
108
- return stop("Rejected: insufficient brightness variation")
109
-
110
- # Reject long-term variables
111
- if np.ptp(mjd) > self.maximum_duration_days:
112
- return stop("Rejected: activity spans too long")
113
-
114
- # Find brightest observation (lowest magnitude)
115
- i = int(np.argmin(mag))
116
- peak_mag = float(mag[i])
117
- peak_err = float(err[i])
118
- peak_mjd = float(mjd[i])
119
- peak_band = self.ztf_band_names.get(int(band[i]), "unknown")
120
-
121
- # Require reliable peak photometry
122
- if peak_err > self.maximum_peak_mag_error:
123
- return stop("Rejected: excessive peak uncertainty")
124
-
125
- # Store values for downstream NED analysis
126
- locus.set_property("eyoue_slsn_peak_apparent_mag", peak_mag)
127
- locus.set_property("eyoue_slsn_peak_mag_error", peak_err)
128
- locus.set_property("eyoue_slsn_peak_mjd", peak_mjd)
129
- locus.set_property("eyoue_slsn_peak_band", peak_band)
130
- locus.set_property(
131
- "eyoue_slsn_prefilter_status",
132
- "Passed pre-filter; requires downstream NED enrichment",
133
- )
134
-
135
- locus.tag("eyoue_slsn_prefilter")