Skip to content

Commit

Permalink
FIX: plot_wave was broken by new updates to ACT, this has been fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Jackson committed Jan 31, 2023
1 parent bc7d2fb commit d20c324
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/plot_read_sp2b.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
my_sp2 = pysp2.io.read_sp2(pysp2.testing.EXAMPLE_SP2B)
my_config = pysp2.io.read_config(pysp2.testing.EXAMPLE_INI)
my_sp2 = pysp2.util.gaussian_fit(my_sp2, my_config)
print(my_sp2)
pysp2.vis.plot_wave(my_sp2, 1100, 0)
plt.show()
18 changes: 15 additions & 3 deletions pysp2/vis/plot_wave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import act
import numpy as np
import xarray as xr

from ..util import _gaus

Expand Down Expand Up @@ -30,12 +31,23 @@ def plot_wave(ds, record_no, chn, plot_fit=True, init_kwargs=None, **kwargs):
Returns the ACT
"""
spectra = ds.isel(event_index=record_no)
time = spectra['time'].values
inp_data = {}
inp_data['time'] = xr.DataArray(np.array(time[np.newaxis]),
dims=['time'])
inp_data['Data_ch' + str(chn)] = xr.DataArray(
spectra['Data_ch' + str(chn)].values[np.newaxis, :],
dims=['time', 'bins'])
inp_data = xr.Dataset(inp_data)
bins = np.linspace(0, 100, 100)
if init_kwargs is None:
display = act.plotting.HistogramDisplay(spectra)
display = act.plotting.HistogramDisplay(inp_data)
else:
display = act.plotting.HistogramDisplay(spectra, **init_kwargs)
ax = display.plot_size_distribution('Data_ch' + str(chn), bins, set_title='Channel %d record %d' % (chn, record_no))
display = act.plotting.HistogramDisplay(inp_data, **init_kwargs)
ax = display.plot_size_distribution(
'Data_ch' + str(chn), bins,
set_title='Channel %d record %d' % (chn, record_no),
time=inp_data.time[0])

if plot_fit and chn in [0, 4]:
xspace = np.linspace(0, 100, 1000)
Expand Down

0 comments on commit d20c324

Please sign in to comment.