diff options
Diffstat (limited to 'qolab')
-rw-r--r-- | qolab/data/trace.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/qolab/data/trace.py b/qolab/data/trace.py index f6c6e68..4c42cd0 100644 --- a/qolab/data/trace.py +++ b/qolab/data/trace.py @@ -16,11 +16,15 @@ class Trace: self.config['label'] = label self.config['unit'] = None self.config['tags'] = {} + self.item_format='.15e' self.values = np.empty(0) self.clear_data() - def clear_data(self): + def clear_last_saved_pos(self): self.last_saved_pos = 0 + + def clear_data(self): + self.clear_last_saved_pos() if self.values is not None: self.values = np.empty(0, dtype=self.values.dtype) @@ -41,13 +45,13 @@ class Trace: def getHeader(self, prefix=''): return headerFronDictionary(self.getConfig(), prefix='') - def save(self, fname, item_format='e', last_saved_pos=None, skip_headers_if_file_exist=False, **kwargs): + def save(self, fname, last_saved_pos=None, skip_headers_if_file_exist=False, **kwargs): if last_saved_pos is None: last_saved_pos = self.last_saved_pos data = self.getData() if last_saved_pos > 0: skip_headers_if_file_exist=True - fname = save_table_with_header(fname, data[last_saved_pos:,:], self.getHeader(), item_format=item_format, skip_headers_if_file_exist=skip_headers_if_file_exist, **kwargs) + fname = save_table_with_header(fname, data[last_saved_pos:,:], self.getHeader(), item_format=self.item_format, skip_headers_if_file_exist=skip_headers_if_file_exist, **kwargs) self.last_saved_pos = data.shape[0] return(fname) @@ -59,13 +63,14 @@ class TraceXY(Trace): def __init__(self, label): self.config = {} self.config['label'] = label + self.item_format='.15e' self.config['tags'] = {} self.x = None self.y = None self.clear_data() def clear_data(self): - self.last_saved_pos = 0 + self.clear_last_saved_pos() if self.x is not None: self.x.clear_data() if self.y is not None: @@ -106,13 +111,14 @@ class TraceSetSameX(Trace): def __init__(self, label): self.config = {} self.config['label'] = label + self.item_format='.15e' self.config['tags'] = {} self.x = None self.traces={} self.clear_data() def clear_data(self): - self.last_saved_pos = 0 + self.clear_last_saved_pos() if self.x is not None: self.x.clear_data() for k, tr in self.traces.items(): |