spavbl.set_ylim(0.8, 1.8)
            spavbl.grid('on')
            spavbl.set_xlabel('Time [h]')

    group_name = group_names[ii]
    pl.suptitle(' Fill. %d started on %s\n%s' %
                (filln, tref_string, group_name))
    fig_h.canvas.set_window_title(group_name)

    hl_var_names = dict_hl_groups[group_name][:]
    hl_var_names_copy = dict_hl_groups[group_name][:]
    for varname in hl_var_names_copy:
        if varname in blacklist:
            hl_var_names.remove(varname)

    heatloads = SetOfHomogeneousNumericVariables(variable_list=hl_var_names,
                                                 timber_variables=dict_hl_data)
    hl_model = SetOfHomogeneousNumericVariables(
        variable_list=HL.variable_lists_heatloads['MODEL'],
        timber_variables=fill_dict)

    # CORRECT ARC AVERAGES
    if group_name == 'Arcs' and filln < first_correct_filln:
        hl_corr_factors = []
        for ii, varname in enumerate(dict_hl_groups[group_name]):
            if varname not in blacklist:
                hl_corr_factors.append(arc_correction_factor_list[ii])
        heatloads.correct_values(hl_corr_factors)

    if flag_average: hl_ts_curr, hl_aver_curr = heatloads.mean()
    for ii, kk in enumerate(heatloads.variable_list):
        colorcurr = ms.colorprog(i_prog=ii,
Beispiel #2
0
    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:
            heatloads.timber_variables[device].values = heatloads.timber_variables[device].values/norm_length_dict[device]
    if plot_all:
        for ii, kk in enumerate(heatloads.variable_list):

            #if '13L5' in kk and ('D2' in kk or 'D3' in kk):
            spavbl.set_ylabel('Bunch length')
            spavbl.set_ylim(0.8,1.8)
            spavbl.grid('on')
            spavbl.set_xlabel('Time [h]')

    group_name = group_names[ii]
    pl.suptitle(' Fill. %d started on %s\n%s'%(filln, tref_string, group_name))
    fig_h.canvas.set_window_title(group_name)

    hl_var_names = dict_hl_groups[group_name][:]
    hl_var_names_copy = dict_hl_groups[group_name][:]
    for varname in hl_var_names_copy:
        if varname in blacklist:
            hl_var_names.remove(varname)

    heatloads = SetOfHomogeneousNumericVariables(variable_list=hl_var_names, timber_variables=dict_hl_data)
    hl_model = SetOfHomogeneousNumericVariables(variable_list=HL.variable_lists_heatloads['MODEL'], timber_variables=fill_dict)

    # CORRECT ARC AVERAGES
    if group_name == 'Arcs' and filln < first_correct_filln:
        hl_corr_factors = []
        for ii, varname in enumerate(dict_hl_groups[group_name]):
            if varname not in blacklist:
                hl_corr_factors.append(arc_correction_factor_list[ii])
        heatloads.correct_values(hl_corr_factors)



    if flag_average: hl_ts_curr, hl_aver_curr  = heatloads.mean()
    for ii, kk in enumerate(heatloads.variable_list):
        colorcurr = ms.colorprog(i_prog=ii, Nplots=len(heatloads.variable_list))
Beispiel #4
0
            data_folder_fill +
            '/fill_basic_data_csvs/basic_data_fill_%d.csv' % filln,
            verbose=False))
    fill_dict.update(
        tm.parse_timber_file(
            data_folder_fill +
            '/fill_heatload_data_csvs/heatloads_fill_%d.csv' % filln,
            verbose=False))

energy = Energy.energy(fill_dict, beam=1)
energy.t_stamps = (energy.t_stamps - energy.t_stamps[0]) / 3600.
t_ref = dict_fill_bmodes[filln]['t_startfill']
tref_string = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime(t_ref))

heatloads = SetOfHomogeneousNumericVariables(
    variable_list=variable_list,
    timber_variables=fill_dict).aligned_object(dt_seconds=60)
## Swap 13L5 D2 and D4, as the correct gas flow is in reverse direction
#for ctr,var in enumerate(heatloads.variables):
#    if '13R4' in var:
#        if 'D2' in var:
#            ctr_2 = ctr
#            var_2 = var
#        elif 'D4' in var:
#            ctr_4 = ctr
#            var_4 = var
#heatloads.variables[ctr_2] = var_4
#heatloads.variables[ctr_4] = var_2

