def _calc(self, cars, nrb, ret_obj): try: # Assume that an nD nrb should be averaged to be 1D # TODO: Change this in the future to accept matching NRB's nrb = _mean_nd_to_1d(nrb) if self.rng is None: kkd = _kkrelation(bg=nrb + self.nrb_amp_offset, cri=cars + self.cars_amp_offset, hilb_kwargs=self.hilb_kwargs, **self.kk_kwargs) ret_obj *= 0 ret_obj += kkd else: slice_cars_rng = cars.ndim*[slice(None)] slice_cars_rng[self.kk_kwargs['axis']] = self.rng slice_cars_rng = tuple(slice_cars_rng) slice_ret_obj = ret_obj.ndim*[slice(None)] slice_ret_obj[self.kk_kwargs['axis']] = self.rng slice_ret_obj = tuple(slice_ret_obj) kkd = _kkrelation(bg=nrb[self.rng] + self.nrb_amp_offset, cri=cars[slice_cars_rng] + self.cars_amp_offset, hilb_kwargs=self.hilb_kwargs, **self.kk_kwargs) ret_obj *= 0 ret_obj[slice_ret_obj] += kkd except Exception as e: print('Error: {}'.format(e)) return False else: return True
def _calc(self, cars, nrb, ret_obj): # Assume that an nD nrb should be averaged to be 1D nrb = _mean_nd_to_1d(nrb) shp = cars.shape[0:-2] # Step row-by-row through image for idx in _np.ndindex(shp): if self.rng is None: kkd = _kkrelation(bg=nrb + self.nrb_amp_offset, cri=cars[idx] + self.cars_amp_offset, phase_offset=self.phase_offset, norm_by_bg=self.norm_to_nrb, pad_factor=self.pad_factor) else: kkd = _kkrelation(bg=nrb[self.rng] + self.nrb_amp_offset, cri=cars[idx][..., self.rng] + self.cars_amp_offset, phase_offset=self.phase_offset, norm_by_bg=self.norm_to_nrb, pad_factor=self.pad_factor) try: ret_obj[idx] *= 0 if self.rng is None: ret_obj[idx] += kkd elif ret_obj[idx].size == kkd.size: ret_obj[idx] += kkd else: ret_obj[idx][..., self.rng] += kkd except: return False else: pass return True
def _calc(self, data, ret_obj): # Assume that an nD dark should be averaged to be 1D self.dark = _mean_nd_to_1d(self.dark, axis=-1) # Expand dark dimensionality to match data.ndim self.dark = _expand_1d_to_ndim(self.dark, data.ndim) ret_obj -= self.dark return True
def _calc(self, data, ret_obj): # Assume that an nD dark should be averaged to be 1D self.dark = _mean_nd_to_1d(self.dark, axis=-1) # Expand dark dimensionality to match data.ndim self.dark = _expand_1d_to_ndim(self.dark, data.ndim) try: ret_obj -= self.dark except: return False else: return True