Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
dd3aa5a0d6
@ -14,17 +14,16 @@ class MeasurementSet(list):
|
|||||||
"""
|
"""
|
||||||
Group of measurements that have some correspondence to one another. Class
|
Group of measurements that have some correspondence to one another. Class
|
||||||
is used to operate on multiple measurements at once.
|
is used to operate on multiple measurements at once.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, mlist: List[Measurement] = []):
|
def __init__(self, mlist: List[Measurement] = []):
|
||||||
"""
|
"""
|
||||||
Initialize a measurement set
|
Initialize a measurement set
|
||||||
|
|
||||||
Args:
|
Arg:
|
||||||
mlist: Measurement list
|
mlist: Measurement list
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if any([not isinstance(i, Measurement) for i in mlist]):
|
if any([not isinstance(i, Measurement) for i in mlist]):
|
||||||
raise TypeError("Object in list should be of Measurement type")
|
raise TypeError("Object in list should be of Measurement type")
|
||||||
|
|
||||||
@ -33,11 +32,17 @@ class MeasurementSet(list):
|
|||||||
super().__init__(mlist)
|
super().__init__(mlist)
|
||||||
|
|
||||||
def getNewestReferenceMeasurement(self, mtype: MeasurementType):
|
def getNewestReferenceMeasurement(self, mtype: MeasurementType):
|
||||||
"""Return the newest (in time) measurement in the current list of a certain type. Returns None in case no measurement could be found.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
mtype (MeasurementType): The type required.
|
|
||||||
"""
|
"""
|
||||||
|
Get the NEWEST ref. measurement of a current type, in the current set.
|
||||||
|
|
||||||
|
Arg:
|
||||||
|
mtype (MeasurementType): The type required.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
- The newest (in time) measurement in the current list of a certain type.
|
||||||
|
- None, in case no measurement could be found.
|
||||||
|
"""
|
||||||
|
|
||||||
mnewest = None
|
mnewest = None
|
||||||
for m in self:
|
for m in self:
|
||||||
if m.measurementType() == mtype:
|
if m.measurementType() == mtype:
|
||||||
@ -49,19 +54,26 @@ class MeasurementSet(list):
|
|||||||
return mnewest
|
return mnewest
|
||||||
|
|
||||||
def getReferenceMeasurements(self, mtype: MeasurementType):
|
def getReferenceMeasurements(self, mtype: MeasurementType):
|
||||||
"""Get all available reference measurements of a certain type in the
|
"""Get ALL ref. measurements of a certain type, in the current set.
|
||||||
current set.
|
|
||||||
|
|
||||||
Args:
|
Arg:
|
||||||
mtype (MeasurementType): The type of which to list
|
mtype (MeasurementType): The type of which to list
|
||||||
|
|
||||||
Returns:
|
Return:
|
||||||
a new measurement set including all measurements of a certain type
|
A new measurement set, including all measurements of a certain type
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return [m for m in self if m.measurementType() == mtype]
|
return [m for m in self if m.measurementType() == mtype]
|
||||||
|
|
||||||
def getNewestReferenceMeasurements(self):
|
def getNewestReferenceMeasurements(self):
|
||||||
"""Returns a dictionary with newest measurement of each type that is not specific returns None in case no measurement is found."""
|
"""
|
||||||
|
Get the NEWEST ref. measurement of all types, in the current set.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
- A dictionary with the newest measurement of each type that is not specific
|
||||||
|
- None, in case no measurement is found.
|
||||||
|
"""
|
||||||
|
|
||||||
newest = {}
|
newest = {}
|
||||||
for m in self:
|
for m in self:
|
||||||
mtype = m.measurementType()
|
mtype = m.measurementType()
|
||||||
@ -75,8 +87,17 @@ class MeasurementSet(list):
|
|||||||
return newest
|
return newest
|
||||||
|
|
||||||
def newestReferenceOlderThan(self, secs):
|
def newestReferenceOlderThan(self, secs):
|
||||||
"""Returns a dictionary of references with the newest reference, that is still
|
"""
|
||||||
older than `secs` seconds."""
|
Get a dictionary of reference measurements which are older than a
|
||||||
|
specified threshold. Only one of each type is returned.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
- secs: time threshold, in seconds
|
||||||
|
|
||||||
|
Return:
|
||||||
|
- a dictionary of references with the newest reference, that is still
|
||||||
|
older than `secs` seconds
|
||||||
|
"""
|
||||||
curtime = time.time()
|
curtime = time.time()
|
||||||
newest = self.getNewestReferenceMeasurements()
|
newest = self.getNewestReferenceMeasurements()
|
||||||
newest_older_than = {}
|
newest_older_than = {}
|
||||||
@ -87,25 +108,29 @@ class MeasurementSet(list):
|
|||||||
|
|
||||||
def measTimeSame(self):
|
def measTimeSame(self):
|
||||||
"""
|
"""
|
||||||
Returns True if all measurements have the same measurement
|
Returns True if all measurements have the same measurement length and
|
||||||
time (recorded time)
|
sample rate
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(self) > 0:
|
if len(self) > 0:
|
||||||
first = self[0].N
|
firstN = self[0].N # samples
|
||||||
return all([first == meas.N for meas in self])
|
firstFS = self[0].samplerate # sample rate
|
||||||
|
sameN = all([firstN == meas.N for meas in self])
|
||||||
|
sameFS = all([firstFS == meas.samplerate for meas in self])
|
||||||
|
return sameN and sameFS
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def measSimilar(self):
|
def measSimilar(self):
|
||||||
"""
|
"""
|
||||||
Similar means: channel metadata is the same, and the measurement time
|
Similar means: channel metadata is the same, and the measurement time
|
||||||
is the same. It means that the recorded data is, of course, different.
|
is the same.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
True if measChannelsSame() and measTimeSame() else False
|
- True if measChannelsSame() and measTimeSame()
|
||||||
|
- False otherwise
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self.measTimeSame() and self.measChannelsSame()
|
return self.measTimeSame() and self.measChannelsSame()
|
||||||
|
|
||||||
def measChannelsSame(self):
|
def measChannelsSame(self):
|
||||||
@ -115,6 +140,7 @@ class MeasurementSet(list):
|
|||||||
a set of measurements, simultaneously. If the channel data is the same
|
a set of measurements, simultaneously. If the channel data is the same
|
||||||
(name, sensitivity, ...) it returns True.
|
(name, sensitivity, ...) it returns True.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(self) > 0:
|
if len(self) > 0:
|
||||||
first = self[0].channelConfig
|
first = self[0].channelConfig
|
||||||
return all([first == meas.channelConfig for meas in self])
|
return all([first == meas.channelConfig for meas in self])
|
||||||
|
Loading…
Reference in New Issue
Block a user