y_min, y_max = -10, np.max(heatloads.data) + 5
timestamps = (heatloads.timestamps - heatloads.timestamps[0]) / 3600.
        table_bint = total_bint.nearest_older_sample(tt_blen)

    ii = 0
    group_names = list(dict_hl_groups.keys())
    group_name = group_names[ii]
    pl.suptitle(' Fill. %d started on %s\n%s (%s)' %
                (filln, tref_string, group_name, title_string))
    fig_h.canvas.set_window_title(group_name + ' %i' % filln)

    hl_var_names = dict_hl_groups[group_name][:]
    hl_var_names_copy = dict_hl_groups[group_name][:]
    for varname in hl_var_names_copy:
        if varname in blacklist:
            hl_var_names.remove(varname)

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

    # Model heat load
    hl_imped_fill = fc.HeatLoad_calculated_fill(fill_dict,
                                                hli_calculator,
                                                bct_dict=bct_bx,
                                                fbct_dict=fbct_bx,
                                                blength_dict=blength_bx)
    hl_sr_fill = fc.HeatLoad_calculated_fill(fill_dict,
                                             hlsr_calculator,
                                             bct_dict=bct_bx,
                                             fbct_dict=fbct_bx,
                                             blength_dict=blength_bx)
    hl_total_model = (hl_imped_fill.heat_load_calculated_total +
                      hl_sr_fill.heat_load_calculated_total) * 53.45
    hl_model_t_stamps = (hl_imped_fill.t_stamps -
            data_folder +
            '/fill_bunchbybunch_data_csvs/bunchbybunch_data_fill_%d.csv' %
            filln,
            verbose=False))
except Exception as e:
    print e
    pass

if not args.nolog:
    fill_dict.update(
        tm.parse_timber_file(
            data_folder +
            './fill_heatload_data_csvs/heatloads_fill_%d.csv' % filln,
            verbose=False))
    heatloads = SetOfHomogeneousNumericVariables(variable_list=arc_keys_list +
                                                 quad_keys_list,
                                                 timber_variables=fill_dict)
energy = Energy.energy(fill_dict, beam=1)
bct_bx = {}
for beam_n in colstr:
    bct_bx[beam_n] = BCT(fill_dict, beam=beam_n)

hli_calculator = ihl.HeatLoadCalculatorImpedanceLHCArc()
hlsr_calculator = srhl.HeatLoadCalculatorSynchrotronRadiationLHCArc()

hl_imped_fill = fc.HeatLoad_calculated_fill(fill_dict, hli_calculator)
hl_sr_fill = fc.HeatLoad_calculated_fill(fill_dict, hlsr_calculator)

figs = []
ms.mystyle(12)
title = 'Recalculated arc heat loads %i' % filln
    
    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:
        for device in hl_varlist:
            heatloads.timber_variables[device].values = heatloads.timber_variables[device].values/norm_length_dict[device]
        for device in HL.variable_lists_heatloads['MODEL']:
            hl_model.timber_variables[device].values = hl_model.timber_variables[device].values/53.45
            
Beispiel #8
0
    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:
        for device in hl_varlist:
            heatloads.timber_variables[
Beispiel #9
0
            raise ValueError('%s does not have a .POSST' % var)

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

    for filln in fill_sublist_2:
        h5_file = data_file_func(filln)
        if h5_file in os.listdir(os.path.dirname(h5_file)):
            continue
        this_temp_file = temp_file % filln
        print('Downloading csv for fill %i' % filln)
        t_start_fill = dict_fill_bmodes[filln]['t_startfill']
        t_end_fill = dict_fill_bmodes[filln]['t_endfill']
        lldb.dbquery(varlist, t_start_fill, t_end_fill, this_temp_file)
        print('Aligning data for fill %i' % filln)
        htd_ob = SetOfHomogeneousNumericVariables(
            varlist, this_temp_file).aligned_object(dt_seconds)
        print('Creating h5 file for fill %i' % filln)
        n_tries_max = 5
        for n_try in xrange(n_tries_max):
            try:
                mfm.aligned_obj_to_h5(htd_ob, h5_file)
                break
            except Exception as e:
                print('Saving of h5 failed')
                time.sleep(10)
        else:
            print('Raise error after trying to save the h5 file %i times' %
                  n_tries_max)
            raise

        if os.path.isfile(h5_file) and os.path.getsize(h5_file) > 500: