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

Added a cap on distance for matching and changed error handling on KSB #158

Merged
merged 11 commits into from
May 26, 2021
16 changes: 8 additions & 8 deletions btk/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,11 @@ def meas_ksb_ellipticity(image, additional_params):
gal_image = galsim.Image(image[meas_band_num, :, :])
gal_image.scale = pixel_scale
shear_est = "KSB"
try:
res = galsim.hsm.EstimateShear(gal_image, psf_image, shear_est=shear_est, strict=True)
result = [res.corrected_g1, res.corrected_g2, res.observed_shape.e]
except RuntimeError as e:
print(e)
result = [-10.0, -10.0, -10.0]

res = galsim.hsm.EstimateShear(gal_image, psf_image, shear_est=shear_est, strict=False)
ismael-mendoza marked this conversation as resolved.
Show resolved Hide resolved
result = [res.corrected_g1, res.corrected_g2, res.observed_shape.e]
if res.error_message != "":
print(res.error_message)
thuiop marked this conversation as resolved.
Show resolved Hide resolved
return result


Expand Down Expand Up @@ -181,8 +180,9 @@ def get_detection_match(true_table, detected_table, f_distance=distance_center):
match_indx = [-1] * len(true_table)
dist_m = [0.0] * len(true_table)
for i, indx in enumerate(true_indx):
match_indx[indx] = detected_indx[i]
dist_m[indx] = dist[indx][detected_indx[i]]
if dist[indx][detected_indx[i]] <= 5:
thuiop marked this conversation as resolved.
Show resolved Hide resolved
match_indx[indx] = detected_indx[i]
dist_m[indx] = dist[indx][detected_indx[i]]

match_table["match_detected_id"] = match_indx
match_table["dist"] = dist_m
Expand Down