diff --git a/eos/projection.py b/eos/projection.py index 06afa18..530dd2a 100644 --- a/eos/projection.py +++ b/eos/projection.py @@ -663,6 +663,52 @@ class TofProjection(ProjectionInterface): """ self._graph[0].set_ydata(self.data.I.T) +class LProjection(ProjectionInterface): + lamda: np.ndarray + + data: np.recarray + _dtype = np.dtype([ + ('cts', np.float64), + ('I', np.float64), + ('err', np.float64), + ]) + + def __init__(self): + self.lamda = np.linspace(3.0, 12.0, 91) + self.data = np.zeros(self.lamda.shape[0]-1, dtype=self._dtype).view(np.recarray) + self.monitor = 0. + + def project(self, dataset: EventDatasetProtocol, monitor: float): + cts , *_ = np.histogram(dataset.data.events.lamda, bins=self.lamda) + self.data.cts += cts + self.monitor += monitor + + self.data.I = self.data.cts / self.monitor + self.data.err = np.sqrt(self.data.cts) / self.monitor + + def clear(self): + self.data[:] = 0 + self.monitor = 0. + + def plot(self, **kwargs): + from matplotlib import pyplot as plt + for key in ONLY_MAP: + if key in kwargs: del(kwargs[key]) + + + self._graph = plt.plot(self.lamda[:-1], self.data.I, **kwargs) + + plt.xlabel('Wavelength / Angstrom') + plt.ylabel('I / cpm') + plt.xlim(self.lamda[0], self.lamda[-1]) + plt.title('Wavelength') + + def update_plot(self): + """ + Inline update of previous plot by just updating the data. + """ + self._graph[0].set_ydata(self.data.I.T) + class CombinedProjection(ProjectionInterface): """ diff --git a/eos/reduction_e2h.py b/eos/reduction_e2h.py index 30e500a..6b34a97 100644 --- a/eos/reduction_e2h.py +++ b/eos/reduction_e2h.py @@ -19,7 +19,8 @@ from .normalization import LZNormalisation from .options import E2HConfig, E2HPlotArguments, IncidentAngle, MonitorType, E2HPlotSelection from . import event_handling as eh from .path_handling import PathResolver -from .projection import CombinedProjection, LZProjection, ProjectionInterface, ReflectivityProjector, TofProjection, \ +from .projection import CombinedProjection, LProjection, LZProjection, ProjectionInterface, ReflectivityProjector, \ + TofProjection, \ TofZProjection, \ YTProjection, YZProjection @@ -90,7 +91,9 @@ class E2HReduction: if self.config.reduction.plot in [E2HPlotSelection.All, E2HPlotSelection.LT, E2HPlotSelection.Q]: self.grid = LZGrid(0.01, [0.0, 0.25]) - if self.config.reduction.plot in [E2HPlotSelection.All, E2HPlotSelection.LT, E2HPlotSelection.YZ, E2HPlotSelection.YT]: + if self.config.reduction.plot in [E2HPlotSelection.All, E2HPlotSelection.LT, + E2HPlotSelection.YZ, E2HPlotSelection.YT, + E2HPlotSelection.TZ]: self.plot_kwds['colorbar'] = True self.plot_kwds['cmap'] = str(self.config.reduction.plot_colormap) if self.config.reduction.plotArgs==E2HPlotArguments.Linear: @@ -167,6 +170,9 @@ class E2HReduction: if self.config.reduction.plot==E2HPlotSelection.YT: self.projection = YTProjection(tthh) + if self.config.reduction.plot==E2HPlotSelection.L: + self.projection = LProjection() + if self.config.reduction.plot==E2HPlotSelection.TZ: self.projection = TofZProjection(last_file_header.timing.tau, foldback=not self.config.reduction.fast)