Cached time string of measurement time stamp
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bdef0b45f3
commit
f1348ede80
@ -52,6 +52,7 @@ import os, time, wave, logging
|
||||
from .lasp_common import SIQtys, Qty, getFreq
|
||||
from .lasp_cpp import Window, DaqChannel, LASP_VERSION_MAJOR, AvPowerSpectra
|
||||
from typing import List
|
||||
from functools import lru_cache
|
||||
|
||||
|
||||
def getSampWidth(dtype):
|
||||
@ -248,6 +249,9 @@ class Measurement:
|
||||
except KeyError:
|
||||
self._sens = np.ones(self.nchannels)
|
||||
|
||||
# The time is cached AND ALWAYS ASSUMED TO BE AN IMMUTABLE OBJECT.
|
||||
# It is also cached. Changing the measurement timestamp should not
|
||||
# be done.
|
||||
self._time = f.attrs['time']
|
||||
|
||||
# Quantity stored as channel.
|
||||
@ -375,6 +379,7 @@ class Measurement:
|
||||
self._comment = cmt
|
||||
|
||||
@property
|
||||
@lru_cache()
|
||||
def recTime(self):
|
||||
"""Returns the total recording time of the measurement, in float
|
||||
seconds."""
|
||||
@ -385,6 +390,19 @@ class Measurement:
|
||||
"""Returns the measurement time in seconds since the epoch."""
|
||||
return self._time
|
||||
|
||||
@property
|
||||
@lru_cache()
|
||||
def timestr(self):
|
||||
"""
|
||||
Return a properly formatted string of the measurement time, in order of
|
||||
|
||||
year-month-day hour etc.
|
||||
|
||||
"""
|
||||
time_struct = time.localtime(self.time)
|
||||
time_string = time.strftime('%Y-%m-%d %H:%M:%S', time_struct)
|
||||
return time_string
|
||||
|
||||
def rms(self, channels=None, substract_average=False):
|
||||
"""Returns the root mean square values for each channel
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user