Skip to content

Commit

Permalink
Made some changes in the permissions of files and folders created by …
Browse files Browse the repository at this point in the history
…the scans

Now they all give access to the staff group (iss-staff)
  • Loading branch information
Bruno Luvizotto authored and estavitski committed Jan 5, 2017
1 parent eec9ae5 commit 1b4b779
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
9 changes: 7 additions & 2 deletions isstools/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,13 @@ def save_bin(self):
print('File Saved! [{}]'.format(filename[:-3] + 'dat'))

def calibrate_offset(self):
self.RE.md['angle_offset'] = self.RE.md['angle_offset'] + (xray.energy2encoder(float(self.edit_E0_2.text())) - xray.energy2encoder(float(self.edit_ECal.text())))/360000
self.label_angle_offset.setText('{0:.4f}'.format(self.RE.md['angle_offset']))
ret = self.questionMessage('Confirmation', 'Are you sure you would like to calibrate it?')
if not ret:
print ('[E0 Calibration] Aborted!')
return False
self.RE.md['angle_offset'] = str(float(self.RE.md['angle_offset']) + (xray.energy2encoder(float(self.edit_E0_2.text())) - xray.energy2encoder(float(self.edit_ECal.text())))/360000)
self.label_angle_offset.setText('{0:.4f}'.format(float(self.RE.md['angle_offset'])))
print ('[E0 Calibration] New value: {}\n[E0 Calibration] Completed!'.format(self.RE.md['angle_offset']))

def get_dic(self, module):
dic = dict()
Expand Down
40 changes: 33 additions & 7 deletions isstools/xasdata/xasdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
get_table, get_fields, restream, process)
from datetime import datetime
from isstools.conversions import xray
from subprocess import call

class XASdata:
def __init__(self, **kwargs):
Expand Down Expand Up @@ -37,7 +38,10 @@ def loadENCtrace(self, filename = '', filepath = '/GPFS/xf08id/pizza_box_data/')
with open(filepath + str(filename)) as f:
for line in f: # read rest of lines
current_line = line.split()
array_out.append([int(current_line[0])+1e-9*int(current_line[1]), int(current_line[2]), int(current_line[3])])
current_line[2] = int(current_line[2])
if current_line[2] > 0:
current_line[2] = -(current_line[2] ^ 0xffffff - 1)
array_out.append([int(current_line[0])+1e-9*int(current_line[1]), current_line[2], int(current_line[3])])
return np.array(array_out)

def loadTRIGtrace(self, filename = '', filepath = '/GPFS/xf08id/pizza_box_data/'):
Expand Down Expand Up @@ -161,14 +165,20 @@ def export_trace(self, filename, filepath = '/GPFS/xf08id/Sandbox/', uid = ''):
if(not uid):
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time, trajectory_name = '', '', '', '', '', '', '', '', '', '', ''
else:
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time, trajectory_name = db[uid]['start']['PI'], db[uid]['start']['PROPOSAL'], db[uid]['start']['SAF'], db[uid]['start']['comment'], db[uid]['start']['year'], db[uid]['start']['cycle'], db[uid]['start']['scan_id'], db[uid]['start']['uid'], db[uid]['start']['time'], db[uid]['stop']['time'], db[uid]['start']['trajectory_name']
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time = db[uid]['start']['PI'], db[uid]['start']['PROPOSAL'], db[uid]['start']['SAF'], db[uid]['start']['comment'], db[uid]['start']['year'], db[uid]['start']['cycle'], db[uid]['start']['scan_id'], db[uid]['start']['uid'], db[uid]['start']['time'], db[uid]['stop']['time']
human_start_time = str(datetime.fromtimestamp(start_time).strftime('%m/%d/%Y %H:%M:%S'))
human_stop_time = str(datetime.fromtimestamp(stop_time).strftime(' %m/%d/%Y %H:%M:%S'))
human_duration = str(datetime.fromtimestamp(stop_time - start_time).strftime('%M:%S'))
if hasattr(db[uid]['start'], 'trajectory_name'):
trajectory_name = db[uid]['start']['trajectory_name']
else:
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]]).transpose(), fmt='%17.6f %12.6f %f %f %f',
delimiter=" ", header = 'Timestamp (s) En. (eV) i0 (V) it(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])
return fn


