def readDataFromXML(self, cav_long_twiss_bucket_da, scl_long_tuneup_controller): #------ read data for cavity from the XML stucture self.isReady = Boolean( cav_long_twiss_bucket_da.intValue("isReady")).booleanValue() self.fit_bpm_amp_avg_err = cav_long_twiss_bucket_da.doubleValue( "amp_avg_fit_err") twiss_arr_da = cav_long_twiss_bucket_da.childAdaptor("Twiss_arr") alphaX = twiss_arr_da.doubleValue("alphaX") betaX = twiss_arr_da.doubleValue("betaX") emittX = twiss_arr_da.doubleValue("emittX") alphaY = twiss_arr_da.doubleValue("alphaY") betaY = twiss_arr_da.doubleValue("betaY") emittY = twiss_arr_da.doubleValue("emittY") alphaZ = twiss_arr_da.doubleValue("alphaZ") betaZ = twiss_arr_da.doubleValue("betaZ") emittZ = twiss_arr_da.doubleValue("emittZ") self.twiss_arr[0].setTwiss(alphaX, betaX, emittX) self.twiss_arr[1].setTwiss(alphaY, betaY, emittY) self.twiss_arr[2].setTwiss(alphaZ, betaZ, emittZ) self.long_Twiss_arr_err[0] = twiss_arr_da.doubleValue("alphaZ_err") self.long_Twiss_arr_err[1] = twiss_arr_da.doubleValue("betaZ_err") self.long_Twiss_arr_err[2] = twiss_arr_da.doubleValue("emittZ_err") self.long_Twiss_arr_steps[0] = twiss_arr_da.doubleValue("alphaZ_steps") self.long_Twiss_arr_steps[1] = twiss_arr_da.doubleValue("betaZ_steps") self.long_Twiss_arr_steps[2] = twiss_arr_da.doubleValue("emittZ_steps") twiss_fit_da = cav_long_twiss_bucket_da.childAdaptor("Twiss_fit") alphaZ = twiss_fit_da.doubleValue("alphaZ") betaZ = twiss_fit_da.doubleValue("betaZ") emittZ = twiss_fit_da.doubleValue("emittZ") self.long_Twiss_fit.setTwiss(alphaZ, betaZ, emittZ) twiss_matrix_da = cav_long_twiss_bucket_da.childAdaptor("Twiss_matrix") alphaZ = twiss_matrix_da.doubleValue("alphaZ") betaZ = twiss_matrix_da.doubleValue("betaZ") emittZ = twiss_matrix_da.doubleValue("emittZ") self.long_Twiss_matrix.setTwiss(alphaZ, betaZ, emittZ) self.long_Twiss_z2_zzp_zp2_err[0] = twiss_matrix_da.doubleValue( "z2_err") self.long_Twiss_z2_zzp_zp2_err[1] = twiss_matrix_da.doubleValue( "z_zp_err") self.long_Twiss_z2_zzp_zp2_err[2] = twiss_matrix_da.doubleValue( "z2_err") #---- clean up and read the amp graphs self.update() bpm_amps_da = cav_long_twiss_bucket_da.childAdaptor("BPM_Amplitudes") for bpm_amp_da in bpm_amps_da.childAdaptors("BPM"): bpm_wrapper = scl_long_tuneup_controller.getBPM_Wrapper( bpm_amp_da.stringValue("BPM")) for [bpm_wrapper_tmp, amp_plotTh] in self.bpm_amp_plotTh_arr: if (bpm_wrapper_tmp == bpm_wrapper): readGraphDataFromDA(amp_plotTh, bpm_amp_da, "BPM_AMPL_GD") break
def readDataFromXML(self,cav_long_twiss_bucket_da,scl_long_tuneup_controller): #------ read data for cavity from the XML stucture self.isReady = Boolean(cav_long_twiss_bucket_da.intValue("isReady")).booleanValue() self.fit_bpm_amp_avg_err = cav_long_twiss_bucket_da.doubleValue("amp_avg_fit_err") twiss_arr_da = cav_long_twiss_bucket_da.childAdaptor("Twiss_arr") alphaX = twiss_arr_da.doubleValue("alphaX") betaX = twiss_arr_da.doubleValue("betaX") emittX = twiss_arr_da.doubleValue("emittX") alphaY = twiss_arr_da.doubleValue("alphaY") betaY = twiss_arr_da.doubleValue("betaY") emittY = twiss_arr_da.doubleValue("emittY") alphaZ = twiss_arr_da.doubleValue("alphaZ") betaZ = twiss_arr_da.doubleValue("betaZ") emittZ = twiss_arr_da.doubleValue("emittZ") self.twiss_arr[0].setTwiss(alphaX,betaX,emittX) self.twiss_arr[1].setTwiss(alphaY,betaY,emittY) self.twiss_arr[2].setTwiss(alphaZ,betaZ,emittZ) self.long_Twiss_arr_err[0] = twiss_arr_da.doubleValue("alphaZ_err") self.long_Twiss_arr_err[1] = twiss_arr_da.doubleValue("betaZ_err") self.long_Twiss_arr_err[2] = twiss_arr_da.doubleValue("emittZ_err") self.long_Twiss_arr_steps[0] = twiss_arr_da.doubleValue("alphaZ_steps") self.long_Twiss_arr_steps[1] = twiss_arr_da.doubleValue("betaZ_steps") self.long_Twiss_arr_steps[2] = twiss_arr_da.doubleValue("emittZ_steps") twiss_fit_da = cav_long_twiss_bucket_da.childAdaptor("Twiss_fit") alphaZ = twiss_fit_da.doubleValue("alphaZ") betaZ = twiss_fit_da.doubleValue("betaZ") emittZ = twiss_fit_da.doubleValue("emittZ") self.long_Twiss_fit.setTwiss(alphaZ,betaZ,emittZ) twiss_matrix_da = cav_long_twiss_bucket_da.childAdaptor("Twiss_matrix") alphaZ = twiss_matrix_da.doubleValue("alphaZ") betaZ = twiss_matrix_da.doubleValue("betaZ") emittZ = twiss_matrix_da.doubleValue("emittZ") self.long_Twiss_matrix.setTwiss(alphaZ,betaZ,emittZ) self.long_Twiss_z2_zzp_zp2_err[0] =twiss_matrix_da.doubleValue("z2_err") self.long_Twiss_z2_zzp_zp2_err[1] =twiss_matrix_da.doubleValue("z_zp_err") self.long_Twiss_z2_zzp_zp2_err[2] =twiss_matrix_da.doubleValue("z2_err") #---- clean up and read the amp graphs self.update() bpm_amps_da = cav_long_twiss_bucket_da.childAdaptor("BPM_Amplitudes") for bpm_amp_da in bpm_amps_da.childAdaptors("BPM"): bpm_wrapper = scl_long_tuneup_controller.getBPM_Wrapper(bpm_amp_da.stringValue("BPM")) for [bpm_wrapper_tmp,amp_plotTh] in self.bpm_amp_plotTh_arr: if(bpm_wrapper_tmp == bpm_wrapper): readGraphDataFromDA(amp_plotTh,bpm_amp_da,"BPM_AMPL_GD") break
def readDataFromXML(self,root_da): accStates_Arr_da = root_da.childAdaptor("Accelerator_States_Arr_Analysis_Panel") if(accStates_Arr_da == null): return accState_isOn_arr = [] for accState_da in accStates_Arr_da.childAdaptors("Accelerator_State"): acc_state_isOn = Boolean(accState_da.intValue("isOn")).booleanValue() record_isOn_arr = [] record_ind_arr = [] records_da = accState_da.childAdaptor("HOR_RECORDS") for ws_lw_size_record_da in records_da.childAdaptors(): ws_lw_size_record_isOn = Boolean(ws_lw_size_record_da.intValue("isOn")).booleanValue() ws_lw_size_record_ind = ws_lw_size_record_da.intValue("index") record_isOn_arr.append(ws_lw_size_record_isOn) record_ind_arr.append(ws_lw_size_record_ind) records_da = accState_da.childAdaptor("VER_RECORDS") for ws_lw_size_record_da in records_da.childAdaptors(): ws_lw_size_record_isOn = Boolean(ws_lw_size_record_da.intValue("isOn")).booleanValue() ws_lw_size_record_ind = ws_lw_size_record_da.intValue("index") record_isOn_arr.append(ws_lw_size_record_isOn) record_ind_arr.append(ws_lw_size_record_ind) accState_isOn_arr.append([acc_state_isOn,record_isOn_arr,record_ind_arr]) #-------now make AccState data for Twiss analysis ------------------------------------- linac_wizard_document = self.linac_wizard_document ws_data_analysis_controller = linac_wizard_document.ws_lw_controller.ws_data_analysis_controller ws_records_table_model = ws_data_analysis_controller.ws_records_table_model ws_rec_table_element_arr = ws_records_table_model.ws_rec_table_element_arr tr_twiss_analysis_controller = linac_wizard_document.tr_twiss_analysis_controller accStatesKeeper = tr_twiss_analysis_controller.accStatesKeeper accStatesKeeper.clean() for [acc_state_isOn,record_isOn_arr,record_ind_arr] in accState_isOn_arr: for itr in range(len(record_isOn_arr)): ws_lw_size_record_ind = record_ind_arr[itr] ws_lw_size_record_isOn = record_isOn_arr[itr] #---- index of the ws_scan_and_fit_record is shifted by 1 to show it in the tables ws_scan_and_fit_record = ws_rec_table_element_arr[ws_lw_size_record_ind-1] ws_scan_and_fit_record.pos = linac_wizard_document.accSeq.getPosition(ws_scan_and_fit_record.ws_node) ws_lw_size_record = tr_twiss_analysis_controller.makeWS_LW_Size_Record() ws_lw_size_record.setUpParams(ws_scan_and_fit_record) accStatesKeeper.addRecord(ws_lw_size_record) ws_lw_size_record.isOn = ws_lw_size_record_isOn dict_panel = tr_twiss_analysis_controller.dict_panel count = 0 for accState_da in accStates_Arr_da.childAdaptors("Accelerator_State"): accState = self.accState_arr[count] accState.isOn = accState_isOn_arr[count][0] readGraphDataFromDA(accState.gd_model_hor,accState_da,"gd_model_hor") readGraphDataFromDA(accState.gd_model_ver,accState_da,"gd_model_ver") readGraphDataFromDA(accState.gd_model_lon,accState_da,"gd_model_lon") button_ind = accState_da.intValue("fit_button_ind") if(button_ind == 0): dict_panel.gaussButton.setSelected(true) if(button_ind == 1): dict_panel.custom_gaussButton.setSelected(true) if(button_ind == 2): dict_panel.custom_rmsButton.setSelected(true) count += 1 tr_twiss_analysis_controller.dict_panel.dict_table.getModel().fireTableDataChanged()
def readDataFromXML(self, cav_wrapper_da, scl_long_tuneup_controller): #print "debug ============= cav_wrapper_da=",cav_wrapper_da.name() self.bpm_wrapper0 = scl_long_tuneup_controller.getBPM_Wrapper( cav_wrapper_da.stringValue("bpm0")) self.bpm_wrapper1 = scl_long_tuneup_controller.getBPM_Wrapper( cav_wrapper_da.stringValue("bpm1")) self.isGood = Boolean(cav_wrapper_da.intValue("isGood")).booleanValue() self.isMeasured = Boolean( cav_wrapper_da.intValue("isMeasured")).booleanValue() self.isAnalyzed = Boolean( cav_wrapper_da.intValue("isAnalyzed")).booleanValue() #--------- read parameters------------------------- cav_wrapper_params_da = cav_wrapper_da.childAdaptor("Params") self.initDesignAmp = cav_wrapper_params_da.doubleValue("initDesignAmp") self.initDesignPhase = cav_wrapper_params_da.doubleValue( "initDesignPhase") self.designAmp = cav_wrapper_params_da.doubleValue("designAmp") self.designPhase = cav_wrapper_params_da.doubleValue("designPhase") self.avg_gap_phase = cav_wrapper_params_da.doubleValue("avg_gap_phase") self.initLiveAmp = cav_wrapper_params_da.doubleValue("initLiveAmp") self.initLivePhase = cav_wrapper_params_da.doubleValue("initLivePhase") self.livePhase = cav_wrapper_params_da.doubleValue("livePhase") self.scanPhaseShift = cav_wrapper_params_da.doubleValue( "scanPhaseShift") self.phase_scan_harm_err = cav_wrapper_params_da.doubleValue( "phase_scan_harm_err") self.phase_scan_harm_amp = cav_wrapper_params_da.doubleValue( "phase_scan_harm_amp") self.eKin_in_guess = cav_wrapper_params_da.doubleValue("eKin_in_guess") self.eKin_out_guess = cav_wrapper_params_da.doubleValue( "eKin_out_guess") self.eKin_in = cav_wrapper_params_da.doubleValue("eKin_in") self.eKin_out = cav_wrapper_params_da.doubleValue("eKin_out") self.eKin_err = cav_wrapper_params_da.doubleValue("eKin_err") self.bpm_eKin_out = cav_wrapper_params_da.doubleValue("bpm_eKin_out") self.model_eKin_out = cav_wrapper_params_da.doubleValue( "model_eKin_out") self.real_scanPhaseShift = cav_wrapper_params_da.doubleValue( "real_scanPhaseShift") #--------- read the cavity rescale data self.rescaleBacket.readDataFromXML(cav_wrapper_da) #--------- read harm. functions------------------------- cav_wrapper_phase_harm_da = cav_wrapper_da.childAdaptor( "Phase_Harm_Func") self.phase_scan_harm_funcion.parsePramArr( cav_wrapper_phase_harm_da.stringValue("params_arr")) cav_wrapper_energy_harm_da = cav_wrapper_da.childAdaptor( "Eenergy_guess_Harm_Func") self.energy_guess_harm_funcion.parsePramArr( cav_wrapper_energy_harm_da.stringValue("params_arr")) #--------- read phase Diff. graph data readGraphDataFromDA(self.phaseDiffPlot, cav_wrapper_da, "Phase_Diff_GD") readGraphDataFromDA(self.phaseDiffPlotTh, cav_wrapper_da, "Phase_Diff_Fit_GD") readGraphDataFromDA(self.eKinOutPlot, cav_wrapper_da, "Ekin_Out_GD") readGraphDataFromDA(self.eKinOutPlotTh, cav_wrapper_da, "Ekin_Out_Fit_GD") #--------- loop over bpm wrappers for this cavity cav_wrapper_bpm_list_da = cav_wrapper_da.childAdaptor("bpm_arr") bpm_wrapper_alias_arr = cav_wrapper_bpm_list_da.stringValue( "bpm_wrappers").split() cav_wrapper_bpm_list_da = cav_wrapper_da.childAdaptor( "bpm_use_in_phase_analysis_arr") use_in_phase_analysis_arr = cav_wrapper_bpm_list_da.stringValue( "use_arr").split() cav_wrapper_bpm_list_da = cav_wrapper_da.childAdaptor( "bpm_use_in_amp_analysis_arr") use_in_amp_analysis_arr = cav_wrapper_bpm_list_da.stringValue( "use_arr").split() bpm_wrapper_arr = [] for bpm_wrapper_alias in bpm_wrapper_alias_arr: bpm_wrapper = scl_long_tuneup_controller.getBPM_Wrapper( bpm_wrapper_alias) bpm_wrapper_arr.append(bpm_wrapper) bpm_wrappers = [] use_in_phase_arr = [] use_in_amp_arr = [] for ind in range(len(bpm_wrapper_arr)): bpm_wrapper = bpm_wrapper_arr[ind] if (bpm_wrapper != null): bpm_wrappers.append(bpm_wrapper) use_in_phase_arr.append(use_in_phase_analysis_arr[ind]) use_in_amp_arr.append(use_in_amp_analysis_arr[ind]) use_in_phase_analysis_arr = use_in_phase_arr use_in_amp_analysis_arr = use_in_amp_arr self.setUpBPM_Wrappers(bpm_wrappers, scl_long_tuneup_controller) for ind in range(len(self.bpm_wrappers)): bpm_wrapper = self.bpm_wrappers[ind] self.bpm_wrappers_useInPhaseAnalysis[ind] = Boolean( int(use_in_phase_analysis_arr[ind])).booleanValue() self.bpm_wrappers_useInAmpBPMs[ind] = Boolean( int(use_in_amp_analysis_arr[ind])).booleanValue() #-------- read the phase scan data # we have to keep in mind that in self.bpm_wrappers we have only bpm wrappers that exist in the # scl_long_tuneup_controller.bpm_wrappers and therefore exist in the self.bpm_amp_phase_dict as keys # Threfore they have (graphDataAmp,graphDataPhase) and we just have to fill them out. cav_wrapper_scan_data_da = cav_wrapper_da.childAdaptor("scan_data") for bpm_wrapper in self.bpm_wrappers: if (not self.bpm_amp_phase_dict.has_key(bpm_wrapper)): continue (graphDataAmp, graphDataPhase) = self.bpm_amp_phase_dict[bpm_wrapper] cav_wrapper_scan_data_bpm_da = cav_wrapper_scan_data_da.childAdaptor( bpm_wrapper.alias) if (cav_wrapper_scan_data_bpm_da != null): readGraphDataFromDA(graphDataPhase, cav_wrapper_scan_data_bpm_da, "phase") readGraphDataFromDA(graphDataAmp, cav_wrapper_scan_data_bpm_da, "amplitude")
def readDataFromXML(self,cav_wrapper_da,scl_long_tuneup_controller): #print "debug ============= cav_wrapper_da=",cav_wrapper_da.name() self.bpm_wrapper0 = scl_long_tuneup_controller.getBPM_Wrapper(cav_wrapper_da.stringValue("bpm0")) self.bpm_wrapper1 = scl_long_tuneup_controller.getBPM_Wrapper(cav_wrapper_da.stringValue("bpm1")) self.isGood = Boolean(cav_wrapper_da.intValue("isGood")).booleanValue() self.isMeasured = Boolean(cav_wrapper_da.intValue("isMeasured")).booleanValue() self.isAnalyzed = Boolean(cav_wrapper_da.intValue("isAnalyzed")).booleanValue() #--------- read parameters------------------------- cav_wrapper_params_da = cav_wrapper_da.childAdaptor("Params") self.initDesignAmp = cav_wrapper_params_da.doubleValue("initDesignAmp") self.initDesignPhase = cav_wrapper_params_da.doubleValue("initDesignPhase") self.designAmp = cav_wrapper_params_da.doubleValue("designAmp") self.designPhase = cav_wrapper_params_da.doubleValue("designPhase") self.avg_gap_phase = cav_wrapper_params_da.doubleValue("avg_gap_phase") self.initLiveAmp = cav_wrapper_params_da.doubleValue("initLiveAmp") self.initLivePhase = cav_wrapper_params_da.doubleValue("initLivePhase") self.livePhase = cav_wrapper_params_da.doubleValue("livePhase") self.scanPhaseShift = cav_wrapper_params_da.doubleValue("scanPhaseShift") self.phase_scan_harm_err = cav_wrapper_params_da.doubleValue("phase_scan_harm_err") self.phase_scan_harm_amp = cav_wrapper_params_da.doubleValue("phase_scan_harm_amp") self.eKin_in_guess = cav_wrapper_params_da.doubleValue("eKin_in_guess") self.eKin_out_guess = cav_wrapper_params_da.doubleValue("eKin_out_guess") self.eKin_in = cav_wrapper_params_da.doubleValue("eKin_in") self.eKin_out = cav_wrapper_params_da.doubleValue("eKin_out") self.eKin_err = cav_wrapper_params_da.doubleValue("eKin_err") self.bpm_eKin_out = cav_wrapper_params_da.doubleValue("bpm_eKin_out") self.model_eKin_out = cav_wrapper_params_da.doubleValue("model_eKin_out") self.real_scanPhaseShift = cav_wrapper_params_da.doubleValue("real_scanPhaseShift") #--------- read the cavity rescale data self.rescaleBacket. readDataFromXML(cav_wrapper_da) #--------- read harm. functions------------------------- cav_wrapper_phase_harm_da = cav_wrapper_da.childAdaptor("Phase_Harm_Func") self.phase_scan_harm_funcion.parsePramArr(cav_wrapper_phase_harm_da.stringValue("params_arr")) cav_wrapper_energy_harm_da = cav_wrapper_da.childAdaptor("Eenergy_guess_Harm_Func") self.energy_guess_harm_funcion.parsePramArr(cav_wrapper_energy_harm_da.stringValue("params_arr")) #--------- read phase Diff. graph data readGraphDataFromDA(self.phaseDiffPlot,cav_wrapper_da,"Phase_Diff_GD") readGraphDataFromDA(self.phaseDiffPlotTh,cav_wrapper_da,"Phase_Diff_Fit_GD") readGraphDataFromDA(self.eKinOutPlot,cav_wrapper_da,"Ekin_Out_GD") readGraphDataFromDA(self.eKinOutPlotTh,cav_wrapper_da,"Ekin_Out_Fit_GD") #--------- loop over bpm wrappers for this cavity cav_wrapper_bpm_list_da = cav_wrapper_da.childAdaptor("bpm_arr") bpm_wrapper_alias_arr = cav_wrapper_bpm_list_da.stringValue("bpm_wrappers").split() cav_wrapper_bpm_list_da = cav_wrapper_da.childAdaptor("bpm_use_in_phase_analysis_arr") use_in_phase_analysis_arr = cav_wrapper_bpm_list_da.stringValue("use_arr").split() cav_wrapper_bpm_list_da = cav_wrapper_da.childAdaptor("bpm_use_in_amp_analysis_arr") use_in_amp_analysis_arr = cav_wrapper_bpm_list_da.stringValue("use_arr").split() bpm_wrapper_arr = [] for bpm_wrapper_alias in bpm_wrapper_alias_arr: bpm_wrapper = scl_long_tuneup_controller.getBPM_Wrapper(bpm_wrapper_alias) bpm_wrapper_arr.append(bpm_wrapper) bpm_wrappers = [] use_in_phase_arr = [] use_in_amp_arr = [] for ind in range(len(bpm_wrapper_arr)): bpm_wrapper = bpm_wrapper_arr[ind] if(bpm_wrapper != null): bpm_wrappers.append(bpm_wrapper) use_in_phase_arr.append(use_in_phase_analysis_arr[ind]) use_in_amp_arr.append(use_in_amp_analysis_arr[ind]) use_in_phase_analysis_arr = use_in_phase_arr use_in_amp_analysis_arr = use_in_amp_arr self.setUpBPM_Wrappers(bpm_wrappers,scl_long_tuneup_controller) for ind in range(len(self.bpm_wrappers)): bpm_wrapper = self.bpm_wrappers[ind] self.bpm_wrappers_useInPhaseAnalysis[ind] = Boolean(int(use_in_phase_analysis_arr[ind])).booleanValue() self.bpm_wrappers_useInAmpBPMs[ind] = Boolean(int(use_in_amp_analysis_arr[ind])).booleanValue() #-------- read the phase scan data # we have to keep in mind that in self.bpm_wrappers we have only bpm wrappers that exist in the # scl_long_tuneup_controller.bpm_wrappers and therefore exist in the self.bpm_amp_phase_dict as keys # Threfore they have (graphDataAmp,graphDataPhase) and we just have to fill them out. cav_wrapper_scan_data_da = cav_wrapper_da.childAdaptor("scan_data") for bpm_wrapper in self.bpm_wrappers: if(not self.bpm_amp_phase_dict.has_key(bpm_wrapper)): continue (graphDataAmp,graphDataPhase) = self.bpm_amp_phase_dict[bpm_wrapper] cav_wrapper_scan_data_bpm_da = cav_wrapper_scan_data_da.childAdaptor(bpm_wrapper.alias) if(cav_wrapper_scan_data_bpm_da != null): readGraphDataFromDA(graphDataPhase,cav_wrapper_scan_data_bpm_da,"phase") readGraphDataFromDA(graphDataAmp,cav_wrapper_scan_data_bpm_da,"amplitude")