Skip to content

Commit

Permalink
Scan full sky query if pixels in query exceed a threshold (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonreusch committed Jun 1, 2023
1 parent b50f9ff commit e4d36d8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions nuztf/ampel_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
API_ZTF_ARCHIVE_URL = API_BASEURL + "/api/ztf/archive/v3"
API_CATALOGMATCH_URL = API_BASEURL + "/api/catalogmatch"

MAX_N_PIX = 1000

_, ampel_api_archive_token = load_credentials("ampel_api_archive_token")


Expand Down Expand Up @@ -498,6 +500,18 @@ def ampel_api_skymap(
# Now we reduce the query size
regions = utils.deres(nside=nside, ipix=pixels)

n_pix = 0
for reg in regions:
n_pix += len(reg["pixels"])

logger.debug(f"This comprises {n_pix} individual pixels")

if n_pix > MAX_N_PIX:
logger.warning(
f"Total number of pixels exceeds threshold ({MAX_N_PIX} pixels). Issuing a query for the full sky instead."
)
regions = [{"nside": 1, "pixels": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]}]

query = {
"regions": regions,
"jd": {
Expand Down
1 change: 1 addition & 0 deletions nuztf/skymap_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ampel_api_acknowledge_chunk,
ampel_api_lightcurve,
ampel_api_skymap,
ampel_api_timerange,
get_preprocessed_results,
)
from nuztf.base_scanner import BaseScanner
Expand Down
2 changes: 1 addition & 1 deletion slackbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
if self.event_type == "nu":
self.time_window = 10
elif self.event_type == "gw":
self.time_window = 2
self.time_window = 3
else:
self.time_window = time_window

Expand Down

0 comments on commit e4d36d8

Please sign in to comment.