コード例 #1
0
def test_manual_refit_add_points():

    # Initialise the calibrator
    wavecal = WavelengthCalibration(log_file_name=None)
    wavecal.initialise_calibrator(peaks)

    wavecal.set_calibrator_properties(num_pix=1000)
    wavecal.set_hough_properties(
        num_slopes=1000,
        range_tolerance=500.0,
        xbins=200,
        ybins=200,
        min_wavelength=3000.0,
        max_wavelength=8000.0,
    )
    wavecal.add_user_atlas(
        elements=elements_linear, wavelengths=wavelengths_linear
    )
    wavecal.set_ransac_properties(minimum_matches=25)
    wavecal.do_hough_transform(brute_force=False)

    # Run the wavelength calibration
    (
        best_p,
        atched_peaks,
        matched_atlas,
        rms,
        residual,
        peak_utilisation,
        atlas_utilisation,
    ) = wavecal.fit(max_tries=500, fit_deg=1)

    # Refine solution
    (
        best_p,
        matched_peaks,
        matched_atlas,
        rms,
        residual,
        peak_utilisation,
        atlas_utilisation,
    ) = wavecal.robust_refit(best_p, refine=False, robust_refit=True)

    wavecal.add_pix_wave_pair(
        2000.0, 3000.0 + 4 * 2000.0 + 1.0e-3 * 2000.0**2.0
    )
    (
        best_p_manual,
        matched_peaks,
        matched_atlas,
        rms,
        residuals,
    ) = wavecal.manual_refit(matched_peaks, matched_atlas)

    assert np.allclose(best_p_manual, best_p)
コード例 #2
0
def test_linear_fit():

    wavecal = WavelengthCalibration(log_file_name=None)
    wavecal.initialise_calibrator(peaks)

    wavecal.set_calibrator_properties(num_pix=1000)
    wavecal.set_hough_properties(
        num_slopes=1000,
        range_tolerance=500.0,
        xbins=200,
        ybins=200,
        min_wavelength=3000.0,
        max_wavelength=8000.0,
    )
    wavecal.add_user_atlas(
        elements=elements_linear, wavelengths=wavelengths_linear
    )
    wavecal.set_ransac_properties(minimum_matches=20)
    wavecal.do_hough_transform(brute_force=False)

    # Run the wavelength calibration
    (
        best_p,
        matched_peaks,
        matched_atlas,
        rms,
        residual,
        peak_utilisation,
        atlas_utilisation,
    ) = wavecal.fit(max_tries=500, fit_deg=1)
    # Refine solution
    (
        best_p,
        matched_peaks,
        matched_atlas,
        rms,
        residual,
        peak_utilisation,
        atlas_utilisation,
    ) = wavecal.robust_refit(best_p, refine=False, robust_refit=True)

    assert np.abs(best_p[1] - 5.0) / 5.0 < 0.001
    assert np.abs(best_p[0] - 3000.0) / 3000.0 < 0.001
    assert peak_utilisation > 0.8
    assert atlas_utilisation > 0.0
コード例 #3
0
def test_quadratic_fit():

    # Initialise the calibrator
    wavecal = WavelengthCalibration(log_file_name=None)
    wavecal.initialise_calibrator(peaks)

    wavecal.set_calibrator_properties(num_pix=1000)
    wavecal.set_hough_properties(
        num_slopes=1000,
        range_tolerance=500.0,
        xbins=100,
        ybins=100,
        min_wavelength=3000.0,
        max_wavelength=8000.0,
    )
    wavecal.add_user_atlas(
        elements=elements_quadratic, wavelengths=wavelengths_quadratic
    )
    wavecal.set_ransac_properties(minimum_matches=20)
    wavecal.do_hough_transform(brute_force=False)

    # Run the wavelength calibration
    (
        best_p,
        matched_peaks,
        matched_atlas,
        rms,
        residual,
        peak_utilisation,
        atlas_utilisation,
    ) = wavecal.fit(
        max_tries=2000, fit_tolerance=5.0, candidate_tolerance=2.0, fit_deg=2
    )
    # Refine solution
    (
        best_p_robust,
        matched_peaks,
        matched_atlas,
        rms,
        residual,
        peak_utilisation,
        atlas_utilisation,
    ) = wavecal.robust_refit(best_p, refine=False, robust_refit=True)