diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-18 18:45:14 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-18 18:45:14 -0500 |
commit | c28b041949f96b5391a1f64238b38ca7c2a0c4f6 (patch) | |
tree | a8f0f3c3a7bb37b694cef67f5b18dbc4cc936e7f /qolab/data | |
parent | ba24e4d63f67f7edc151b0e185a5b7eac17d2e16 (diff) | |
download | qolab-c28b041949f96b5391a1f64238b38ca7c2a0c4f6.tar.gz qolab-c28b041949f96b5391a1f64238b38ca7c2a0c4f6.zip |
clearing last position and setting default item_format
Diffstat (limited to 'qolab/data')
-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(): |