Exemplo n.º 1
0
def _make_example_pax_val_data():
    _, example_spectra, _ = simulate_pax.simulate_from_presets(
        5.0,
        "schlappa",
        "ag",
        1000,
        schlappa_performance.SCHLAPPA_PARAMETERS["energy_loss"],
    )
    return np.mean(example_spectra["y"], axis=0)
def _run_deconvolution_set(log10_num_electrons):
    parameters = pax_simulation_pipeline.DEFAULT_PARAMETERS
    impulse_response, pax_spectra, xray_xy = simulate_pax.simulate_from_presets(
        log10_num_electrons,
        "schlappa",
        "ag",
        parameters["simulations"],
        parameters["energy_loss"],
    )
    regularizer_widths = parameters["regularizer_widths"]
    iterations = 1e5
    results = Parallel(n_jobs=-1)(
        delayed(_run_single_deconvolution)(
            impulse_response, pax_spectra, xray_xy, regularizer_width, iterations
        )
        for regularizer_width in regularizer_widths
    )
    return results
Exemplo n.º 3
0
def _run_cv(log10_num_electrons, rixs, photoemission, regularization_strengths,
            parameters):
    impulse_response, pax_spectra, xray_xy = simulate_pax.simulate_from_presets(
        log10_num_electrons,
        rixs,
        photoemission,
        parameters["simulations"],
        parameters["energy_loss"],
    )
    deconvolver = deconvolvers.LRFisterGrid(
        impulse_response["x"],
        impulse_response["y"],
        pax_spectra["x"],
        parameters["regularizer_widths"],
        parameters["iterations"],
        xray_xy["y"],
        parameters["cv_fold"],
    )
    deconvolver.fit(np.array(pax_spectra["y"]))
    return deconvolver, pax_spectra
Exemplo n.º 4
0
def run_ana():
    """Run analysis to create data used in this plot
    """
    log10_num_electrons = 4.0
    rixs_model = "schlappa"
    photoemission_model = "ag"
    num_simulations = 100
    energy_loss = np.arange(-8, 10, 0.01)
    regularization_strengths = np.logspace(-3, -1, 10)
    iterations = 1000
    impulse_response, pax_spectra, xray_xy = simulate_pax.simulate_from_presets(
        log10_num_electrons,
        rixs_model,
        photoemission_model,
        num_simulations,
        energy_loss,
    )
    assess_convergence.run(
        impulse_response, pax_spectra, xray_xy, regularization_strengths, iterations
    )
Exemplo n.º 5
0
def _run_single_regularizer(log10_num_electrons, rixs, photoemission,
                            regularizer_width, parameters):
    """Run deconvolution for a single input regularization strength
    """
    impulse_response, pax_spectra, xray_xy = simulate_pax.simulate_from_presets(
        log10_num_electrons,
        rixs,
        photoemission,
        parameters["simulations"],
        parameters["energy_loss"],
    )
    deconvolver = deconvolvers.LRFisterDeconvolve(
        impulse_response["x"],
        impulse_response["y"],
        pax_spectra["x"],
        regularizer_width,
        iterations=parameters["iterations"],
        ground_truth_y=xray_xy["y"],
    )
    deconvolver.fit(np.array(pax_spectra["y"]))
    return deconvolver
def run_set(separation, log10_counts):
    deconvolved_list = []
    for i in range(NUM_SIMULATIONS):
        impulse_response, pax_spectra, xray_xy = simulate_pax.simulate_from_presets(
            log10_counts,
            ["i_doublet", separation],
            "fermi",
            1000,
            np.arange(-0.2, 0.4, 0.002),
        )
        deconvolver = deconvolvers.LRFisterGrid(
            impulse_response["x"],
            impulse_response["y"],
            pax_spectra["x"],
            np.logspace(-4, -2, 10),
            ITERATIONS,
            xray_xy["y"],
        )
        _ = deconvolver.fit(np.array(pax_spectra["y"]))
        deconvolved_list.append(deconvolver)
        print(
            f"Completed {str(log10_counts)} counts, {str(separation)} separation, {str(i)} iteration"
        )
    bootstrap_results = _run_bootstraps(
        impulse_response,
        pax_spectra,
        xray_xy,
        deconvolver.best_regularization_strength_,
    )
    to_save = {
        "deconvolved": deconvolved_list,
        "bootstraps": bootstrap_results,
        "ground_truth": xray_xy,
    }
    file_name = ("simulated_results/doublet2_" + str(separation) + "_" +
                 str(log10_counts) + ".pickle")
    with open(file_name, "wb") as f:
        pickle.dump(to_save, f)