Skip to content
Snippets Groups Projects
Commit 80ef2d0d authored by Danilo Ferreira de Lima's avatar Danilo Ferreira de Lima
Browse files

Save plots as CSV for later replotting.

parent f1d5b5ab
No related branches found
No related tags found
1 merge request!13Allow for three model options: Ridge, ARD and BNN.
......@@ -16,6 +16,8 @@ from itertools import product
import matplotlib
matplotlib.use('Agg')
import pandas as pd
from copy import deepcopy
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
from mpl_toolkits.axes_grid1.inset_locator import InsetPosition
......@@ -102,12 +104,24 @@ def plot_result(filename: str,
intensity: The XGM intensity in uJ.
"""
fig = plt.figure(figsize=(12, 8))
gs = GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
unc_stat = spec_pred["unc"]
unc_pca = spec_pred["pca"]
unc = np.sqrt(unc_stat**2 + unc_pca**2)
df = pd.DataFrame(dict(energy=spec_raw_pe,
spec=spec_smooth,
prediction=spec_pred["expected"],
unc=unc,
beam_intensity=intensity*1e-3*np.ones_like(spec_raw_pe)
))
df.to_csv(filename.replace('.png', '.csv'))
pes_data = deepcopy(pes)
pes_data['bin'] = np.arange(len(pes['channel_1_D']))
df = pd.DataFrame(pes_data)
df.to_csv(filename.replace('.png', '_pes.csv'))
fig = plt.figure(figsize=(12, 8))
gs = GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
ax.plot(spec_raw_pe, spec_smooth, c='b', lw=3, label="High-res. measurement (smoothened)")
ax.plot(spec_raw_pe, spec_pred["expected"], c='r', ls='--', lw=3, label="High-res. prediction")
#ax.fill_between(spec_raw_pe, spec_pred["expected"] - unc, spec_pred["expected"] + unc, facecolor='green', alpha=0.6, label="68% unc.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment