Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-35309: Improve efficiency of trailed source measurement #11

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added python/lsst/meas/extensions/.DS_Store
Binary file not shown.
21 changes: 11 additions & 10 deletions python/lsst/meas/extensions/trailedSources/NaivePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import numpy as np
import scipy.optimize as sciOpt
from scipy.special import erf
from math import sqrt

from lsst.geom import Point2D
from lsst.meas.base.pluginRegistry import register
Expand Down Expand Up @@ -161,8 +162,8 @@ def measure(self, measRecord, exposure):
xpy = Ixx + Iyy
xmy2 = xmy*xmy
xy2 = Ixy*Ixy
a2 = 0.5 * (xpy + np.sqrt(xmy2 + 4.0*xy2))
b2 = 0.5 * (xpy - np.sqrt(xmy2 + 4.0*xy2))
a2 = 0.5 * (xpy + sqrt(xmy2 + 4.0*xy2))
b2 = 0.5 * (xpy - sqrt(xmy2 + 4.0*xy2))

# Measure the trail length
# Check if the second-moments are weighted
Expand Down Expand Up @@ -215,7 +216,7 @@ def measure(self, measRecord, exposure):
xcErr2, ycErr2 = np.diag(measRecord.getCentroidErr())

# Error in length
desc = np.sqrt(xmy2 + 4.0*xy2) # Descriminant^1/2 of EV equation
desc = sqrt(xmy2 + 4.0*xy2) # Descriminant^1/2 of EV equation
da2dIxx = 0.5*(1.0 + (xmy/desc))
da2dIyy = 0.5*(1.0 - (xmy/desc))
da2dIxy = 2.0*Ixy / desc
Expand All @@ -227,21 +228,21 @@ def measure(self, measRecord, exposure):
# Error in theta
dThetadIxx = -Ixy / (xmy2 + 4.0*xy2) # dThetadIxx = -dThetadIyy
dThetadIxy = xmy / (xmy2 + 4.0*xy2)
thetaErr = np.sqrt(dThetadIxx*dThetadIxx*(IxxErr2 + IyyErr2) + dThetadIxy*dThetadIxy*IxyErr2)
thetaErr = sqrt(dThetadIxx*dThetadIxx*(IxxErr2 + IyyErr2) + dThetadIxy*dThetadIxy*IxyErr2)

# Error in flux
dFdxc, dFdyc, _, dFdL, dFdTheta = gradFlux
fluxErr = np.sqrt(dFdL*dFdL*lengthErr*lengthErr + dFdTheta*dFdTheta*thetaErr*thetaErr
+ dFdxc*dFdxc*xcErr2 + dFdyc*dFdyc*ycErr2)
fluxErr = sqrt(dFdL*dFdL*lengthErr*lengthErr + dFdTheta*dFdTheta*thetaErr*thetaErr
+ dFdxc*dFdxc*xcErr2 + dFdyc*dFdyc*ycErr2)

# Errors in end-points
dxdradius = np.cos(theta)
dydradius = np.sin(theta)
radiusErr2 = lengthErr*lengthErr/4.0
xErr2 = np.sqrt(xcErr2 + radiusErr2*dxdradius*dxdradius + thetaErr*thetaErr*dxdtheta*dxdtheta)
yErr2 = np.sqrt(ycErr2 + radiusErr2*dydradius*dydradius + thetaErr*thetaErr*dydtheta*dydtheta)
x0Err = np.sqrt(xErr2) # Same for x1
y0Err = np.sqrt(yErr2) # Same for y1
xErr2 = sqrt(xcErr2 + radiusErr2*dxdradius*dxdradius + thetaErr*thetaErr*dxdtheta*dxdtheta)
yErr2 = sqrt(ycErr2 + radiusErr2*dydradius*dydradius + thetaErr*thetaErr*dydtheta*dydtheta)
x0Err = sqrt(xErr2) # Same for x1
y0Err = sqrt(yErr2) # Same for y1

# Set flags
measRecord.set(self.keyRa, ra)
Expand Down