Skip to content
Snippets Groups Projects
Commit 71a6a3f3 authored by Philipp Niedermayer's avatar Philipp Niedermayer
Browse files

Add data backup methods

parent 5e56ef0d
No related branches found
No related tags found
No related merge requests found
......@@ -199,11 +199,18 @@ class TDCSpill:
def __repr__(self):
return f'TDCSpill({self.detector}, length={self.length:g}s, counts={self.counts})'
def to_file(self, fname):
"""Save the spill to a file in compressed npz format
"""
np.savez_compressed(fname, header=self.header, data=self.data, time_offset=self.time_offset)
@classmethod
def from_file(self, fname):
"""Load the spill from a file in compressed npz format
"""
if not fname.endswith(".npz"): raise ValueError("fname must be a *.npz file. To load *.dat files, use TDCData.from_file(...) instead.")
with np.load(fname) as f:
return TDCSpill(f['header'], f['data'], f['time_offset'].item())
@dataclass
......
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