Skip to content

Commit

Permalink
Refactor and fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdstein committed Aug 6, 2024
1 parent 34cf739 commit 65ed21a
Show file tree
Hide file tree
Showing 11 changed files with 524 additions and 467 deletions.
12 changes: 1 addition & 11 deletions nuztf/base_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(
):
self.cone_nside = cone_nside
self.t_min = t_min

(
self.map_coords,
self.pixel_nos,
Expand Down Expand Up @@ -906,17 +907,6 @@ def calculate_overlap_with_observations(

self.logger.info("Unpacking observations")

if self.nside < 1024:
(
self.map_coords,
self.pixel_nos,
self.nside,
self.map_probs,
self.data,
self.total_pixel_area,
self.key,
) = self.unpack_skymap(output_nside=1024)

pix_map = dict()
pix_obs_times = dict()

Expand Down
21 changes: 16 additions & 5 deletions nuztf/neutrino_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,19 @@ def filter_f_no_prv(self, res: dict):
# Require 2 detections separated by 15 mins
if (endhist - starthist) < 0.01:
self.logger.debug(
f"❌ {ztf_id}: Does have 2 detections, but these are not separated by >15 mins (delta t = {(endhist-starthist)*1440:.0f} min)"
f"❌ {ztf_id}: Does have 2 detections, but these are not separated by "
f">15 mins (delta t = {(endhist-starthist)*1440:.0f} min)"
)
return False

self.logger.debug(f"✅ {ztf_id}: Passes first filtering stage (no prv).")
return True

def filter_f_history(self, res: dict):
"""Filter based on 2 detection requirement and probability contour requirement"""
"""
Filter based on 2 detection requirement
and probability contour requirement
"""

ztf_id = res["objectId"]

Expand Down Expand Up @@ -215,8 +219,14 @@ def in_contour(self, ra_deg, dec_deg):

return np.logical_and(in_ra, in_dec)

def unpack_skymap(self, skymap=None, output_nside: None | int = None):
""" """
def unpack_skymap(self, output_nside: None | int = None):
"""
Unpack the skymap and return the pixel coordinates and probabilities
:param output_nside: Nside of the output map
:return: Map coordinates, pixel numbers, output nside,
map probabilities, data, total pixel area, key
"""
output_nside = 2048 if output_nside is None else output_nside

map_coords = []
Expand All @@ -225,7 +235,8 @@ def unpack_skymap(self, skymap=None, output_nside: None | int = None):
center_ra = np.radians(np.mean([self.ra_max, self.ra_min]))
center_dec = np.radians(np.mean([self.dec_max, self.dec_min]))
# Take the larger of the two sides and convert to radians
# To make sure to include all pixels until the edge of the rectangle, we have to devide by sqrt(2)
# To make sure to include all pixels until the edge of the rectangle,
# we have to devide by sqrt(2)
# (not 2 as previously done here!)
rad = np.radians(
max(self.ra_max - self.ra_min, self.dec_max - self.dec_min)
Expand Down
Loading

0 comments on commit 65ed21a

Please sign in to comment.