示例#1
0
        import GasFlowHLCalculator.qbs_fill as qf
        try:
            fill_dict.update(qf.get_fill_dict(filln,h5_storage=H5_storage(recalc_h5_folder),use_dP=True))
        except ValueError:
            'Skipped due to ValueError'

    if plot_model:
        try:
            fill_dict.update(tm.timber_variables_from_h5(data_folder_fill+'/heatloads_fill_h5s/imp_and_SR_fill_%i.h5' % filln))
        except IOError:
            print "model datafile not found" 


    bct_b1 = BCT.BCT(fill_dict, beam=1)
    bct_b2 = BCT.BCT(fill_dict, beam=2)
    energy = Energy.energy(fill_dict, beam=1, t_start_fill=t_startfill, t_end_fill=t_endfill)
    ax1.plot(tc(bct_b1.t_stamps), bct_b1.values*1e-14, lw=2, c='b', label = 'Intensity B1' if i_fill==0 else "")
    ax1.plot(tc(bct_b2.t_stamps), bct_b2.values*1e-14, lw=2, c='r', label = 'Intensity B2' if i_fill==0 else "")
    ax11.plot(tc(energy.t_stamps), energy.energy/1e3, c='black', linestyle = '--',lw=2,label='Energy' if i_fill==0 else "") #was alpha=.5

    heatloads = SetOfHomogeneousNumericVariables(variable_list=hl_varlist, timber_variables=fill_dict)


    # remove offset
    if zero_at is not None:
        for device in hl_varlist:
            heatloads.timber_variables[device].values = heatloads.timber_variables[device].values - dict_offsets[device]

    # normalize to the length
    if normalization_to_length_of is not None:
        for device in hl_varlist:
示例#2
0
    ],
                  t_start_fill,
                  t_end_fill,
                  scaleAlgorithm='AVG',
                  scaleInterval='SECOND',
                  scaleSize='30'))

print('Done')

##################
## Data manip   ##
##################

bsrt_calib_dict = BSRT_calib.emittance_dictionary(filln=filln)

energy = Energy.energy(fill_dict, beam=beam)
bct = BCT.BCT(fill_dict, beam=beam)
bsrt = BSRT.BSRT(fill_dict,
                 beam=beam,
                 calib_dict=bsrt_calib_dict,
                 average_repeated_meas=average_repeated_meas)
bsrt.calculate_emittances(energy)

dict_bunches, t_bbb, emit_h_bbb, emit_v_bbb, bunch_n_un = bsrt.get_bbb_emit_evolution(
)

#resample with uniform time step
resampled_emit_h_bbb = []
resampled_emit_v_bbb = []

t_resampled = np.arange(t_start_fill, t_end_fill, t_step_resample_s)
import LHCMeasurementTools.LHC_Energy as Energy
import LHCMeasurementTools.LHC_BCT as BCT

import LHCMeasurementTools.LHC_Fills as Fills
from LHCMeasurementTools.LHC_Fill_LDB_Query import save_variables_and_pickle

import pickle
import os

csv_folder = 'fill_basic_data_csvs'
filepath =  csv_folder+'/basic_data_fill'

if not os.path.isdir(csv_folder):
    os.mkdir(csv_folder)

fills_pkl_name = 'fills_and_bmodes.pkl'
with open(fills_pkl_name, 'rb') as fid:
    dict_fill_bmodes = pickle.load(fid)

saved_pkl = csv_folder+'/saved_fills.pkl'

varlist = []
varlist += Energy.variable_list()
varlist += BCT.variable_list()

save_variables_and_pickle(varlist=varlist, file_path_prefix=filepath, 
                          save_pkl=saved_pkl, fills_dict=dict_fill_bmodes)
示例#4
0
import json
import os

h5_folder = 'fill_basic_data_h5s'
filepath = h5_folder + '/basic_data_fill'

if not os.path.isdir(h5_folder):
    os.mkdir(h5_folder)

fills_json_name = 'fills_and_bmodes.json'
dict_fill_bmodes = load_fill_dict_from_json(fills_json_name)

saved_json = h5_folder + '/saved_fills.json'

varlist = []
varlist += Energy.variable_list()
varlist += BCT.variable_list()

# Switch between cals and nxcals
import pytimber
db = pytimber.LoggingDB(source='nxcals')
#db = pytimber.LoggingDB(source='ldb')

#from LHCMeasurementTools.TimberManager import NXCalsFastQuery
#db = NXCalsFastQuery(system='CMW')

