proxtoolbox.utils.OrbitalTomog package¶
Submodules¶
proxtoolbox.utils.OrbitalTomog.array_tools module¶
-
proxtoolbox.utils.OrbitalTomog.array_tools.
shift_array
(arr: numpy.ndarray, dy: int, dx: int)[source]¶ Use numpy.roll to shift an array in the first and second dimensions :param arr: numpy array :param dy: shift in first dimension :param dx: shift in second dimension :return: array like arr
-
proxtoolbox.utils.OrbitalTomog.array_tools.
roll_to_pos
(arr: numpy.ndarray, y: int = 0, x: int = 0, pos: tuple = None, move_maximum: bool = False, by_abs_val: bool = True) → numpy.ndarray[source]¶ Shift the center of mass of an array to the given position by cyclic permutation
Parameters: - arr – 2d array, works best for well-centered feature with limited support
- y – position parameter
- x – position parameter for second dimension
- pos – tuple with the new position, overriding y,x values. should be used for higher-dimensional arrays
- move_maximum – if true, look only at max-value
- by_abs_val – take abs value for the determination of max-val or center-of-mass
Returns: array like original
-
proxtoolbox.utils.OrbitalTomog.array_tools.
shifted_fft
(arr, axes=None)[source]¶ Combined fftshift and fft routine, based on scipy.fftpack
- Args:
- arr: numpy array axes: identical to argument for scipy.fftpack.fft
- Returns:
- transformed array
-
proxtoolbox.utils.OrbitalTomog.array_tools.
shifted_ifft
(arr, axes=None)[source]¶ Combined fftshift and fft routine, based on scipy.fftpack
- Args:
- arr: numpy array axes: identical to argument for scipy.fftpack.fft
- Returns:
- transformed array
-
proxtoolbox.utils.OrbitalTomog.array_tools.
tile_array
(a: numpy.ndarray, shape, normalize: bool = False)[source]¶ Upsample an array by nearest-neighbour interpolation, i.e. [1,2] -> [1,1,2,2] :param a: numpy array, ndim = [2,3] :param shape: tile size, single integer for rectangular tiles, tuple for individual axes otherwise :return: resampled array
proxtoolbox.utils.OrbitalTomog.binning module¶
-
proxtoolbox.utils.OrbitalTomog.binning.
bin_array
(arr: numpy.ndarray, new_shape: any, pad_zeros: bool = True) → numpy.ndarray[source]¶ Reduce the size of an array by binning
Parameters: - arr – original
- new_shape – tuple which must be an integer divisor of the original shape, or integer to bin by that factor
- pad_zeros – pad array with zeros to enable binning by the given factor
Returns: new array
proxtoolbox.utils.OrbitalTomog.interpolation module¶
-
proxtoolbox.utils.OrbitalTomog.interpolation.
fourier_interpolate
(arr: numpy.ndarray, factor: any = 2.0, **kwargs) → numpy.ndarray[source]¶ Interpolation by padding in the Fourier domain. Keyword arguments get passed to sub-functionalities. Options are for example: - center_data: whether to move the center of mass to the center of the array before interpolation, this is generally a good idea
NOTE: testing by simple 2x interpolation and subsequent 2x2 binning shows that errors are introduced in the procedure
Parameters: - arr – numpy array, 2 or 3-dimensional
- factor – tuple or float to indicate by which factor to interpolate, default to factor 2
Returns: interpolated array, cast to identical dtype as arr
proxtoolbox.utils.OrbitalTomog.padding module¶
-
proxtoolbox.utils.OrbitalTomog.padding.
pad_to_square
(arr: numpy.core.multiarray.array, new_shape: tuple = None, **kwargs) → numpy.core.multiarray.array[source]¶ Given a numpy array of unequal dimensions, pad with zeros until it all dimensions have equal length
Parameters: - arr – numpy array
- new_shape – desired shape
- kwargs – are passed on to np.pad
Returns: