Exemple #1
0
def test_bkg_sub_03(scan2d_from_nxs_01: Scan2D):
    """
    Make sure that the background subtraction decreases our intensity.
    """
    vals, stdevs = (np.zeros(len(scan2d_from_nxs_01.intensity)),
                    np.zeros(len(scan2d_from_nxs_01.intensity)))

    # Also update the image intensities & errors.
    for i, image in enumerate(scan2d_from_nxs_01.images):
        vals[i], stdevs[i] = image.sum()

    # Store the intensity(Q) to the new value.
    scan2d_from_nxs_01.intensity = np.array(vals)
    scan2d_from_nxs_01.intensity_e = np.array(stdevs)

    region_list = scan2d_from_nxs_01.metadata.background_regions
    scan2d_from_nxs_01.bkg_sub(roi_subtraction, list_of_regions=region_list)

    assert (vals > scan2d_from_nxs_01.intensity).all()
Exemple #2
0
def test_gauss_bkg_02(scan2d_from_nxs_01: Scan2D):
    """
    Make sure that carrying out this subtraction decreases our intensity.

    Note that this function is not being tested for sensible results because
    this doesn't generally seem to be a sensible technique to use on I07. As
    more instruments are supported, if this technique becomes useful, its
    tests will need to be extended. For now, only the minimum is being done
    to ensure that it is roughly functional.
    """
    vals = np.zeros(len(scan2d_from_nxs_01.intensity))
    # Also update the image intensities & errors.
    for i, image in enumerate(scan2d_from_nxs_01.images):
        vals[i], _ = image.sum()
    # Store the intensity(Q) to the new value.
    scan2d_from_nxs_01.intensity = np.array(vals)

    intensity_0 = np.copy(scan2d_from_nxs_01.intensity)
    scan2d_from_nxs_01.bkg_sub(fit_gaussian_1d)

    assert (scan2d_from_nxs_01.intensity < intensity_0).all()