Skip to content

Commit

Permalink
[FIX] Fixed a few bugs related to the 4th channel added
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Luvizotto authored and estavitski committed Feb 13, 2017
1 parent 45e6a0b commit a29018b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
12 changes: 6 additions & 6 deletions isstools/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ def get_dic(self, module):
if(hasattr(module, 'data_ir')):
dic['original_numerator'] = module.data_ir
elif self.checkBox_num_if.checkState() > 0:
dic['numerator'] = module.if_interp
if(hasattr(module, 'data_if')):
dic['original_numerator'] = module.data_if
dic['numerator'] = module.iff_interp
if(hasattr(module, 'data_iff')):
dic['original_numerator'] = module.data_iff
elif self.checkBox_num_1.checkState() > 0:
if len(module.i0_interp.shape) > 1:
array_ones = np.copy(module.i0_interp)
Expand Down Expand Up @@ -313,9 +313,9 @@ def get_dic(self, module):
if(hasattr(module, 'data_ir')):
dic['original_denominator'] = module.data_ir
elif self.checkBox_den_if.checkState() > 0:
dic['denominator'] = module.if_interp
if(hasattr(module, 'data_if')):
dic['original_denominator'] = module.data_if
dic['denominator'] = module.iff_interp
if(hasattr(module, 'data_iff')):
dic['original_denominator'] = module.data_iff
elif self.checkBox_den_1.checkState() > 0:
if len(module.i0_interp.shape) > 1:
array_ones = np.copy(module.i0_interp)
Expand Down
13 changes: 8 additions & 5 deletions isstools/xasdata/xasdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ def loadINTERPtrace(self, filename):
array_energy.append(float(current_line[1]))
array_i0.append(float(current_line[2]))
array_it.append(float(current_line[3]))
array_it.append(float(current_line[3]))
if len(current_line) >= 5:
array_ir.append(float(current_line[4]))
if len(current_line) >= 6:
array_iff.append(float(current_line[5]))
self.header_read = self.read_header(filename)
ts, energy, i0, it, ir, iff = np.array(array_timestamp), np.array(array_energy), np.array(array_i0), np.array(array_it), np.array(array_ir), np.array(array_iff)

# Trying to make it compatible with old files (iff = [1, 1, ..., 1, 1]):
if not len(iff):
iff = np.ones(len(i0))
return np.concatenate(([ts], [energy])).transpose(), np.concatenate(([ts], [i0])).transpose(),np.concatenate(([ts], [it])).transpose(), np.concatenate(([ts], [ir])).transpose(), np.concatenate(([ts], [iff])).transpose()

def read_header(self, filename):
Expand Down Expand Up @@ -129,7 +132,7 @@ def loadInterpFile(self, filename):
self.i0_interp = self.i0_interp[len_to_erase:]
self.it_interp = self.it_interp[len_to_erase:]
self.ir_interp = self.ir_interp[len_to_erase:]
self.iff_interp = self.ir_interp[len_to_erase:]
self.iff_interp = self.iff_interp[len_to_erase:]

def interpolate(self):
min_timestamp = np.array([self.i0[0,0], self.it[0,0], self.ir[0,0], self.iff[0,0], self.encoder[0,0]]).max()
Expand Down Expand Up @@ -186,7 +189,7 @@ def export_trace(self, filename, filepath = '/GPFS/xf08id/Sandbox/', uid = ''):
trajectory_name = ''

np.savetxt(fn, np.array([self.energy_interp[:,0], self.energy_interp[:,1],
self.i0_interp[:,1], self.it_interp[:,1], self.ir_interp[:,1], self.iff_interp[:,1]]).transpose(), fmt='%17.6f %12.6f %f %f %f %f',
self.i0_interp[:,1], self.it_interp[:,1], self.ir_interp[:,1], self.iff_interp[:,1]]).transpose(), fmt='%17.6f %12.6f %10.6f %10.6f %10.6f %10.6f',
delimiter=" ", header = 'Timestamp (s) En. (eV) i0 (V) it(V) ir(V) iff(V)', comments = '# Year: {}\n# Cycle: {}\n# SAF: {}\n# PI: {}\n# PROPOSAL: {}\n# Scan ID: {}\n# UID: {}\n# Trajectory name: {}\n# Start time: {}\n# Stop time: {}\n# Total time: {}\n#\n# '.format(year, cycle, saf, pi, proposal, scan_id, real_uid, trajectory_name, human_start_time, human_stop_time, human_duration))
call(['setfacl', '-m', 'g:iss-staff:rwX', fn])
call(['chmod', '770', fn])
Expand Down Expand Up @@ -355,7 +358,7 @@ def export_trace(self, filename, filepath = '/GPFS/xf08id/Sandbox/', uid = ''):


np.savetxt(fn, np.array([self.energy_interp[:,0], self.energy_interp[:,1],
self.i0_interp[:,1], self.iflu_interp[:,1], self.ir_interp[:,1]]).transpose(), fmt='%17.6f %12.6f %f %f %f',
self.i0_interp[:,1], self.iflu_interp[:,1], self.ir_interp[:,1]]).transpose(), fmt='%17.6f %12.6f %10.6f %10.6f %10.6f',
delimiter=" ", header = 'Timestamp (s) En. (eV) i0 (V) iflu(V) ir(V)', comments = '# Year: {}\n# Cycle: {}\n# SAF: {}\n# PI: {}\n# PROPOSAL: {}\n# Scan ID: {}\n# UID: {}\n# Trajectory name: {}\n# Start time: {}\n# Stop time: {}\n# Total time: {}\n#\n# '.format(year, cycle, saf, pi, proposal, scan_id, real_uid, trajectory_name, human_start_time, human_stop_time, human_duration))
call(['setfacl', '-m', 'g:iss-staff:rwX', fn])
call(['chmod', '770', fn])
Expand Down Expand Up @@ -605,7 +608,7 @@ def process_equal(self, timestamp, energy, i0, it, ir, iff, delta_en = 2):
self.matrix = np.array([timestamp, energy, i0, it, ir, iff]).transpose()
self.sorted_matrix = self.sort_data(self.matrix, 1)
self.en_grid = self.energy_grid_equal(self.sorted_matrix[:, 1], delta_en)
self.data_en, self.data_i0, self.data_it, self.data_ir = self.average_points(self.sorted_matrix[:, 1], self.sorted_matrix[:, 2], self.sorted_matrix[:, 3], self.sorted_matrix[:, 4], self.sorted_matrix[:, 5])
self.data_en, self.data_i0, self.data_it, self.data_ir, self.data_iff = self.average_points(self.sorted_matrix[:, 1], self.sorted_matrix[:, 2], self.sorted_matrix[:, 3], self.sorted_matrix[:, 4], self.sorted_matrix[:, 5])
self.i0_interp = self.bin(self.en_grid, self.data_en, self.data_i0)
self.it_interp = self.bin(self.en_grid, self.data_en, self.data_it)
self.ir_interp = self.bin(self.en_grid, self.data_en, self.data_ir)
Expand Down

0 comments on commit a29018b

Please sign in to comment.