Commit 032e990e authored by Lorenz Halt's avatar Lorenz Halt 🔀
Browse files

fix stupid errors

parent 857b4e77
......@@ -7,7 +7,7 @@ import copy
def _new_file_name(folder, name, i):
return os.path.join(
folder,
folder,
"{}_{}{}".format(os.path.splitext(name)[0], # name
i, # numbering
os.path.splitext(name)[1])) # extension
......@@ -30,7 +30,7 @@ def external_data_store(data_folder, data_name, data, header):
def resample(data, delta_ms):
ticks = np.arange(0, data[-1, 0] + delta_ms, delta_ms) # Array of wanted sampling times
resampled_data = ticks # initialize result with sampling times in first row (!)
for row in data[:, 1:].T: # interate over all columns (but transposed, thus rows)
resampled_row = np.interp(ticks, data[:, 0], row)
......@@ -43,19 +43,19 @@ def write(file, data, header):
# Test if header fits
if not len(header.split(',')) == data.shape[1]:
raise ValueError("header and data does not fit!\nheader: '{}'\ndata[0]: '{}'".format(header, data[0,:]))
np.savetxt(file, data,
np.savetxt(file, data,
fmt='%i'+(',' +'%f')*(data.shape[1]-1),
header = header,
comments = "",
comments = "",
delimiter =",")
def read(file):
print("Reading from file: '%s'"%(file))
with open(file, 'r') as f:
header_str = f.readline().strip()
data = np.genfromtxt(file,
delimiter=',',
data = np.genfromtxt(file,
delimiter=',',
autostrip=True,
skip_header=1)
return data, header_str
......@@ -78,7 +78,7 @@ def traj_handle(data, traj_type, decay_time=None):
else:
print("Unknown reference shape: '{}'".format(traj_type))
ref = [ 0 for t in data[:,0] ]
trajectory = data[:, 0]
for row in data[:, 1:].T: # interate over all columns (but transposed, thus rows)
traj_row = np.array(ref) * row[0]
......@@ -98,7 +98,7 @@ def combine_data(data1, data2, op):
data_out = np.subtract(data1, data2)
else:
raise ValueError("Operation op={} unknown".format(op))
data_out[:,0] = data1[:,0] # Restore timestamp
return data_out
......
......@@ -52,7 +52,7 @@ class Ilc_serviceproxy:
# Reshape last feedforward if wanted
if self.reshape:
last_ff = self.reshape_ff(self.last_decay_time, last_ff, self.decay_time)
last_ff = self.reshape_ff(last_ff, self.last_decay_time, self.decay_time)
self.reshape = False
data_ff, last_ff = ilc_lib.pad_data(data_ff, last_ff)
......@@ -87,7 +87,7 @@ class Ilc_serviceproxy:
self.decay_time = req.setpoint_duration_ms
self.initialized = req.reuse_ff
if req.retime_scheme != 0:
if req.reuse_scheme != 0:
self.reshape = True
print("Retiming Service received:\n{}".format(req))
......@@ -102,12 +102,12 @@ class Ilc_serviceproxy:
#print("Retiming Service received:\n{}".format(req))
try:
if (np.max(ilc_lib.error_convergence(self.data_diff)) < req.convergence_threshold):
print("Reducing trajectory time to {self.decay_time}")
print("Reducing trajectory time to {}".format(self.decay_time))
self.last_decay_time = self.decay_time
self.decay_time = self.decay_time * req.retime_factor
self.initialized = req.reuse_ff
if req.retime_scheme != 0:
if req.reuse_scheme != 0:
self.reshape = True
return RetimeIfILCResponse(success=True, message="reshaped")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment