sasdata.data_util.manipulations module¶
Data manipulations for 2D data sets. Using the meta data information, various types of averaging are performed in Q-space
To test this module use:
`
cd test
PYTHONPATH=../src/ python2 -m sasmanipulations.test.utest_averaging DataInfoTests.test_sectorphi_quarter
`
- class sasdata.data_util.manipulations.Binning(min_value, max_value, n_bins, base=None)¶
Bases:
objectThis class just creates a binning object either linear or log
- get_bin_index(value)¶
- Parameters:
value – the value in the binning interval whose bin index should be returned. Must be between min_value and max_value.
The general formula logarithm binning is: bin = floor(N * (log(x) - log(min)) / (log(max) - log(min)))
- class sasdata.data_util.manipulations.Boxavg(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)¶
Bases:
Boxavg
- class sasdata.data_util.manipulations.Boxcut(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)¶
Bases:
Boxcut
- class sasdata.data_util.manipulations.Boxsum(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)¶
Bases:
Boxsum
- class sasdata.data_util.manipulations.CircularAverage(r_min=0.0, r_max=0.0, bin_width=0.0005)¶
Bases:
objectPerform circular averaging on 2D data
The data returned is the distribution of counts as a function of Q
- class sasdata.data_util.manipulations.Ring(r_min=0.0, r_max=0.0, center_x=0.0, center_y=0.0, nbins=36)¶
Bases:
RingWrapper for new Ring.
- property nbins_phi¶
- class sasdata.data_util.manipulations.Ringcut(r_min=0.0, r_max=0.0, center_x=0.0, center_y=0.0)¶
Bases:
Ringcut
- class sasdata.data_util.manipulations.SectorPhi(r_min, r_max, phi_min=0, phi_max=6.283185307179586, nbins=20, base=None)¶
Bases:
_SectorSector average as a function of phi. I(phi) is return and the data is averaged over Q.
A sector is defined by r_min, r_max, phi_min, phi_max. The number of bin in phi also has to be defined.
- class sasdata.data_util.manipulations.SectorQ(r_min, r_max, phi_min=0, phi_max=6.283185307179586, nbins=20, base=None)¶
Bases:
_SectorSector average as a function of Q for both wings. setting the _Sector.fold attribute determines whether or not the two sectors are averaged together (folded over) or separate. In the case of separate (not folded), the qs for the “minor wing” are arbitrarily set to a negative value. I(Q) is returned and the data is averaged over phi.
A sector is defined by r_min, r_max, phi_min, phi_max. where r_min, r_max, phi_min, phi_max >0. The number of bin in Q also has to be defined.
- class sasdata.data_util.manipulations.Sectorcut(phi_min=0.0, phi_max=3.141592653589793, center_x=0.0, center_y=0.0)¶
Bases:
Sectorcut
- class sasdata.data_util.manipulations.SlabX(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0, bin_width=0.001, fold=False)¶
Bases:
SlabXWrapper for new SlabX.
- Old signature:
SlabX(x_min=0, x_max=0, y_min=0, y_max=0, bin_width=0.001, fold=False)
New signature uses nbins; translate bin_width -> nbins using ceil(range/bin_width)
- class sasdata.data_util.manipulations.SlabY(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0, bin_width=0.001, fold=False)¶
Bases:
SlabYWrapper for new SlabY. Same bin_width -> nbins translation as SlabX.
- class sasdata.data_util.manipulations.WedgePhi(r_min, r_max, phi_min=0, phi_max=6.283185307179586, center_x=0.0, center_y=0.0, nbins=10)¶
Bases:
WedgePhiWrapper for new WedgePhi (behaviour matches legacy WedgePhi expectations).
- class sasdata.data_util.manipulations.WedgeQ(r_min, r_max, phi_min=0, phi_max=6.283185307179586, center_x=0.0, center_y=0.0, nbins=10)¶
Bases:
WedgeQWrapper for new WedgeQ (behaviour matches legacy WedgeQ expectations).
- sasdata.data_util.manipulations.flip_phi(phi: float) float¶
Force phi to be within the 0 <= to <= 2pi range by adding or subtracting 2pi as necessary
- Returns:
phi in >=0 and <=2Pi
- sasdata.data_util.manipulations.get_dq_data(data2d: Data2D) array¶
Get the dq for resolution averaging The pinholes and det. pix contribution present in both direction of the 2D which must be subtracted when converting to 1D: dq_overlap should be calculated ideally at q = 0. Note This method works on only pinhole geometry. Extrapolate dqx(r) and dqy(phi) at q = 0, and take an average.
- sasdata.data_util.manipulations.get_intercept(q: float, q_0: float, q_1: float) float | None¶
Returns the fraction of the side at which the q-value intercept the pixel, None otherwise. The values returned is the fraction ON THE SIDE OF THE LOWEST Q.
A B +-----------+--------+ <--- pixel size 0 1 Q_0 -------- Q ----- Q_1 <--- equivalent Q range if Q_1 > Q_0, A is returned if Q_1 < Q_0, B is returned if Q is outside the range of [Q_0, Q_1], None is returned
- sasdata.data_util.manipulations.get_pixel_fraction(q_max: float, q_00: float, q_01: float, q_10: float, q_11: float) float¶
Returns the fraction of the pixel defined by the four corners (q_00, q_01, q_10, q_11) that has q < q_max.:
q_01 q_11 y=1 +--------------+ | | | | | | y=0 +--------------+ q_00 q_10 x=0 x=1
- sasdata.data_util.manipulations.get_pixel_fraction_square(x: float, x_min: float, x_max: float) float¶
Return the fraction of the length from xmin to x.:
A B +-----------+---------+ xmin x xmax
- Parameters:
x – x-value
x_min – minimum x for the length considered
x_max – minimum x for the length considered
- Returns:
(x-xmin)/(xmax-xmin) when xmin < x < xmax
- sasdata.data_util.manipulations.get_q_compo(dx: float, dy: float, detector_distance: float, wavelength: float, compo: str | None = None) float¶
This reduces tiny error at very large q. Implementation of this func is not started yet.<–ToDo
- sasdata.data_util.manipulations.position_and_wavelength_to_q(dx: float, dy: float, detector_distance: float, wavelength: float) float¶
- Parameters:
dx – x-distance from beam center [mm]
dy – y-distance from beam center [mm]
detector_distance – sample to detector distance [mm]
wavelength – neutron wavelength [nm]
- Returns:
q-value at the given position