Skip to content

Commit

Permalink
Merge pull request #813 from dirac-institute/issue-752
Browse files Browse the repository at this point in the history
Issue 752
  • Loading branch information
samncorn authored Feb 10, 2024
2 parents 6823cff + 27faae0 commit 25c1ff5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/sorcha/modules/PPAddUncertainties.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def calcAstrometricUncertainty(
error_rand = calcRandomAstrometricErrorPerCoord(FWHMeff, SNR, astErrCoeff)
# random astrometric error for nvisit observations
if nvisit > 1:
error_rand = error_rand / sqrt(nvisit)
error_rand = error_rand / np.sqrt(nvisit)
# add systematic error floor:
astrom_error = np.sqrt(error_sys * error_sys + error_rand * error_rand)

Expand Down
31 changes: 19 additions & 12 deletions src/sorcha/modules/PPFootprintFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
sin = np.sin
cos = np.cos

logger = logging.getLogger(__name__)


def distToSegment(points, x0, y0, x1, y1):
"""Compute the distance from each point to the line segment defined by
Expand Down Expand Up @@ -148,12 +150,10 @@ def ison(self, point, ϵ=10.0 ** (-11), edge_thresh=None, plot=False):
selectedidx : array
Indices of points in point array that fall on the sensor.
"""
pplogger = logging.getLogger(__name__)

# points needs to be shape 2,n
# if single point, needs to be an array of single element arrays
if len(point.shape) != 2 or point.shape[0] != 2:
pplogger.error(f"ERROR: Detector.ison invalid array {point.shape}")
logger.error(f"ERROR: Detector.ison invalid array {point.shape}")
sys.exit(f"ERROR: Detector.ison invalid array {point.shape}")

# check whether point is in circle bounding the detector
Expand All @@ -172,7 +172,7 @@ def ison(self, point, ϵ=10.0 ** (-11), edge_thresh=None, plot=False):
elif self.units == "radians" or self.units == "rad":
edge_thresh = np.radians(edge_thresh / 3600.0)
else:
pplogger.error(f"ERROR: Detector.ison unable to convert edge_thresh to {self.units}")
logger.error(f"ERROR: Detector.ison unable to convert edge_thresh to {self.units}")
sys.exit(f"ERROR: Detector.ison unable to convert edge_thresh to {self.units}")

n = len(self.x)
Expand Down Expand Up @@ -428,16 +428,23 @@ def __init__(self, path=None, detectorName="detector"):
# the center of the camera should be the origin
# if the user doesn't provide their own version of the footprint,
# we'll use the default LSST version that comes included.
pplogger = logging.getLogger(__name__)

if path:
allcornersdf = pd.read_csv(path)
pplogger.info(f"Using CCD Detector file: {path}")
try:
allcornersdf = pd.read_csv(path)
logger.info(f"Using CCD Detector file: {path}")
except IOError:
logger.error(f"Provided detector footprint file does not exist.")
sys.exit(1)

else:
default_camera_config_file = "data/LSST_detector_corners_100123.csv"
stream = pkg_resources.resource_stream(__name__, default_camera_config_file)
pplogger.info(f"Using built-in CCD Detector file: {default_camera_config_file}")
allcornersdf = pd.read_csv(stream)
try:
default_camera_config_file = "data/LSST_detector_corners_100123.csv"
stream = pkg_resources.resource_stream(__name__, default_camera_config_file)
logger.info(f"Using built-in CCD Detector file: {default_camera_config_file}")
allcornersdf = pd.read_csv(stream)
except IOError:
logger.error(f"Error loading default camera footprint, exiting ...")
sys.exit(1)

# build dictionary of detectorName:[list_of_inds]
det_to_inds = {}
Expand Down

0 comments on commit 25c1ff5

Please sign in to comment.