Beispiel #1
0
def sdds_to_dict(in_complete_path):
    us_string = in_complete_path.split('.')[-2]

    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file.'
        return
    data = temp.data[0]

    cycleTime = data['cycleTime'].tostring()
    t_stamp_unix = time.mktime(
        time.strptime(
            cycleTime.replace('"', '').replace('\n', '').split('.')[0],
            '%Y/%m/%d %H:%M:%S'))

    beamID = np.int_(data['beamID'])
    deviceName = (data['deviceName'].tostring()).split('\n')[0]
    acqState = np.int_(data['acqState'])
    totalIntensity = data['totalIntensity']
    acqTime = data['acqTime'].tostring()
    propType = np.int_(data['propType'])
    totalIntensity_unitExponent = np.int_(data['totalIntensity_unitExponent'])
    bunchIntensitySlow = data['bunchIntensitySlow']
    bunchIntensityFast = data['bunchIntensityFast']
    gateIntensity_unitExponent = np.int_(data['gateIntensity_unitExponent'])
    nbOfMeas = np.int_(data['nbOfMeas'])
    totalIntensityFast = data['totalIntensityFast']
    superCycleNb = np.int_(data['superCycleNb'])
    acqMsg = data['acqMsg'].tostring()
    measStamp = data['measStamp']
    acqDesc = data['acqDesc'].tostring()
    observables = np.int_(data['observables'])
    totalIntensity_unit = np.int_(data['totalIntensity_unit'])

    dict_meas = {
        'beamID': beamID,
        'deviceName': deviceName,
        'acqState': acqState,
        'totalIntensity': totalIntensity,
        'acqTime': acqTime,
        'propType': propType,
        'totalIntensity_unitExponent': totalIntensity_unitExponent,
        'bunchIntensitySlow': bunchIntensitySlow,
        'bunchIntensityFast': bunchIntensityFast,
        'gateIntensity_unitExponent': gateIntensity_unitExponent,
        'nbOfMeas': nbOfMeas,
        'totalIntensityFast': totalIntensityFast,
        'superCycleNb': superCycleNb,
        'cycleTime': cycleTime,
        'acqMsg': acqMsg,
        'measStamp': measStamp,
        'acqDesc': acqDesc,
        'observables': observables,
        'totalIntensity_unit': totalIntensity_unit,
        'SPSuser': us_string,
        't_stamp_unix': t_stamp_unix
    }

    return dict_meas
Beispiel #2
0
def sdds_to_dict(in_complete_path):
	us_string = in_complete_path.split('.')[-3]
	t_stamp_unix = float(in_complete_path.split('@')[-2])/1e9+1

	zfile = zipfile.ZipFile(in_complete_path)
	filename = zfile.namelist()[0]
	zfile.extract(filename)

	try:
		temp = sddsdata(filename, endian='little', full=True)
	except IndexError:
		print 'Failed to open data file. (save_blmexpert_mat)'
		return
	os.remove(filename)
	data = temp.data[0]

	dict_meas = {
		'totalLoss': data['totalLoss'],
		'cal2DLosses': data['cal2DLosses'],
		'nbOfChannels': data['nbOfChannels'],
		'measStamp': data['measStamp'],
		'nbOfMeas': data['nbOfMeas'],
		'superCycleNb': data['superCycleNb'],
		'channelNames': data['channelNames'],
		'SPSuser':us_string,
		't_stamp_unix':t_stamp_unix
			}	
	return dict_meas
