Example #1
0
    if args.use_recalc:
        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
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)
Example #3
0
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,
                        n_vars_per_extraction=1000)
Example #4
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)
Example #5
0
        print("Fill incomplete --> no h5 convesion")
        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()):