Expand Down Expand Up @@ -320,14 +330,22 @@ def export_trace(self, filename, filepath = '/GPFS/xf08id/Sandbox/', uid = ''):
if(not uid):
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time, trajectory_name = '', '', '', '', '', '', '', '', '', '', ''
else:
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time, trajectory_name = db[uid]['start']['PI'], db[uid]['start']['PROPOSAL'], db[uid]['start']['SAF'], db[uid]['start']['comment'], db[uid]['start']['year'], db[uid]['start']['cycle'], db[uid]['start']['scan_id'], db[uid]['start']['uid'], db[uid]['start']['time'], db[uid]['stop']['time'], db[uid]['start']['trajectory_name']
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time = db[uid]['start']['PI'], db[uid]['start']['PROPOSAL'], db[uid]['start']['SAF'], db[uid]['start']['comment'], db[uid]['start']['year'], db[uid]['start']['cycle'], db[uid]['start']['scan_id'], db[uid]['start']['uid'], db[uid]['start']['time'], db[uid]['stop']['time']
human_start_time = str(datetime.fromtimestamp(start_time).strftime('%m/%d/%Y %H:%M:%S'))
human_stop_time = str(datetime.fromtimestamp(stop_time).strftime(' %m/%d/%Y %H:%M:%S'))
human_duration = str(datetime.fromtimestamp(stop_time - start_time).strftime('%M:%S'))

if hasattr(db[uid]['start'], 'trajectory_name'):
trajectory_name = db[uid]['start']['trajectory_name']
else:
trajectory_name = ''


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',
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])
return fn


Expand All @@ -344,21 +362,27 @@ def export_trace_xia(self, parsed_xia_array, filename, filepath = '/GPFS/xf08id/
if(not uid):
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time, trajectory_name = '', '', '', '', '', '', '', '', '', '', ''
else:
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time, trajectory_name = db[uid]['start']['PI'], db[uid]['start']['PROPOSAL'], db[uid]['start']['SAF'], db[uid]['start']['comment'], db[uid]['start']['year'], db[uid]['start']['cycle'], db[uid]['start']['scan_id'], db[uid]['start']['uid'], db[uid]['start']['time'], db[uid]['stop']['time'], db[uid]['start']['trajectory_name']
pi, proposal, saf, comment, year, cycle, scan_id, real_uid, start_time, stop_time = db[uid]['start']['PI'], db[uid]['start']['PROPOSAL'], db[uid]['start']['SAF'], db[uid]['start']['comment'], db[uid]['start']['year'], db[uid]['start']['cycle'], db[uid]['start']['scan_id'], db[uid]['start']['uid'], db[uid]['start']['time'], db[uid]['stop']['time']
human_start_time = str(datetime.fromtimestamp(start_time).strftime('%m/%d/%Y %H:%M:%S'))
human_stop_time = str(datetime.fromtimestamp(stop_time).strftime(' %m/%d/%Y %H:%M:%S'))
human_duration = str(datetime.fromtimestamp(stop_time - start_time).strftime('%M:%S'))

if hasattr(db[uid]['start'], 'trajectory_name'):
trajectory_name = db[uid]['start']['trajectory_name']
else:
trajectory_name = ''

np.savetxt(fn, np.array([self.energy_interp[:,0], self.energy_interp[:,1],
self.i0_interp[:,1], self.iflu_interp[:,1], parsed_xia_array]).transpose(), fmt='%17.6f %12.6f %f %f',
delimiter=" ", header = 'Timestamp (s) En. (eV) i0 (V) iflu(V) xia', 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])
return fn




def export_trig_trace(self, filename, filepath = '/GPFS/xf08id/Sandbox/'):
np.savetxt(filepath + filename + suffix, self.energy_interp[:,1], fmt='%f', delimiter=" ")
call(['setfacl', '-m', 'g:iss-staff:rwX', filepath + filename + suffix])
call(['chmod', '770', filepath + filename + suffix])


class XASDataManager:
Expand Down Expand Up @@ -521,6 +545,8 @@ def plot_der(self, plotting_dic = dict(), ax=plt, color='b'):
def export_dat(self, filename, header = ''):
filename = filename[0: len(filename) - 3] + 'dat'
np.savetxt(filename, np.array([self.en_grid, self.i0_interp, self.it_interp, self.ir_interp]).transpose(), fmt='%.7e %15.7e %15.7e %15.7e', comments = '', header = header)
call(['setfacl', '-m', 'g:iss-staff:rwX', filename])
call(['chmod', '770', filename])


def plot_orig(self, ax=plt, color='r'):
Expand Down

0 comments on commit 1b4b779

Please sign in to comment.