Beispiel #3
0
def sdds_to_dict(in_complete_path):
    us_string = in_complete_path.split('.')[-3]
    t_stamp_unix = float(in_complete_path.split('@')[-2]) / 1e9 + 1

    zfile = zipfile.ZipFile(in_complete_path)
    filename = zfile.namelist()[0]
    zfile.extract(filename)

    try:
        temp = sddsdata(filename, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file. (save_blmexpert_mat)'
        return
    os.remove(filename)
    data = temp.data[0]

    dict_meas = {
        'totalLoss': data['totalLoss'],
        'cal2DLosses': data['cal2DLosses'],
        'nbOfChannels': data['nbOfChannels'],
        'measStamp': data['measStamp'],
        'nbOfMeas': data['nbOfMeas'],
        'superCycleNb': data['superCycleNb'],
        'channelNames': data['channelNames'],
        'SPSuser': us_string,
        't_stamp_unix': t_stamp_unix
    }
    return dict_meas
Beispiel #4
0
def sdds_to_dict(in_complete_path):
	us_string = in_complete_path.split('.')[-2]

	try:
		temp = sddsdata(in_complete_path, endian='little', full=True)
	except IndexError:
		print 'Failed to open data file. (save_bct_mat)'
		return
	data = temp.data[0]

	cycleTime = data['cycleTime'].tostring()
	t_stamp_unix = time.mktime(time.strptime(cycleTime.replace('"', '').replace('\n','').split('.')[0], '%Y/%m/%d %H:%M:%S'))

	beamID = np.int_(data['beamID'])
	deviceName = ((data['deviceName'].tostring()).split('\n')[0]).split('SPS.')[-1]
	sbfIntensity = np.float_(data['sbfIntensity'])
	acqState = np.int_(data['acqState'])
	totalIntensity = data['totalIntensity']
	acqTime = data['acqTime'].tostring()
	propType = np.int_(data['propType'])
	totalIntensity_unitExponent = np.int_(data['totalIntensity_unitExponent'])
	measStamp_unitExponent = np.float_(data['measStamp_unitExponent'])
	samplingTime = np.int_(data['samplingTime'])
	measStamp_unit = np.int_(data['measStamp_unit'])
	observables = np.int_(data['observables'])
	nbOfMeas = np.int_(data['nbOfMeas'])
	superCycleNb = np.int_(data['superCycleNb'])
	acqMsg = data['acqMsg'].tostring()
	measStamp = data['measStamp']
	acqDesc = data['acqDesc'].tostring()
	totalIntensity_unit = np.int_(data['totalIntensity_unit'])

	dict_meas = {
		'beamID':beamID,
		'deviceName':deviceName,
		'sbfIntensity':sbfIntensity,
		'acqState':acqState,
		'totalIntensity':totalIntensity,
		'acqTime':acqTime,
		'propType':propType,
		'totalIntensity_unitExponent':totalIntensity_unitExponent,
		'measStamp_unitExponent':measStamp_unitExponent,
		'samplingTime':samplingTime,
		'measStamp_unit':measStamp_unit,
		'observables':observables,
		'nbOfMeas':nbOfMeas,
		'superCycleNb':superCycleNb,
		'cycleTime':cycleTime,
		'acqMsg':acqMsg,
		'measStamp':measStamp,
		'acqDesc':acqDesc,
		'totalIntensity_unit':totalIntensity_unit,
		'SPSuser':us_string,
		't_stamp_unix':t_stamp_unix
			}

	return dict_meas
Beispiel #5
0
def sdds_to_dict(in_complete_path):

    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file. (save_bct_mat)'
        return
    data = temp.data[0]

    acq_comment = data['ACQ-COMMENT'].tostring()
    cycle_length = np.float_(data['CYCLE-LENGTH'])
    date = data['DATE'].tostring()
    device_name = data['DEVICE-NAME'].tostring()
    number_profiles = np.int_(data['NUMBER-PROFILES'])
    number_strips = np.int_(data['NUMBER-STRIPS'])
    profile_cycle_time = np.float_(data['PROFILE-CYCLE-TIME']) / 1e3
    sc_number = np.int_(data['SC-NUMBER'])
    time = data['TIME'].tostring()
    timestamp_millisecond = np.int_(data['TIMESTAMP-MILLISECOND'])
    timestamp_second = np.int_(data['TIMESTAMP-SECOND'])
    timing_user = data['TIMING-USER'].tostring()
    total_gain = data['TOTAL-GAIN']

    eclm_data = np.zeros((number_profiles, number_strips))
    for ii in range(number_profiles):
        key_string = 'SEM-PROFILE-%d' % (ii + 1)
        eclm_data[ii, :] = data[key_string]

    device_name = in_complete_path.split('-')[0].split('/')[-1]
    us_string = in_complete_path.split('-')[1].split('.')[-1]

    dict_meas = {
        'ACQ_COMMENT': acq_comment,
        'DATE': date,
        'DEVICE_NAME': device_name,
        'NUMBER_PROFILES': number_profiles,
        'NUMBER_STRIPS': number_strips,
        'PROFILE_CYCLE_TIME': profile_cycle_time,
        'SC_NUMBER': sc_number,
        'TIME': time,
        'TIMESTAMP_MILLISECOND': timestamp_millisecond,
        'TIMESTAMP_SECOND': timestamp_second,
        'TIMING_USER': timing_user,
        'TOTAL_GAIN': total_gain,
        'eclm_data': eclm_data,
        'device_name': device_name,
        'SPSuser': us_string
    }

    return dict_meas
Beispiel #6
0
def sdds_to_dict(in_complete_path):
	
    try:
	    temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
	    print 'Failed to open data file. (save_bct_mat)'
	    return
    data = temp.data[0]

    acq_comment = data['ACQ-COMMENT'].tostring()
    cycle_length = np.float_(data['CYCLE-LENGTH'])
    date = data['DATE'].tostring()
    device_name = data['DEVICE-NAME'].tostring()
    number_profiles = np.int_(data['NUMBER-PROFILES'])
    number_strips = np.int_(data['NUMBER-STRIPS'])
    profile_cycle_time = np.float_(data['PROFILE-CYCLE-TIME']) / 1e3
    sc_number = np.int_(data['SC-NUMBER'])
    time = data['TIME'].tostring()
    timestamp_millisecond = np.int_(data['TIMESTAMP-MILLISECOND'])
    timestamp_second = np.int_(data['TIMESTAMP-SECOND'])
    timing_user = data['TIMING-USER'].tostring()
    total_gain = data['TOTAL-GAIN']

    eclm_data = np.zeros((number_profiles, number_strips))
    for ii in range(number_profiles):
        key_string = 'SEM-PROFILE-%d'%(ii+1)
        eclm_data[ii,:] = data[key_string]

    device_name = in_complete_path.split('-')[0].split('/')[-1]
    us_string = in_complete_path.split('-')[1].split('.')[-1]

    dict_meas =  {
    'ACQ_COMMENT':acq_comment,
    'DATE':date,
    'DEVICE_NAME':device_name,
    'NUMBER_PROFILES':number_profiles,
    'NUMBER_STRIPS':number_strips,
    'PROFILE_CYCLE_TIME':profile_cycle_time,
    'SC_NUMBER':sc_number,
    'TIME':time,
    'TIMESTAMP_MILLISECOND':timestamp_millisecond,
    'TIMESTAMP_SECOND':timestamp_second,
    'TIMING_USER':timing_user,
    'TOTAL_GAIN':total_gain,
    'eclm_data':eclm_data,
    'device_name':device_name,
    'SPSuser':us_string
    }

    return dict_meas
Beispiel #7
0
def sdds_to_dict(in_complete_path):
    us_string = in_complete_path.split('.')[-2]

    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file. (save_multit_mat)'
        return
    data = temp.data[0]
    nbOfMonitors = float(data['nbOfMonitors'])
    BunchNos = np.float_(data['BunchNos'])
    ChannelNames = data['ChannelNames']
    MonStatus = np.float_(data['MonStatus'])
    startTime = float(data['startTime'])
    date = data['date'].tostring()
    nbOfTurns = float(data['nbOfTurns'])
    TurnNos = np.float_(data['TurnNos'])
    scNumber = float(data['scNumber'])
    SPSuser = data['user'].tostring().split('\n')[0]
    acqComment = data['acqComment'].tostring()
    MonPlanes = np.float_(data['MonPlanes'])
    MonNames = data['MonNames']
    Time = data['time'].tostring()

    t_stamp_unix = float(
        data['timestampSecond']) + float(data['timestampMilliSecond']) * 1e-3

    dict_meas = {\
     'BunchNos': BunchNos,
     'ChannelNames': ChannelNames,
     'MonStatus': MonStatus,
     'startTime': startTime,
     'date': date,
     'nbOfTurns': nbOfTurns,
     'TurnNos': TurnNos,
     'scNumber': scNumber,
     'SPSuser': SPSuser,
     'acqComment': acqComment,
     'MonPlanes': MonPlanes,
     'nbOfMonitors': nbOfMonitors,
     'MonNames': MonNames,
     'Time': Time,
     't_stamp_unix': t_stamp_unix\
    }

    for channel in ChannelNames:
        dict_meas[channel] = np.float_(data[channel])
        dict_meas[channel + '-SUM'] = np.float_(data[channel + '-SUM'])

    return dict_meas
def sdds_to_dict(in_complete_path):
	us_string = in_complete_path.split('.')[-2]

	try:
		temp = sddsdata(in_complete_path, endian='little', full=True)
	except IndexError:
		print 'Failed to open data file. (save_multit_mat)'
		return
	data = temp.data[0]
	nbOfMonitors = float(data['nbOfMonitors'])
	BunchNos = np.float_(data['BunchNos'])
	ChannelNames = data['ChannelNames']
	MonStatus = np.float_(data['MonStatus'])
	startTime = float(data['startTime'])
	date = data['date'].tostring()	
	nbOfTurns = float(data['nbOfTurns'])
	TurnNos = np.float_(data['TurnNos'])
	scNumber = float(data['scNumber'])
	SPSuser = data['user'].tostring().split('\n')[0]
	acqComment = data['acqComment'].tostring()
	MonPlanes = np.float_(data['MonPlanes'])
	MonNames = data['MonNames']
	Time = data['time'].tostring()
	
	t_stamp_unix = float(data['timestampSecond'])+float(data['timestampMilliSecond'])*1e-3
	
	dict_meas = {\
		'BunchNos': BunchNos,
		'ChannelNames': ChannelNames,
		'MonStatus': MonStatus,
		'startTime': startTime,
		'date': date,
		'nbOfTurns': nbOfTurns,
		'TurnNos': TurnNos,
		'scNumber': scNumber,
		'SPSuser': SPSuser,
		'acqComment': acqComment,
		'MonPlanes': MonPlanes,
		'nbOfMonitors': nbOfMonitors,
		'MonNames': MonNames,
		'Time': Time,
		't_stamp_unix': t_stamp_unix\
	}
	
	for channel in ChannelNames:
		dict_meas[channel] = np.float_(data[channel])
		dict_meas[channel+'-SUM'] = np.float_(data[channel+'-SUM'])
		
	return dict_meas
Beispiel #9
0
 def __init__(self,fn):
   sdds=sddsdata(fn)
   self.filename=fn
   self.bpms=r_[sdds.data[0]['bpmNames'],sdds.data[0]['bpmNames']]
   self.turns=sdds.data[0]['nbOfCapTurns'][0]
   xdata=sdds.data[0]['horPositionsConcentratedAndSorted']
   ydata=sdds.data[0]['verPositionsConcentratedAndSorted']
   self.data=r_[xdata,ydata].reshape(len(self.bpms),self.turns)
   self.xidx=zeros(len(self.bpms),dtype=bool)
   self.xidx[:len(self.bpms)/2]=True
   self.yidx=~self.xidx
   self.bad=self.find_bad_bpms()
   self.badxy=self.mk_badxy()
   self.t=arange(self.turns)
   self.goodx=(~self.badxy) & self.xidx
   self.goody=(~self.badxy) & self.yidx
Beispiel #10
0
def sdds_to_dict(in_complete_path):
	us_string = in_complete_path.split('.')[-2]

	try:
		temp = sddsdata(in_complete_path, endian='little', full=True)
	except IndexError:
		print 'Failed to open data file. (save_bct_mat)'
		return
	data = temp.data[0]

	frequency = np.float_(data['frequency'])

	dict_meas = {
		'frequency':frequency
	}

	return dict_meas
Beispiel #11
0
def sdds_to_dict(in_complete_path):
    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file. (save_mr_mat)'
        return
    data = temp.data[0]

    superCycleNb = float(data['SCNumber'])
    cycleTag = float(data['cycleTag'])
    firstSampleTime = float(data['firstSampleTime'])
    offset = float(data['offset'])
    sampleInterval = float(data['sampleInterval'])
    sensitivity = float(data['sensitivity'])
    triggerError = np.float_(data['triggerError'])
    triggerStamp = data['triggerStamp']
    value = np.float_(data['value'])
    #value_units = data['value_units'].tostring()
    first_trigger_t_stamp_unix = float(triggerStamp[0]) / 1e9
    SPSuser = in_complete_path.split('SPS.USER.')[-1].split('.')[0]

    time_string_filename = in_complete_path.split('@')[3]
    time_string_filename = ':'.join(time_string_filename.split('_')[:-1])
    date_string_path = in_complete_path.split('/')[-3]
    t_stamp_unix = time.mktime(
        time.strptime(date_string_path + ' ' + time_string_filename,
                      '%Y_%m_%d %H:%M:%S'))

    dict_meas = {
        'superCycleNb': superCycleNb,
        'cycleTag': cycleTag,
        'firstSampleTime': firstSampleTime,
        'offset': offset,
        'sampleInterval': sampleInterval,
        'sensitivity': sensitivity,
        'triggerError': triggerError,
        'triggerStamp': triggerStamp,
        'value': value,
        'first_trigger_t_stamp_unix': first_trigger_t_stamp_unix,
        'SPSuser': SPSuser,
        't_stamp_unix': t_stamp_unix
    }

    return dict_meas
Beispiel #12
0
def sdds_to_dict(in_complete_path):
    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file. (save_mr_mat)'
        return
    data = temp.data[0]

    superCycleNb = float(data['SCNumber'])
    cycleTag =  float(data['cycleTag'])
    firstSampleTime = float(data['firstSampleTime'])
    offset =  float(data['offset'])
    sampleInterval = float(data['sampleInterval'])
    sensitivity =  float(data['sensitivity'])
    triggerError = np.float_(data['triggerError'])
    triggerStamp =  data['triggerStamp']
    value = np.float_(data['value'])
    #value_units = data['value_units'].tostring()
    first_trigger_t_stamp_unix =  float(triggerStamp[0])/1e9   
    SPSuser = in_complete_path.split('SPS.USER.')[-1].split('.')[0]

    time_string_filename = in_complete_path.split('@')[3]
    time_string_filename = ':'.join(time_string_filename.split('_')[:-1])
    date_string_path = in_complete_path.split('/')[-3]
    t_stamp_unix = time.mktime(time.strptime(date_string_path + ' ' + time_string_filename, '%Y_%m_%d %H:%M:%S'))

    dict_meas = {
        'superCycleNb': superCycleNb,
        'cycleTag': cycleTag,
        'firstSampleTime': firstSampleTime,
        'offset': offset,
        'sampleInterval': sampleInterval,
        'sensitivity': sensitivity,
        'triggerError': triggerError,
        'triggerStamp': triggerStamp,
        'value': value,
        'first_trigger_t_stamp_unix': first_trigger_t_stamp_unix,
        'SPSuser': SPSuser,
        't_stamp_unix': t_stamp_unix }

    return dict_meas
Beispiel #13
0
 def __init__(self,fn,iqc=True):
     self.fn=fn
     sdds=sddsdata.sddsdata(open(fn))
     self.bpms=r_[sdds.data[0]['bpmNames']]
     self.nbpms=len(self.bpms)
     self.turns=sdds.data[0]['nbOfCapTurns'][0]
     self.bunches=sdds.data[0]['nbOfCapBunches'][0]
     xdata=sdds.data[0]['horPositionsConcentratedAndSorted']
     ydata=sdds.data[0]['verPositionsConcentratedAndSorted']
     if iqc:
         self.xbpm=xdata.reshape(self.nbpms,self.turns,self.bunches).transpose(0,2,1)
         self.ybpm=ydata.reshape(self.nbpms,self.turns,self.bunches).transpose(0,2,1)
     else:
         self.xbpm=xdata.reshape(self.nbpms,self.bunches,self.turns)
         self.ybpm=ydata.reshape(self.nbpms,self.bunches,self.turns)
     self.dt=sdds.data[0]['acqStamp'][0]/1e9
     self.date=dumpdate(self.dt)
     self.sdds=sdds
     if 'B2' in self.bpms[0]:
         self.beam=2
     elif 'B1' in self.bpms[0]:
         self.beam=1
Beispiel #14
0
def sdds_to_dict(in_complete_path):
    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file.'
        return
    data = temp.data[0]

    filename = in_complete_path.split('/')[-1]
    date_string = in_complete_path.split('/')[-3]
    us_string = filename.split('SPS.USER.')[-1].split('.sdds')[0]
    time_string = filename.split('Acquisition@')[-1].split('@')[0]

    temp_timest_string = date_string + '_' + time_string
    ms = float(temp_timest_string.split('_')[-1])
    t_stamp_unix = time.mktime(
        time.strptime(temp_timest_string[:-4],
                      '%Y_%m_%d_%H_%M_%S')) + ms * 1e-3
    t_stamp_string = temp_timest_string

    rawDataH = np.float_(data['rawDataH'])
    rawDataV = np.float_(data['rawDataV'])

    deviceName = str(data['deviceName']).split('\n')[0]
    triggerName = str(data['triggerName']).split('\n')[0]
    acqPeriod = np.int(data['acqPeriod'])
    dataMode = np.int(data['dataMode'])
    stopCycleTime = np.int(data['stopCycleTime'])
    requestedNbOfMeas = np.int(data['requestedNbOfMeas'])
    doneNbOfMeas = np.int(data['doneNbOfMeas'])
    cycleNumber = np.int(data['cycleNumber'])
    nbOfTurns = np.int(data['nbOfTurns'])
    acqOffset = np.int(data['acqOffset'])
    cycleLength = np.uint64(data['cycleLength'])
    measStamp = np.int_(data['measStamp'])

    propType = np.int(data['propType'])
    frevSource = np.int(data['frevSource'])
    doneNbOfIRQs = np.int(data['doneNbOfIRQs'])
    observables = np.int(data['observables'])

    exOffset = np.int(data['exOffset'])
    exDelay = np.int(data['exDelay'])
    exPeriod = np.int(data['exPeriod'])
    exMode = np.int(data['exMode'])

    windowFunction = np.int(data['windowFunction'])
    minSearchWindowFreqV = np.float(data['minSearchWindowFreqV'])
    minSearchWindowFreqH = np.float(data['minSearchWindowFreqH'])
    maxSearchWindowFreqV = np.float(data['maxSearchWindowFreqV'])
    maxSearchWindowFreqH = np.float(data['maxSearchWindowFreqH'])
    ring = np.int(data['ring'])

    chirpMode = np.int(data['chirpMode'])
    chirpStartFreqH = np.float(data['chirpStartFreqH'])
    chirpStartFreqV = np.float(data['chirpStartFreqV'])
    chirpStopFreqH = np.float(data['chirpStopFreqH'])
    chirpStopFreqV = np.float(data['chirpStopFreqV'])
    enableExcitationH = np.int(data['enableExcitationH'])
    enableExcitationV = np.int(data['enableExcitationV'])
    excitationAmplitudeV = np.float(data['excitationAmplitudeV'])
    excitationAmplitudeH = np.float(data['excitationAmplitudeH'])

    dict_meas = {
        't_stamp_unix': t_stamp_unix,
        't_stamp_string': t_stamp_string,
        'SPSuser': us_string,
        'deviceName': deviceName,
        'rawDataH': rawDataH,
        'rawDataV': rawDataV,
        'triggerName': triggerName,
        'acqPeriod': acqPeriod,
        'dataMode': dataMode,
        'stopCycleTime': stopCycleTime,
        'requestedNbOfMeas': requestedNbOfMeas,
        'doneNbOfMeas': doneNbOfMeas,
        'cycleNumber': cycleNumber,
        'nbOfTurns': nbOfTurns,
        'acqOffset': acqOffset,
        'cycleLength': cycleLength,
        'measStamp': measStamp,
        'propType': propType,
        'frevSource': frevSource,
        'doneNbOfIRQs': doneNbOfIRQs,
        'observables': observables,
        'exOffset': exOffset,
        'exDelay': exDelay,
        'exPeriod': exPeriod,
        'exMode': exMode,
        'windowFunction': windowFunction,
        'minSearchWindowFreqV': minSearchWindowFreqV,
        'minSearchWindowFreqH': minSearchWindowFreqH,
        'maxSearchWindowFreqV': maxSearchWindowFreqV,
        'maxSearchWindowFreqH': maxSearchWindowFreqH,
        'ring': ring,
        'chirpMode': chirpMode,
        'chirpStartFreqH': chirpStartFreqH,
        'chirpStartFreqV': chirpStartFreqV,
        'chirpStopFreqH': chirpStopFreqH,
        'chirpStopFreqV': chirpStopFreqV,
        'enableExcitationH': enableExcitationH,
        'enableExcitationV': enableExcitationV,
        'excitationAmplitudeV': excitationAmplitudeV,
        'excitationAmplitudeH': excitationAmplitudeH
    }

    return dict_meas
def sdds_to_dict(in_complete_path):
    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file.'
        return
    data = temp.data[0]

    filename = in_complete_path.split('/')[-1]
    date_string = in_complete_path.split('/')[-3]
    us_string = filename.split('SPS.USER.')[-1].split('.sdds')[0]
    time_string = filename.split('Acquisition@')[-1].split('@')[0]  

    temp_timest_string = date_string+'_'+time_string
    ms = float(temp_timest_string.split('_')[-1])
    t_stamp_unix = time.mktime(time.strptime(temp_timest_string[:-4], '%Y_%m_%d_%H_%M_%S'))+ms*1e-3
    t_stamp_string = temp_timest_string

    rawDataH = np.float_(data['rawDataH'])
    rawDataV = np.float_(data['rawDataV'])

    deviceName = str(data['deviceName']).split('\n')[0]
    triggerName = str(data['triggerName']).split('\n')[0]
    acqPeriod = np.int(data['acqPeriod'])
    dataMode = np.int(data['dataMode'])
    stopCycleTime = np.int(data['stopCycleTime'])
    requestedNbOfMeas = np.int(data['requestedNbOfMeas'])
    doneNbOfMeas = np.int(data['doneNbOfMeas'])
    cycleNumber = np.int(data['cycleNumber'])
    nbOfTurns = np.int(data['nbOfTurns'])
    acqOffset = np.int(data['acqOffset'])
    cycleLength = np.uint64(data['cycleLength'])
    measStamp = np.int_(data['measStamp'])

    propType = np.int(data['propType'])
    frevSource = np.int(data['frevSource'])
    doneNbOfIRQs = np.int(data['doneNbOfIRQs'])
    observables = np.int(data['observables'])

    exOffset = np.int(data['exOffset'])
    exDelay = np.int(data['exDelay'])
    exPeriod = np.int(data['exPeriod'])
    exMode = np.int(data['exMode'])

    windowFunction = np.int(data['windowFunction'])
    minSearchWindowFreqV = np.float(data['minSearchWindowFreqV'])
    minSearchWindowFreqH = np.float(data['minSearchWindowFreqH'])
    maxSearchWindowFreqV = np.float(data['maxSearchWindowFreqV'])
    maxSearchWindowFreqH = np.float(data['maxSearchWindowFreqH'])
    ring = np.int(data['ring'])

    chirpMode = np.int(data['chirpMode'])
    chirpStartFreqH = np.float(data['chirpStartFreqH'])
    chirpStartFreqV = np.float(data['chirpStartFreqV'])
    chirpStopFreqH = np.float(data['chirpStopFreqH'])
    chirpStopFreqV = np.float(data['chirpStopFreqV'])
    enableExcitationH = np.int(data['enableExcitationH'])
    enableExcitationV = np.int(data['enableExcitationV'])
    excitationAmplitudeV = np.float(data['excitationAmplitudeV'])
    excitationAmplitudeH = np.float(data['excitationAmplitudeH'])

    dict_meas = {
        't_stamp_unix':t_stamp_unix,
        't_stamp_string':t_stamp_string,
        'SPSuser':us_string,
        'deviceName':deviceName,
        'rawDataH':rawDataH,
        'rawDataV':rawDataV,
        'triggerName':triggerName,
        'acqPeriod':acqPeriod,
        'dataMode':dataMode,
        'stopCycleTime':stopCycleTime,
        'requestedNbOfMeas':requestedNbOfMeas,
        'doneNbOfMeas':doneNbOfMeas,
        'cycleNumber':cycleNumber,
        'nbOfTurns':nbOfTurns,
        'acqOffset':acqOffset,
        'cycleLength':cycleLength,
        'measStamp':measStamp,
        'propType':propType,
        'frevSource':frevSource,
        'doneNbOfIRQs':doneNbOfIRQs,
        'observables':observables,
        'exOffset':exOffset,
        'exDelay':exDelay,
        'exPeriod':exPeriod,
        'exMode':exMode,
        'windowFunction':windowFunction,
        'minSearchWindowFreqV':minSearchWindowFreqV,
        'minSearchWindowFreqH':minSearchWindowFreqH,
        'maxSearchWindowFreqV':maxSearchWindowFreqV,
        'maxSearchWindowFreqH':maxSearchWindowFreqH,
        'ring':ring,
        'chirpMode':chirpMode,
        'chirpStartFreqH':chirpStartFreqH,
        'chirpStartFreqV':chirpStartFreqV,
        'chirpStopFreqH':chirpStopFreqH,
        'chirpStopFreqV':chirpStopFreqV,
        'enableExcitationH':enableExcitationH,
        'enableExcitationV':enableExcitationV,
        'excitationAmplitudeV':excitationAmplitudeV,
        'excitationAmplitudeH':excitationAmplitudeH
            }

    return dict_meas
Beispiel #16
0
import sddsdata as sdds

filename = "LHCBPM2-Mon_Jun_29_16-26-00_CEST_2009.sdds"

a = sdds.sddsdata(filename, 'big')

print a.data[0].keys()
Beispiel #17
0
def pull_to_hdf5(device='fbct', day=pd.datetime.today().strftime("%Y_%m_%d")):

    global path_to_fbct, output_path

    if device is 'fbct':
        device_no = '31450'
        path_to_fbct += "{:s}/SPS.BCTFR.{:s}@Acquisition/".format(
            day, device_no)
        output_path += device.upper(
        ) + "/{:s}/SPS.BCTFR.{:s}@Acquisition/".format(day, device_no)

        files = glob.glob(path_to_fbct + "*.sdds")
        filenames = map(lambda s: s.split('/')[-1], files)
    else:
        raise ValueError("Unknown device {:s}".format(device))

    # Create output directories if not already present
    if not os.path.isdir(output_path):
        os.makedirs(output_path)

    # Store in file all sdds which have already been converted
    if not os.path.exists(output_path + 'converted_fbct.txt'):
        with open(output_path + 'converted_fbct.txt', 'w') as fh:
            fh.write("*** Converted fbct files created at {:s}".format(
                str(pd.datetime.now())))
    else:
        with open(output_path + 'converted_fbct.txt', 'r') as fh:
            converted_list = fh.read().splitlines()
        del converted_list[0]

    # List of files still to be converted
    unconverted_files = [
        fn for i, fn in enumerate(files) if filenames[i] not in converted_list
    ]

    for fl in unconverted_files[:]:
        try:
            data = sddsdata(fl, endian='little', full=True)
        except IOError as err:
            print("Failed to open file {:s}!".format(fl.split('/')[-1]))
            print(err.message)
            raise err

        ddict = data.data[0]
        fname = data.filename.split("/")[-1].replace("sdds", "h5")

        with h5py.File(output_path + fname, "w") as h5file:
            for t, v in ddict.items():
                try:
                    h5file.create_dataset(t,
                                          data=v,
                                          compression='gzip',
                                          compression_opts=9)
                except TypeError as err:
                    # print(err.message)
                    h5file.create_dataset(t, data=v)

        # Register converted files in converted file list
        with open(output_path + 'converted_fbct.txt', 'a') as fh:
            fh.write(fname.replace("h5", "sdds") + "\n")

        print("\n--> Converted file {:s} to hdf5 in folder {:s}".format(
            fname, output_path))
Beispiel #18
0
def sdds_to_dict(in_complete_path):
    us_string = in_complete_path.split('.')[-2]

    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file. (save_multiq_mat)'
        return
    data = temp.data[0]

    BBQ_Version = data['BBQ-Version'].tostring()
    acqOffset = float(data['acqOffset'])
    acqPeriod = float(data['acqPeriod'])
    acqStartTimes = np.float_(data['acqStartTimes'])
    acqTimes = np.float_(data['acqTimes'])
    chirpStartFreqH = float(data['chirpStartFreqH'])
    chirpStartFreqV = float(data['chirpStartFreqV'])
    chirpStopFreqH = float(data['chirpStopFreqH'])
    chirpStopFreqV = float(data['chirpStopFreqV'])
    date = data['date'].tostring()
    enableExcitationH = bool(data['enableExcitationH'])
    enableExcitationV = bool(data['enableExcitationV'])
    exDelay = float(data['exDelay'])
    exOffset = float(data['exOffset'])
    exPeriod = float(data['exPeriod'])
    excitationAmplitudeH = float(data['excitationAmplitudeH'])
    excitationAmplitudeV = float(data['excitationAmplitudeV'])
    fullNumberOfTurns = float(data['fullNumberOfTurns'])
    nbOfMeas = float(data['nbOfMeas'])
    nbOfTurns = float(data['nbOfTurns'])
    superCycleNb = float(data['scNumber'])
    Time = data['time'].tostring()
    triggerName = data['triggerName'].tostring()
    tuneDataH = data['tuneDataH']
    tuneDataV = data['tuneDataV']
    SPSuser = data['user'].tostring().split('\n')[0]
    window = data['window'].tostring()
    windowFunction = float(data['windowFunction'])

    t_stamp_unix = float(
        data['timestampSecond']) + float(data['timestampMilliSecond']) * 1e-3
    rawData_H = []
    rawData_V = []
    for ii in xrange(int(nbOfMeas)):
        rawData_H.append(data['rawData-H-%d' % (ii + 1)])
        rawData_V.append(data['rawData-V-%d' % (ii + 1)])

    rawData_H = np.float_(np.array(rawData_H))
    rawData_V = np.float_(np.array(rawData_V))

    dict_meas = {\
     'BBQ_Version': BBQ_Version,
     'acqOffset':  acqOffset,
     'acqPeriod':  acqPeriod,
     'acqStartTimes':acqStartTimes,
     'acqTimes': acqTimes,
     'chirpStartFreqH': chirpStartFreqH,
     'chirpStartFreqV': chirpStartFreqV,
     'chirpStopFreqH ':chirpStopFreqH,
     'chirpStopFreqV':chirpStopFreqV,
     'date':date,
     'enableExcitationH':enableExcitationH,
     'enableExcitationV':enableExcitationV,
     'exDelay':exDelay,
     'exOffset':exOffset,
     'exPeriod': exPeriod,
     'excitationAmplitudeH':excitationAmplitudeH,
     'excitationAmplitudeV': excitationAmplitudeV,
     'fullNumberOfTurns': fullNumberOfTurns,
     'nbOfMeas':nbOfMeas,
     'nbOfTurns':nbOfTurns,
     'superCycleNb': superCycleNb,
     'Time': Time,
     'triggerName': triggerName,
     'tuneDataH': tuneDataH,
     'tuneDataV': tuneDataV,
     'SPSuser': SPSuser,
     'window ':window,
     'windowFunction': windowFunction,
     'rawData_H':rawData_H,
     'rawData_V':rawData_V,
     't_stamp_unix':t_stamp_unix\
     }

    return dict_meas
Beispiel #19
0
#!/afs/cern.ch/eng/sl/lintrack/Python-2.5_32bit/Python-2.5_32bit/bin/python

import  sddsdata as sdds

t=sdds.sddsdata('/afs/cern.ch/user/r/rtomas/lintrack/LHCBPM1-Wed_Sep_10_21-01-36_CEST_2008.sdds.sdds','big')


print t.data[t.data.keys()[0]]
bpm1=t.data.keys()[1]

print bpm1, t.data[bpm1]
header= t.header
bpmnames = t.data['bpmNames']
print bpmnames
othernames= [i for i in t.data.keys() if 'BPM' not in i]
thevalues = [t.data[i] for i in othernames]
print othernames
print thevalues
#print t.data['bpmNames']
Beispiel #20
0
filenamedir=filenamedir+'/'
onlyfilename=filename.split('/')[-1]


convert=sys.argv[0]  #We assume that twiss.dat is in the same dir as the convert.py
convertdir=join(convert.split('/')[0:-1], '/')
if convertdir=='':
  convertdir='.'
tf=convertdir+'/twiss.dat'
print "TWISS FILE: ", tf 
tw=twiss(tf)


#t=sdds.sddsdata('/afs/cern.ch/user/r/rtomas/lintrack/LHCBPM1-Wed_Sep_10_21-01-36_CEST_2008.sdds.sdds','big')

a=sdds.sddsdata(filename, 'big')

nbOfCapBunches=int(a.data['nbOfCapBunches'])
nbOfCapTurns=int(a.data['nbOfCapTurns'])
print "Turns, Bunches:", nbOfCapTurns,nbOfCapBunches
bpmnames = a.data['bpmNames']
channelnames = a.data['ChannelNames']
#otherBPMnames= [i for i in a.data.keys() if 'BPM' in i]
othernames= [i for i in a.data.keys() if 'BPM' not in i]
#print bpmnames[0],otherBPMnames[0]
#print othernames
#print a.data['BPMSW.1L1.B1/H-bunch111']



bunchfile={}
Beispiel #21
0
def sdds_to_dict(in_complete_path):

    try:
        temp = sddsdata(in_complete_path, endian='little', full=True)
    except IndexError:
        print 'Failed to open data file. (save_bct_mat)'
        return
    data = temp.data[0]

    try:
        dict_meas = {
            'acqDesc':
            data['acqDesc'].tostring(),
            'acqMsg':
            data['acqMsg'].tostring(),
            'acqState':
            np.int_(data['acqState']),
            'acqTime':
            data['acqTime'].tostring(),
            'measStamp':
            data['measStamp'],
            'measStamp_unit':
            np.int_(data['measStamp_unit']),
            'measStamp_unitExponent':
            np.float_(data['measStamp_unitExponent']),
            'nbOfMeas':
            np.int_(data['nbOfMeas']),
            'observables':
            np.int_(data['observables']),
            'propType':
            np.int_(data['propType']),
            'samplingTime':
            np.int_(data['samplingTime']),
            'sbfIntensity':
            np.float_(data['sbfIntensity']),
            'superCycleNb':
            np.int_(data['superCycleNb']),
            'totalIntensity':
            data['totalIntensity'],
            'totalIntensity_unit':
            np.int_(data['totalIntensity_unit']),
            'totalIntensity_unitExponent':
            np.int_(data['totalIntensity_unitExponent']),
            'deviceName':
            ((data['deviceName'].tostring()).split('\n')[0]).split('SPS.')[-1],
            'beamID':
            np.int_(data['beamID']),
            'cycleTime':
            data['cycleTime'].tostring(),
        }
    except KeyError as err:
        print(err.message)
        print("This looks like a post October 2017 SDDS... will try to adapt.")

        # import pdb; pdb.set_trace()
        dict_meas = {
            'calMarkerData':
            data['calMarkerData'],
            'inCheckStatusData':
            data['inCheckStatusData'],
            'range1Data':
            data['range1Data'],
            'range2Data':
            data['range2Data'],
            'range3Data':
            data['range3Data'],
            'totalIntensity':
            data['totalIntensity'],
            'totalIntensity4Ranges':
            data['totalIntensity4Ranges'],
            'acqMsg':
            data['acqMsg'],
            'acqState':
            data['acqState'],
            'acqTime':
            data['acqTime'],
            'cycleTime':
            data['cycleTime'],
            'dumpCycleTime':
            data['dumpCycleTime'],
            'dumpInt':
            data['dumpInt'],
            'measStamp_unit':
            np.int_(data['measStamp_unit']),
            'measStamp_unitExponent':
            data['measStamp_unitExponent'],
            'nbOfAdcData':
            np.int_(data['nbOfAdcData']),
            'nbOfMeas':
            data['nbOfMeas'],
            'samplingTime':
            data['samplingTime'],
            'sbfCycleTime':
            data['sbfCycleTime'],
            'sbfIntensity':
            data['sbfIntensity'],
            'selectedRange':
            data['selectedRange'],
            'slowCycleTime':
            data['slowCycleTime'],
            'slowExtInt':
            data['slowExtInt'],
            'superCycleNb':
            data['superCycleNb'],
            'totalIntensity_unit':
            data['totalIntensity_unit'],
            'totalIntensity_unitExponent':
            data['totalIntensity_unitExponent'],
            'vmodStatus':
            data['vmodStatus'],
            'acqDesc':
            data['acqDesc'],
            'beamID':
            0,
            'deviceName':
            data['acqMsg'].tostring().replace(
                '\n', '').strip('"').split(':')[-1].split('SPS.')[-1],
            'lowIbStatusData':
            data['lowIbStatusData'],
            'measStamp':
            data['measStamp'],
            'range4Data':
            data['range4Data'],
        }

    us_string = in_complete_path.split('.')[-2]
    cycleTime = data['cycleTime'].tostring()
    t_stamp_unix = time.mktime(
        time.strptime(
            cycleTime.replace('"', '').replace('\n', '').split('.')[0],
            '%Y/%m/%d %H:%M:%S'))
    dict_meas['SPSuser'] = us_string
    dict_meas['t_stamp_unix'] = t_stamp_unix

    return dict_meas
def sdds_to_dict(in_complete_path):
	us_string = in_complete_path.split('.')[-2]

	try:
		temp = sddsdata(in_complete_path, endian='little', full=True)
	except IndexError:
		print 'Failed to open data file. (save_multiq_mat)'
		return
	data = temp.data[0]

	BBQ_Version = data['BBQ-Version'].tostring()
	acqOffset = float(data['acqOffset'])
	acqPeriod = float(data['acqPeriod'])
	acqStartTimes = np.float_(data['acqStartTimes'])
	acqTimes = np.float_(data['acqTimes'])
	chirpStartFreqH = float(data['chirpStartFreqH'])
	chirpStartFreqV = float(data['chirpStartFreqV'])
	chirpStopFreqH = float(data['chirpStopFreqH'])
	chirpStopFreqV = float(data['chirpStopFreqV'])
	date = data['date'].tostring()
	enableExcitationH = bool(data['enableExcitationH'])
	enableExcitationV = bool(data['enableExcitationV'])
	exDelay = float(data['exDelay'])
	exOffset = float(data['exOffset'])
	exPeriod = float(data['exPeriod'])
	excitationAmplitudeH = float(data['excitationAmplitudeH'])
	excitationAmplitudeV = float(data['excitationAmplitudeV'])
	fullNumberOfTurns = float(data['fullNumberOfTurns'])
	nbOfMeas = float(data['nbOfMeas'])
	nbOfTurns = float(data['nbOfTurns'])
	superCycleNb = float(data['scNumber'])
	Time = data['time'].tostring()
	triggerName = data['triggerName'].tostring()
	tuneDataH = data['tuneDataH']
	tuneDataV = data['tuneDataV']
	SPSuser = data['user'].tostring().split('\n')[0]
	window = data['window'].tostring()
	windowFunction = float(data['windowFunction'])
	
	t_stamp_unix = float(data['timestampSecond'])+float(data['timestampMilliSecond'])*1e-3
	rawData_H=[]
	rawData_V=[]
	for ii in xrange(int(nbOfMeas)):
		rawData_H.append(data['rawData-H-%d'%(ii+1)])
		rawData_V.append(data['rawData-V-%d'%(ii+1)])

	rawData_H = np.float_(np.array(rawData_H))
	rawData_V = np.float_(np.array(rawData_V))

	dict_meas = {\
		'BBQ_Version': BBQ_Version,
		'acqOffset':  acqOffset,
		'acqPeriod':  acqPeriod,
		'acqStartTimes':acqStartTimes,
		'acqTimes': acqTimes,
		'chirpStartFreqH': chirpStartFreqH,
		'chirpStartFreqV': chirpStartFreqV,
		'chirpStopFreqH ':chirpStopFreqH,
		'chirpStopFreqV':chirpStopFreqV,
		'date':date,
		'enableExcitationH':enableExcitationH,
		'enableExcitationV':enableExcitationV,
		'exDelay':exDelay,
		'exOffset':exOffset,
		'exPeriod': exPeriod,
		'excitationAmplitudeH':excitationAmplitudeH,
		'excitationAmplitudeV': excitationAmplitudeV,
		'fullNumberOfTurns': fullNumberOfTurns,
		'nbOfMeas':nbOfMeas,
		'nbOfTurns':nbOfTurns,
		'superCycleNb': superCycleNb,
		'Time': Time,
		'triggerName': triggerName,
		'tuneDataH': tuneDataH,
		'tuneDataV': tuneDataV,
		'SPSuser': SPSuser,
		'window ':window,
		'windowFunction': windowFunction,
		'rawData_H':rawData_H,
		'rawData_V':rawData_V,
		't_stamp_unix':t_stamp_unix\
		}

	return dict_meas