save_variables_and_json(varlist=varlist,
                        file_path_prefix=filepath,
                        save_json=saved_json,
                        fills_dict=dict_fill_bmodes,
                        db=db,
示例#5
0
        continue

    if os.path.isfile(h5filename) and dict_fill_bmodes[filln]['flag_complete'] is True:
        print("Already complete and in h5")
        continue

    try:
        dict_fill_data = {}
        dict_fill_data.update(tm.parse_timber_file('fill_basic_data_csvs/basic_data_fill_%d.csv'%filln, verbose=False))
        dict_fill_data.update(tm.parse_timber_file('fill_heatload_data_csvs/heatloads_fill_%d.csv'%filln, verbose=False))


        varlist = []

        varlist += LHC_BCT.variable_list()
        varlist += LHC_Energy.variable_list()
        for kk in list(LHC_Heatloads.variable_lists_heatloads.keys()):
            varlist+=LHC_Heatloads.variable_lists_heatloads[kk]


        dict_to_h5 = {}

        for varname in varlist:
            #~ print varname
            dict_to_h5[varname+'!t_stamps'] = np.float_(dict_fill_data[varname].t_stamps)
            dict_to_h5[varname+'!values'] = dict_fill_data[varname].float_values()


        with h5py.File(h5filename, 'w') as fid:
            for kk in list(dict_to_h5.keys()):
                fid[kk] = dict_to_h5[kk]
fill_dict = {}
fill_dict.update(tm.parse_timber_file('fill_basic_data_csvs/basic_data_fill_%d.csv'%filln, verbose=False))
fill_dict.update(tm.parse_timber_file('fill_heatload_data_csvs/heatloads_fill_%d.csv'%filln, verbose=False))
fill_dict.update(tm.parse_timber_file('fill_bunchbybunch_data_csvs/bunchbybunch_data_fill_%d.csv'%filln, verbose=False))

dict_beam = fill_dict
dict_fbct = fill_dict


colstr = {}
colstr[1] = 'b'
colstr[2] = 'r'



energy = Energy.energy(fill_dict, beam=1)

t_fill_st = dict_fill_bmodes[filln]['t_startfill']
t_fill_end = dict_fill_bmodes[filln]['t_endfill']
t_fill_len = t_fill_end - t_fill_st


t_min = dict_fill_bmodes[filln]['t_startfill']-0*60.
t_max = dict_fill_bmodes[filln]['t_endfill']+0*60.


t_ref=t_fill_st
tref_string=time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime(t_ref))


pl.close('all')
示例#7
0
dict_fill_data = {}
dict_fill_data.update(
    tm.parse_timber_file('fill_basic_data_csvs/basic_data_fill_%d.csv' % filln,
                         verbose=True))
dict_fill_data.update(
    tm.parse_timber_file('fill_extra_data_csvs/extra_data_fill_%d.csv' % filln,
                         verbose=True))

dict_beam = dict_fill_data
dict_fbct = dict_fill_data

colstr = {}
colstr[1] = 'b'
colstr[2] = 'r'

energy = Energy.energy(dict_fill_data, beam=1)

t_fill_st = dict_fill_bmodes[filln]['t_startfill']
t_fill_end = dict_fill_bmodes[filln]['t_endfill']
t_fill_len = t_fill_end - t_fill_st

t_min = dict_fill_bmodes[filln]['t_startfill'] - 0 * 60.
t_max = dict_fill_bmodes[filln]['t_endfill'] + 0 * 60.

t_ref = t_fill_st
tref_string = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime(t_ref))

pl.close('all')
ms.mystyle_arial(fontsz=myfontsz, dist_tick_lab=8)

bct_bx = {}
for i_fill, filln in enumerate(fill_list):

    print 'Fill %d, %d/%d'%(filln, i_fill+1, N_fills)
    if filln in empty_fills:
        continue
    
    t_startfill = fill_info.dict_fill_bmodes[filln]['t_startfill']
    t_endfill = fill_info.dict_fill_bmodes[filln]['t_endfill']
    fill_dict = {}
    fill_dict.update(tm.parse_timber_file('fill_basic_data_csvs/basic_data_fill_%d.csv'%filln, verbose=False))
    fill_dict.update(tm.parse_timber_file('fill_heatload_data_csvs/heatloads_fill_%d.csv'%filln, verbose=False))


    bct_b1 = BCT.BCT(fill_dict, beam=1)
    bct_b2 = BCT.BCT(fill_dict, beam=2)    
    energy = Energy.energy(fill_dict, beam=1, t_start_fill=t_startfill, t_end_fill=t_endfill)
    ax1.plot(tc(bct_b1.t_stamps), bct_b1.values*1e-14, lw=2, c='b')
    ax1.plot(tc(bct_b2.t_stamps), bct_b2.values*1e-14, lw=2, c='r')
    ax11.plot(tc(energy.t_stamps), energy.energy/1e3, c='black', lw=1.5, alpha=0.5)
    
    heatloads = SetOfHomogeneousNumericVariables(variable_list=hl_varlist, timber_variables=fill_dict)
    hl_model = SetOfHomogeneousNumericVariables(variable_list=HL.variable_lists_heatloads['MODEL'], timber_variables=fill_dict)
        
    
    # remove offset
    if zero_at is not None:
        for device in hl_varlist:
            heatloads.timber_variables[device].values = heatloads.timber_variables[device].values - dict_offsets[device]
    
    # normalize to the length
    if normalization_to_length_of is not None: