Skip to content

Commit

Permalink
KeyError for early KN filter (#163)
Browse files Browse the repository at this point in the history
* Trigger CI

* Install locally py4j

* Fix layout

* cast series into array
  • Loading branch information
JulienPeloton authored Dec 12, 2023
1 parent 22d1ac8 commit 7ed92fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ jobs:
ANOMALY_TG_TOKEN: ${{ secrets.ANOMALY_TG_TOKEN }}
run: |
pip install fink-utils --upgrade
pip install py4j
./run_tests.sh
curl -s https://codecov.io/bash | bash
4 changes: 2 additions & 2 deletions fink_filters/filter_anomaly_notification/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def anomaly_notification_(
... send_to_tg=False, channel_id=None,
... send_to_slack=False, channel_name=None)
>>> print(pdf_anomalies['objectId'].values)
['ZTF21acoshvy' 'ZTF18aaypnnd' 'ZTF18abgjtxx' 'ZTF18aapgymv' 'ZTF18aaakhsv'
'ZTF18abhxigz' 'ZTF18aapoack' 'ZTF19aboujyi' 'ZTF18abbtxsx' 'ZTF18actxdmj']
['ZTF21acoshvy' 'ZTF18abgjtxx' 'ZTF19acevxhv' 'ZTF19aboujyi' 'ZTF18aapgymv'
'ZTF18abbtxsx' 'ZTF18aaakhsv' 'ZTF18aaypnnd' 'ZTF18aapoack' 'ZTF18abzvnya']
"""
# Filtering by coordinates
if cut_coords:
Expand Down
23 changes: 13 additions & 10 deletions fink_filters/filter_early_kn_candidates/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

from fink_filters.tester import spark_unit_tests

def perform_classification(drb, classtar, jd, jdstarthist, ndethist, cdsxmatch, fid,
def perform_classification(
drb, classtar, jd, jdstarthist, ndethist, cdsxmatch, fid,
magpsf, sigmapsf, ra, dec, roid):
"""
"""
Expand Down Expand Up @@ -129,8 +130,10 @@ def perform_classification(drb, classtar, jd, jdstarthist, ndethist, cdsxmatch,
)
# for a test on "many" objects, you may wait 1s to stay under the
# query limit.
table = SDSS.query_region(pos, fields=['type'],
radius=5 * u.arcsec)
table = SDSS.query_region(
pos, fields=['type'],
radius=5 * u.arcsec
)
type_close_objects = []
if table is not None:
type_close_objects = table['type']
Expand Down Expand Up @@ -302,14 +305,14 @@ def early_kn_candidates(
jd.astype(float)[f_kn] - jdstarthist.astype(float)[f_kn]
)
# Redefine notations relative to candidates
fid = np.array(fid)[f_kn]
jd = np.array(jd)[f_kn]
mag = magpsf[f_kn]
err_mag = sigmapsf[f_kn]
field = field[f_kn]
fid = np.array(fid.values)[f_kn]
jd = np.array(jd.values)[f_kn]
mag = magpsf.values[f_kn]
err_mag = sigmapsf.values[f_kn]
field = field.values[f_kn]

dict_filt = {1: 'g', 2: 'r'}
for i, alertID in enumerate(objectId[f_kn]):
for i, alertID in enumerate(objectId[f_kn].values):
# information to send
alert_text = """
*Fink Science Portal:* <https://fink-portal.org/{}|{}>
Expand Down Expand Up @@ -442,7 +445,7 @@ def early_kn_candidates(
# DWF channel and requirements
dwf_ztf_fields = [1525, 530, 482, 1476, 388, 1433]
dwf_in_env = ('KNWEBHOOK_DWF' in os.environ)
if (int(field.values[i]) in dwf_ztf_fields) and dwf_in_env:
if (int(field[i]) in dwf_ztf_fields) and dwf_in_env:
requests.post(
os.environ['KNWEBHOOK_DWF'],
json={
Expand Down

0 comments on commit 7ed92fb

Please sign in to comment.