def yvar(self): """ The y coordinates. """ yvar = _np.shape(linspacestep(self._ystart, self._ystop, self.step))[0] - 1 yvar = linspacestep(1, yvar) return yvar
def yvar(self): """ The y coordinates. """ yvar = _np.shape(linspacestep(self._ystart, self._ystop, self.step))[0] - 1 yvar = linspacestep(1, yvar) return yvar
def __init__(self, img, xbounds=None, ybounds=None, step=1): # ====================================== # Save things # ====================================== self._img = img self._xbounds = xbounds self._ybounds = ybounds self._step = step self._ind = None # ====================================== # Translate to clearer variables # ====================================== if xbounds is None: xstart = 0 xstop = img.shape[0] else: xstart = xbounds[0] xstop = xbounds[1] if ybounds is None: ystart = 0 ystop = img.shape[1] else: ystart = ybounds[0] ystop = ybounds[1] self._ystart = ystart self._ystop = ystop self._xstart = xstart self._xstop = xstop xrange = slice(xstart, xstop) yrange = slice(ystart, ystop) img = img[xrange, yrange] # ====================================== # Check number of points and # initialize arrays # ====================================== num_pts = (ystop - ystart) / step self._variance = _np.zeros(num_pts) self._gr = _np.empty(num_pts, object) # ====================================== # Fit individual slices # ====================================== for i, val in enumerate(linspacestep(0, ystop - ystart - step, step)): # Take a strip of the image strip = img[:, slice(val, val + step)] # Sum over the strip to get an average of sorts histdata = _np.sum(strip, 1) xbins = len(histdata) x = _np.linspace(1, xbins, xbins) # Fit with a Gaussian to find spot size try: self._gr[i] = GaussResults( x, histdata, # sigma_y = _np.ones(xbins), variance = True, background = True ) self._variance[i] = self._gr[i].popt[2] except RuntimeError as e: print(e)
def __init__(self, img, xbounds=None, ybounds=None, step=1): # ====================================== # Save things # ====================================== self._img = img self._xbounds = xbounds self._ybounds = ybounds self._step = step self._ind = None # ====================================== # Translate to clearer variables # ====================================== if xbounds is None: xstart = 0 xstop = img.shape[0] else: xstart = xbounds[0] xstop = xbounds[1] if ybounds is None: ystart = 0 ystop = img.shape[1] else: ystart = ybounds[0] ystop = ybounds[1] self._ystart = ystart self._ystop = ystop self._xstart = xstart self._xstop = xstop xrange = slice(xstart, xstop) yrange = slice(ystart, ystop) img = img[xrange, yrange] # ====================================== # Check number of points and # initialize arrays # ====================================== num_pts = (ystop - ystart) / step self._variance = _np.zeros(num_pts) self._gr = _np.empty(num_pts, object) # ====================================== # Fit individual slices # ====================================== for i, val in enumerate(linspacestep(0, ystop - ystart - step, step)): # Take a strip of the image strip = img[:, slice(val, val + step)] # Sum over the strip to get an average of sorts histdata = _np.sum(strip, 1) xbins = len(histdata) x = _np.linspace(1, xbins, xbins) # Fit with a Gaussian to find spot size try: self._gr[i] = GaussResults( x, histdata, # sigma_y = _np.ones(xbins), variance=True, background=True) self._variance[i] = self._gr[i].popt[2] except RuntimeError as e: print(e)