Skip to content

Commit

Permalink
Correcting checks on ra and dec and ensure that they are np arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquot committed Jan 9, 2025
1 parent 6b653a4 commit 8da4055
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion bin/pycbc_make_sky_grid
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ from scipy.spatial.transform import Rotation as R

import pycbc
from pycbc.detector import Detector
from pycbc.io.hdf import HFile
from pycbc.types import angle_as_radians
from pycbc.tmpltbank import sky_grid

Expand Down
7 changes: 4 additions & 3 deletions pycbc/tmpltbank/sky_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import h5py

from pycbc.detector import Detector

from pycbc.conversion import ensurearray

class SkyGrid:
def __init__(self, ra, dec, detectors, ref_gps_time):
Expand All @@ -34,9 +34,10 @@ def __init__(self, ra, dec, detectors, ref_gps_time):
# We store the points in a 2D array internally, first dimension runs
# over the list of points, second dimension is RA/dec.
# Question: should we use Astropy sky positions instead?
if (self.ra < 0).any() or (self.ra > 2 * np.pi).any():
ra, dec, _ = ensurearray(ra,dec)
if (ra < 0).any() or (ra > 2 * np.pi).any():
raise ValueError('RA must be in the range [0,2π]')
if (self.dec < -np.pi/2).any() or (ra > np.pi/2).any():
if (dec < -np.pi/2).any() or (dec > np.pi/2).any():
raise ValueError('DEC must be in the range [-π/2, π/2]')
self.positions = np.vstack([ra, dec]).T
self.detectors = sorted(detectors)
Expand Down

0 comments on commit 8da4055

Please sign in to comment.