def test_subtract_dark():
    cal_dict = sort_ibsen_by_int(DIR)
    REFERENCE = copy.deepcopy(cal_dict[5.0]['reference']['tdata'])
    DARK = copy.deepcopy(cal_dict[5.0]['darkcurrent']['tdata'])
    SINGLE_SPECTRA = copy.deepcopy(cal_dict[5.0]['reference']['tdata'][0])
    REFERENCE_MEAN = np.mean(REFERENCE, axis=0)
    DARK_MEAN = np.mean(DARK, axis=0)
    REFERENCE_CORRECTED = REFERENCE_MEAN - DARK_MEAN
    SINGLE_SPECTRA_CORRECTED = SINGLE_SPECTRA - DARK_MEAN

    cal_dict = subtract_dark(cal_dict)

    assert cal_dict[5.0]['reference']['darkcurrent_corrected'] == True
    assert_array_equal(cal_dict[5.0]['reference']['mean'], REFERENCE_CORRECTED)
    assert_array_equal(cal_dict[5.0]['reference']['tdata'][0], SINGLE_SPECTRA_CORRECTED)
    assert_array_equal(cal_dict[5.0]['reference']['data'][:,0], SINGLE_SPECTRA_CORRECTED)
def prepare_data():
    corrected_calc = subtract_dark(sort_ibsen_by_int(DIR))
    return corrected_calc