Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jonwright/ImageD11
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwright committed Nov 17, 2023
2 parents 97fcedd + 5a0603b commit 7b43cfe
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions ImageD11/blobcorrector.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, argsplinefile, orientation="edf"):
self.tck2 = None
if self.splinefile is not None:
self.readfit2dspline(self.splinefile)

self.dim = ( int(self.xmax-self.xmin), int(self.ymax-self.ymin)) # detector dimensions read from splinefile


def correct(self, xin, yin):
Expand Down Expand Up @@ -138,6 +138,33 @@ def make_pos_lut(self, dims):
self.pixel_lut[1] * self.ysize )
return self.pos_lut


def correct_px_lut(self, pks):
"""Transform x,y in raw image coordinates into x,y of an
idealised image using a LUT. Faster than standard correct method for large peakfiles.
pks : ImageD11 columnfile with raw coordinates s_raw, f_raw add new colulmns sc, fc with corrected coordinates"""

assert self.dim is not None
assert 's_raw' in pks.titles and 'f_raw' in pks.titles

# make pixel_lut + substract xy grid coordinate (i,j) to keep only dx and dy arrays.
self.make_pixel_lut(self.dim)
i,j = numpy.mgrid[ 0:self.dim[0], 0:self.dim[1] ]
dx = self.pixel_lut[0] - i
dy = self.pixel_lut[1] - j

# get integer pixel index (si,fi) of each peak
si = numpy.round(pks['s_raw']).astype(int)
fi = numpy.round(pks['f_raw']).astype(int)

# apply dx dy correction on s_raw / f_raw
sc = (dx[ si, fi ] + pks.s_raw).astype(numpy.float32)
fc = (dy[ si, fi ] + pks.f_raw).astype(numpy.float32)
# add corrected arrays as new columns
pks.addcolumn(sc, 'sc')
pks.addcolumn(fc, 'fc')


def distort(self, xin, yin):
"""
Distort a pair of points xnew, ynew to find where they
Expand Down Expand Up @@ -338,4 +365,3 @@ def pixel_lut(self):
# Hence, for now,
# """
# pass

0 comments on commit 7b43cfe

Please sign in to comment.