Skip to content

Commit

Permalink
Improve DIPOL quad matching (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanep97 authored Jun 9, 2024
1 parent 992e731 commit 224da9f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion iop4lib/instruments/dipol.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,16 @@ def _build_wcs_for_polarimetry_images_photo_quads(cls, redf: 'ReducedFit', summa
quads_1 = np.array(list(itertools.combinations(sets_L[0], 4)))
quads_2 = np.array(list(itertools.combinations(sets_L[1], 4)))

# remove quads of points that have an area less than 5% of the image
def PolyArea(x,y):
# order points clockwise
idx = np.argsort(np.arctan2(y-y.mean(), x-x.mean()))
x, y = x[idx], y[idx]
return 0.5*np.abs(np.dot(x,np.roll(y,1))-np.dot(y,np.roll(x,1)))

quads_1 = np.array([quad for quad in quads_1 if PolyArea(quad[:,0], quad[:,1]) > 0.05*(redf_pol.width*redf_pol.height)])
quads_2 = np.array([quad for quad in quads_2 if PolyArea(quad[:,0], quad[:,1]) > 0.05*(redf_pol.width*redf_pol.height)])

if len(quads_1) == 0 or len(quads_2) == 0:
logger.error(f"No quads found in {redf_pol} and {redf_phot}, returning success = False.")
return BuildWCSResult(success=False)
Expand Down Expand Up @@ -803,7 +813,7 @@ def _build_wcs_for_polarimetry_images_photo_quads(cls, redf: 'ReducedFit', summa
fig.clear()


result = BuildWCSResult(success=True, wcslist=wcslist, info={'redf_phot__pk':redf_phot.pk, 'redf_phot__fileloc':redf_phot.fileloc, n_seg_threshold:n_seg_threshold, npixels:npixels})
result = BuildWCSResult(success=True, wcslist=wcslist, info={'redf_phot__pk':redf_phot.pk, 'redf_phot__fileloc':redf_phot.fileloc, 'n_seg_threshold':n_seg_threshold, 'npixels':npixels})

return result

Expand Down

0 comments on commit 224da9f

Please sign in to comment.