conversion to new python3

This commit is contained in:
Markus Rosenstihl
2026-02-27 22:09:44 +01:00
parent 0b152b31fd
commit 29f003c99e
6 changed files with 78 additions and 73 deletions
+14 -13
View File
@@ -75,7 +75,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
for i in range(channels):
self.y.append(numpy.zeros((samples,), dtype="Int16"))
self.x = numpy.zeros((samples,), dtype="Float64")
self.x = numpy.zeros((samples,), dtype="float64")
self.index.append((0, samples-1))
self.cont_data = True
@@ -231,7 +231,8 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
if self.description is not None:
for (key,value) in self.description.items():
accu_group._v_attrs.__setattr__("description_"+key,str(value))
if key != None:
accu_group._v_attrs.__setattr__("description_"+key, str(value))
accu_group._v_attrs.__setattr__("sampling_rate",self.sampling_rate)
# save interval information
@@ -267,7 +268,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
# prepare saving data
channel_no=len(self.y)
timedata=numpy.empty((len(self.y[0]),channel_no),
dtype = "Int32")
dtype = "int16")
for ch in range(channel_no):
timedata[:,ch]=self.get_ydata(ch)
@@ -283,7 +284,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
time_slice_data=hdffile.create_carray(accu_group,
name="adc_data",
shape=timedata.shape,
atom=tables.Int32Atom(shape=chunkshape,
atom=tables.Int16Atom(shape=chunkshape,
flavor="numpy"),
filters=filter,
title="adc data")
@@ -292,7 +293,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
name="adc_data",
shape=timedata.shape,
chunkshape=chunkshape,
atom=tables.Int32Atom(),
atom=tables.Int16Atom(),
filters=filter,
title="adc data")
time_slice_data[:]=timedata
@@ -340,7 +341,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
tmp_y = []
for i in range(self.get_number_of_channels()):
tmp_y.append(numpy.array(self.y[i], dtype="Float64") + other)
tmp_y.append(numpy.array(self.y[i], dtype="float64") + other)
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
@@ -361,7 +362,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
tmp_y = []
for i in range(self.get_number_of_channels()):
tmp_y.append(numpy.array(self.y[i], dtype="Float64") - other)
tmp_y.append(numpy.array(self.y[i], dtype="float64") - other)
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
@@ -377,7 +378,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
tmp_y = []
for i in range(self.get_number_of_channels()):
tmp_y.append(other - numpy.array(self.y[i], dtype="Float64"))
tmp_y.append(other - numpy.array(self.y[i], dtype="float64"))
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
@@ -394,7 +395,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
tmp_y = []
for i in range(self.get_number_of_channels()):
tmp_y.append(numpy.array(self.y[i], dtype="Float64") * other)
tmp_y.append(numpy.array(self.y[i], dtype="float64") * other)
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
@@ -414,7 +415,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
tmp_y = []
for i in range(self.get_number_of_channels()):
tmp_y.append(numpy.array(self.y[i], dtype="Float64") ** other)
tmp_y.append(numpy.array(self.y[i], dtype="float64") ** other)
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
@@ -430,7 +431,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
tmp_y = []
for i in range(self.get_number_of_channels()):
tmp_y.append(numpy.array(self.y[i], dtype="Float64") / other)
tmp_y.append(numpy.array(self.y[i], dtype="float64") / other)
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
@@ -446,7 +447,7 @@ class ADC_Result(Resultable, Drawable, DamarisFFT, Signalpath):
tmp_y = []
for i in range(self.get_number_of_channels()):
tmp_y.append(other / numpy.array(self.y[i], dtype="Float64"))
tmp_y.append(other / numpy.array(self.y[i], dtype="float64"))
r = ADC_Result(x = self.x[:], y = tmp_y, index = self.index[:], sampl_freq = self.sampling_rate, desc = self.description, job_id = self.job_id, job_date = self.job_date)
self.lock.release()
@@ -516,7 +517,7 @@ def read_from_hdf(hdf_node):
# now do the real data
adc_data=hdf_node.adc_data.read()
adc.x=numpy.arange(adc_data.shape[0], dtype="Float64")/adc.sampling_rate
adc.x=numpy.arange(adc_data.shape[0], dtype="float64")/adc.sampling_rate
for ch in range(adc_data.shape[1]):
adc.y.append(adc_data[:,ch])