@@ -183,7 +183,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
|
|||||||
for i in range(self.get_number_of_channels()):
|
for i in range(self.get_number_of_channels()):
|
||||||
tmp_y.append(self.y[i][start:end+1].copy())
|
tmp_y.append(self.y[i][start:end+1].copy())
|
||||||
|
|
||||||
r = ADC_Result(x = tmp_x, y = tmp_y, index = [(0,len(tmp_y[0])-1)], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
|
r = ADC_Result(x = tmp_x, y = tmp_y, index = [(0,len(tmp_y[0])-1)], sampl_freq = self.sampling_rate, desc = self.description.copy() if self.description is not None else None, job_id = self.job_id, job_date = self.job_date)
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|||||||
@@ -118,9 +118,23 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
|
|||||||
tmp_y.append(self.y[i][start:end+1])
|
tmp_y.append(self.y[i][start:end+1])
|
||||||
|
|
||||||
r = Accumulation(x = tmp_x, y = tmp_y, n = self.n, index = [(0,len(tmp_y[0])-1)], sampl_freq = self.sampling_rate, error = self.use_error)
|
r = Accumulation(x = tmp_x, y = tmp_y, n = self.n, index = [(0,len(tmp_y[0])-1)], sampl_freq = self.sampling_rate, error = self.use_error)
|
||||||
|
if self.uses_statistics():
|
||||||
|
r.y_square = []
|
||||||
|
for i in range(self.get_number_of_channels()):
|
||||||
|
r.y_square.append(self.y_square[i][start:end+1])
|
||||||
|
if self.common_descriptions is not None:
|
||||||
|
r.common_descriptions = self.common_descriptions.copy()
|
||||||
|
r.time_period = self.time_period[:]
|
||||||
|
r.job_ids = self.job_ids.copy()
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def get_result_by_index(self, index):
|
||||||
|
return self.get_accu_by_index(index)
|
||||||
|
|
||||||
|
def get_Result_by_index(self, index):
|
||||||
|
return self.get_accu_by_index(index)
|
||||||
|
|
||||||
def get_ysquare(self, channel):
|
def get_ysquare(self, channel):
|
||||||
if self.uses_statistics():
|
if self.uses_statistics():
|
||||||
try:
|
try:
|
||||||
@@ -1032,10 +1046,10 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
|
|||||||
self.set_title(self.__title_pattern % self.n)
|
self.set_title(self.__title_pattern % self.n)
|
||||||
if hasattr(other, "is_clipped"):
|
if hasattr(other, "is_clipped"):
|
||||||
self.is_clipped = other.is_clipped
|
self.is_clipped = other.is_clipped
|
||||||
self.common_descriptions=other.common_desriptions.copy()
|
self.common_descriptions=other.common_descriptions.copy()
|
||||||
self.time_period=other.time_period[:]
|
self.time_period=other.time_period[:]
|
||||||
self.job_id = other.job_id # added by Oleg Petrov
|
self.job_id = other.job_id # added by Oleg Petrov
|
||||||
self.job_ids += other.job_ids
|
self.job_ids.update(other.job_ids)
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -1066,6 +1080,7 @@ class Accumulation(Errorable, Drawable, DamarisFFT, Signalpath):
|
|||||||
self.time_period=[min(self.time_period[0],other.time_period[0]),
|
self.time_period=[min(self.time_period[0],other.time_period[0]),
|
||||||
max(self.time_period[1],other.time_period[1])]
|
max(self.time_period[1],other.time_period[1])]
|
||||||
self.job_id = other.job_id
|
self.job_id = other.job_id
|
||||||
|
self.job_ids.update(other.job_ids)
|
||||||
# Removes mismatched common description keys
|
# Removes mismatched common description keys
|
||||||
if self.common_descriptions is not None and other.common_descriptions is not None:
|
if self.common_descriptions is not None and other.common_descriptions is not None:
|
||||||
# Get all keys that exist in both dictionaries
|
# Get all keys that exist in both dictionaries
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ def result():
|
|||||||
print("h5 already opened")
|
print("h5 already opened")
|
||||||
accu = Accumulation(error=False)
|
accu = Accumulation(error=False)
|
||||||
for num,ts in enumerate(results):
|
for num,ts in enumerate(results):
|
||||||
x = numpy.linspace(0, 1, 10)
|
|
||||||
y1 = [numpy.array([0, 4000, 8190, 8191, 8192, 0, -8191, -8192, -8193, 0], dtype="int16")]
|
|
||||||
|
|
||||||
# Test with default (14-bit)
|
|
||||||
adc1 = ADC_Result(x=x, y=y1, index=[(0,9)], sampl_freq=1000, desc={}, job_id=1, job_date=0)
|
|
||||||
accu.is_clipped = True
|
|
||||||
data["accu"] = accu
|
data["accu"] = accu
|
||||||
data["data/ts %i"%num] = ts+0
|
data["data/ts %i"%num] = ts+0
|
||||||
ts.write_to_hdf(h5, "/", f"adc_{num}", f"adc_{num}")
|
ts.write_to_hdf(h5, "/", f"adc_{num}", f"adc_{num}")
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class TestAccumulation(unittest.TestCase):
|
|||||||
self.assertTrue(np.array_equal(sub_result.y[0], np.array([20, 30])))
|
self.assertTrue(np.array_equal(sub_result.y[0], np.array([20, 30])))
|
||||||
self.assertTrue(np.array_equal(sub_result.y[1], np.array([25, 35])))
|
self.assertTrue(np.array_equal(sub_result.y[1], np.array([25, 35])))
|
||||||
self.assertEqual(sub_result.index, [(0, 1)])
|
self.assertEqual(sub_result.index, [(0, 1)])
|
||||||
# TODO Fix #13: self.assertEqual(sub_result.common_descriptions, {"key": "value"})
|
self.assertEqual(sub_result.common_descriptions, {"key": "value"})
|
||||||
|
|
||||||
def test_write_to_csv_without_error(self):
|
def test_write_to_csv_without_error(self):
|
||||||
"""Test the functionality of writing to CSV."""
|
"""Test the functionality of writing to CSV."""
|
||||||
|
|||||||
Reference in New Issue
Block a user