def __init__(self, pattern=None, integerDigits=None, fractionDigits=None, **kwargs): if integerDigits is not None: kwargs['maximumIntegerDigits'] = integerDigits kwargs['minimumIntegerDigits'] = integerDigits if fractionDigits is not None: kwargs['maximumFractionDigits'] = fractionDigits kwargs['minimumFractionDigits'] = fractionDigits if pattern is not None: DecimalFormat.__init__(self, pattern, **kwargs) else: DecimalFormat.__init__(self, **kwargs)
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.setLayout(FlowLayout(FlowLayout.LEFT,3,3)) #----etched border etched_border = BorderFactory.createEtchedBorder() titled_border = BorderFactory.createTitledBorder(etched_border,"BPMs Phase Offsets: start from CCL4 forward") self.setBorder(titled_border) #--- buttons get_offsets_ccl1_button = JButton("Calculate Offsets from CCL4 forward") get_offsets_ccl1_button.addActionListener(Offsets_from_CCL4_Button_Listener(self.scl_long_tuneup_controller)) ccl4_energy_lbl = JLabel("<html> SCL Entrance E<SUB>kin</SUB>[MeV] = <html>",JLabel.RIGHT) self.ccl4_energy_text = DoubleInputTextField(185.6,DecimalFormat("###.###"),6) self.add(get_offsets_ccl1_button) self.add(ccl4_energy_lbl) self.add(self.ccl4_energy_text)
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.setLayout(BorderLayout()) #----etched border etched_border = BorderFactory.createEtchedBorder() titled_border = BorderFactory.createTitledBorder(etched_border,"SetUp Cavities' New Design Amplitudes and Phases") self.setBorder(titled_border) #--- buttons------------ init_model_button = JButton("Init SCL Model") init_model_button.addActionListener(Init_Tracking_Model_Listener(self.scl_long_tuneup_controller)) read_epics_button = JButton("<html>Get New Live A<SUB>EPICS</SUB><html>") read_epics_button.addActionListener(Read_From_EPICS_Listener(self.scl_long_tuneup_controller)) copy_old_button = JButton("Restore Synch. Phases") copy_old_button.addActionListener(Copy_Old_to_New_Listener(self.scl_long_tuneup_controller)) change_selected_lbl = JLabel("<html>Change Selected New Δφ<SUB>Synch</SUB>(deg)<html>",JLabel.RIGHT) self.avg_gap_phase_wheel = Wheelswitch() self.avg_gap_phase_wheel.setFormat("+###.#") self.avg_gap_phase_wheel.setValue(0.) self.avg_gap_phase_wheel.addPropertyChangeListener("value", Wheel_Listener(self.scl_long_tuneup_controller)) self.is_wheel_listen = true #---- buttons panel buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) buttons_panel.add(init_model_button) buttons_panel.add(read_epics_button) buttons_panel.add(copy_old_button) #---- wheel panle wheel_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) wheel_panel.add(change_selected_lbl) wheel_panel.add(self.avg_gap_phase_wheel) #---- the energy panel energy_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) energy_calc_button = JButton("<html>Calculate E<SUB>kin</SUB><html>") energy_calc_button.addActionListener(Calculate_Energy_Listener(self.scl_long_tuneup_controller)) energy_lbl = JLabel("<html>SCL Final E<SUB>kin</SUB>[MeV]=<html>",JLabel.RIGHT) self.energy_text = DoubleInputTextField(0.,DecimalFormat("####.#####"),12) energy_panel.add(energy_calc_button) energy_panel.add(energy_lbl) energy_panel.add(self.energy_text) #---- add to the main subpanel self.add(buttons_panel,BorderLayout.NORTH) self.add(energy_panel,BorderLayout.CENTER) self.add(wheel_panel,BorderLayout.SOUTH) #---- this is a holder for RF_Gap_Phases_Holder_for_Table_Selection self.rf_gap_phases_holder = null
def __init__(self,ws_scan_Record): self.isOn = true self.index = -1 self.pos = 0. self.fit_is_good = false self.gauss_sigma = ws_scan_Record.gauss_sigma self.ws_node = ws_scan_Record.ws_node self.ws_direction = ws_scan_Record.ws_direction self.custom_gauss_sigma = 0. self.custom_rms_sigma = 0. self.gd_wf = BasicGraphData() self.gd_fit_wf = BasicGraphData() self.gd_log_wf = BasicGraphData() self.gd_log_fit_wf = BasicGraphData() self.gd_wf.setDrawLinesOn(false) self.gd_log_wf.setDrawLinesOn(false) self.gd_fit_wf.setDrawPointsOn(false) self.gd_log_fit_wf.setDrawPointsOn(false) self.gd_wf.setGraphPointSize(5) self.gd_log_wf.setGraphPointSize(5) self.gd_fit_wf.setLineThick(3) self.gd_log_fit_wf.setLineThick(3) self.gd_wf.setGraphColor(Color.BLUE) self.gd_log_wf.setGraphColor(Color.BLUE) self.gd_fit_wf.setGraphColor(Color.RED) self.gd_log_fit_wf.setGraphColor(Color.RED) legendKey = GRAPH_LEGEND_KEY legendName = self.ws_node.getId() if(self.ws_direction == WS_DIRECTION_HOR): legendName += " Hor. " if(self.ws_direction == WS_DIRECTION_VER): legendName += " Ver. " self.gd_wf.setGraphProperty(legendKey,legendName+" Data") self.gd_log_wf.setGraphProperty(legendKey,"Log "+legendName+" Data ") self.gd_fit_wf.setGraphProperty(legendKey,"Log "+legendName+" Fit ") self.gd_log_fit_wf.setGraphProperty(legendKey,"Log "+legendName+" Fit ") #----------- copy Graph data ------------- for i in range(ws_scan_Record.gd_wf.getNumbOfPoints()): self.gd_wf.addPoint(ws_scan_Record.gd_wf.getX(i),ws_scan_Record.gd_wf.getY(i)) for i in range(ws_scan_Record.gd_log_wf.getNumbOfPoints()): self.gd_log_wf.addPoint(ws_scan_Record.gd_log_wf.getX(i),ws_scan_Record.gd_log_wf.getY(i)) self.n_fit_points = 150 self.quad_dict = {} self.cav_amp_phase_dict = {} self.param_dict = [self.quad_dict,self.cav_amp_phase_dict] #-----Gauss Fitting params---------------- self.CONST = DoubleInputTextField(0.,DecimalFormat("0.###E0#"),10) self.A0 = DoubleInputTextField(0.,DecimalFormat("0.###E0#"),10) self.X_CENTER = DoubleInputTextField(0.,DecimalFormat("0.###E0#"),10) self.SIGMA = DoubleInputTextField(self.gauss_sigma,DecimalFormat("0.###E0#"),10) self.X_MIN = DoubleInputTextField(ws_scan_Record.left_limit,DecimalFormat("0.###E0#"),10) self.X_MAX = DoubleInputTextField(ws_scan_Record.right_limit,DecimalFormat("0.###E0#"),10)
int m,y,e; scanf("%d-%d\n%d",&m,&y,&e); y=y+(e/12); m=m+(e%12); if(m>12){ m=m%12; y++; } printf("%02d-%d",m,y); } Java: import java.util.*; import java.text.DecimalFormat; public class Hello { public static void main(String[] args) { DecimalFormat df = new DecimalFormat("00"); Scanner sc = new Scanner(System.in); String[] date = sc.nextLine().split("[-]"); int months = sc.nextInt(); int initialmonth=(Integer.parseInt(date[0])+months%12); int year = (Integer.parseInt(date[1])); year+=(Integer.parseInt(date[0])+months)%12==0? (int)((Integer.parseInt(date[0])+months)/12)-1 :(int)((Integer.parseInt(date[0])+months)/12); int finalmonths = initialmonth%12==0?12:initialmonth%12; String expmonth=df.format(finalmonths); System.out.println(expmonth+"-"+year); } } Python: a=list(input().split("-"))
def __init__(self, main_loop_controller, cav_wrapper): self.main_loop_controller = main_loop_controller self.cav_wrapper = cav_wrapper self.main_panel = JPanel(BorderLayout()) self.parameters_panel = JPanel(BorderLayout()) #---- backward cavity amplitude move params panel0 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) cav_amp_backward_steps_mult_label = JLabel( "N cav. amp. backward steps multiplier =", JLabel.RIGHT) self.cav_amp_backward_steps_mult_text = DoubleInputTextField( 1.0, DecimalFormat("##.##"), 5) panel0.add(cav_amp_backward_steps_mult_label) panel0.add(self.cav_amp_backward_steps_mult_text) #---- cavity's wait time multiplier panel1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) cav_amp_wait_time_mult_label = JLabel( "Cav. amp. time wait multiplier =", JLabel.RIGHT) self.cav_amp_wait_time_mult_text = DoubleInputTextField( 3.0, DecimalFormat("##.##"), 5) panel1.add(cav_amp_wait_time_mult_label) panel1.add(self.cav_amp_wait_time_mult_text) #---- cavity's safe amplitude up and down limits panel2 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) safe_relative_amp_up_label = JLabel("Cav. amp. safe Up [%]=", JLabel.RIGHT) self.safe_relative_amp_up_text = DoubleInputTextField( 7.0, DecimalFormat("##.##"), 5) panel2.add(safe_relative_amp_up_label) panel2.add(self.safe_relative_amp_up_text) panel3 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) safe_relative_amp_down_label = JLabel("Cav. amp. safe Down [%]=", JLabel.RIGHT) self.safe_relative_amp_down_text = DoubleInputTextField( 7.0, DecimalFormat("##.##"), 5) panel3.add(safe_relative_amp_down_label) panel3.add(self.safe_relative_amp_down_text) #----- cavity's guess phase[deg] and amplitude[%] corrections after 360 deg full scan for inner BPMs panel4 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) guess_phase_shift_label = JLabel( "Cav. Guess Phase Shift after Full Scan [deg]=", JLabel.RIGHT) self.guess_phase_shift_text = DoubleInputTextField( 0.0, DecimalFormat("###.##"), 6) panel4.add(guess_phase_shift_label) panel4.add(self.guess_phase_shift_text) panel5 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 3)) guess_cav_amp_shift_label = JLabel( "Cav. Amp Shift after Full Scan [%]=", JLabel.RIGHT) self.guess_cav_amp_shift_text = DoubleInputTextField( 0.0, DecimalFormat("###.##"), 6) panel5.add(guess_cav_amp_shift_label) panel5.add(self.guess_cav_amp_shift_text) #----------------------------------------------- params_panel = JPanel(GridLayout(6, 1, 1, 1)) params_panel.add(panel0) params_panel.add(panel1) params_panel.add(panel2) params_panel.add(panel3) params_panel.add(panel4) params_panel.add(panel5) #------------------------------------------------ self.parameters_panel.add(params_panel, BorderLayout.NORTH) #------------------------------------------------ self.scan_progress_bar = Scan_Progress_Bar() #------------------------------------------------ cav_wrapper.safe_relative_amp_up_text = self.safe_relative_amp_up_text cav_wrapper.safe_relative_amp_down_text = self.safe_relative_amp_down_text
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.setLayout(BorderLayout()) #----etched border etched_border = BorderFactory.createEtchedBorder() titled_border = BorderFactory.createTitledBorder(etched_border,"BPMs Phase Offsets: start from HEBT1 backward") self.setBorder(titled_border) #--- stage 1 GUI elements stage1_lbl = JLabel("Stage 1.",JLabel.RIGHT) get_statistics_button = JButton("Start HEBT1 BPMs Satatistics") get_statistics_button.addActionListener(Get_HEBT_Statistics_Button_Listener(self.scl_long_tuneup_controller)) stop_statistics_button = JButton("Stop") stop_statistics_button.addActionListener(Stop_HEBT_Statistics_Button_Listener(self.scl_long_tuneup_controller)) iter_lbl = JLabel("Iterations=",JLabel.RIGHT) self.iter_text = DoubleInputTextField(10.0,DecimalFormat("##"),2) iter_left_lbl = JLabel("Count=",JLabel.RIGHT) self.iter_left_text = DoubleInputTextField(0.0,DecimalFormat("##"),2) ring_energy_lbl = JLabel("<html>E<SUB>RING</SUB>[MeV]= <html>",JLabel.RIGHT) self.ring_energy_text = DoubleInputTextField(0.0,DecimalFormat("####.###"),8) ring_energy_err_lbl = JLabel(" +- ",JLabel.RIGHT) self.ring_energy_err_text = DoubleInputTextField(0.0,DecimalFormat("####.###"),8) panel_1_1 = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) panel_1_1.setBorder(etched_border) panel_1_1.add(get_statistics_button) panel_1_1.add(stop_statistics_button) panel_1_1.add(iter_lbl) panel_1_1.add(self.iter_text) panel_1_1.add(iter_left_lbl) panel_1_1.add(self.iter_left_text) panel_1_1.add(ring_energy_lbl) panel_1_1.add(self.ring_energy_text) panel_1_1.add(ring_energy_err_lbl) panel_1_1.add(self.ring_energy_err_text) get_em_phase_offsets_button = JButton("Get BPM Offsets from Energy Meter") get_em_phase_offsets_button.addActionListener(Get_Energy_Meter_Offsets_Button_Listener(self.scl_long_tuneup_controller)) panel_1_2 = JPanel(FlowLayout(FlowLayout.LEFT,3,3)) panel_1_2.setBorder(etched_border) panel_1_2.add(get_em_phase_offsets_button) #--- stage 2 GUI elements stage2_lbl = JLabel("Stage 2.",JLabel.RIGHT) get_offsets_hebt1_button = JButton("Calculate Offsets from HEBT1 backward") get_offsets_hebt1_button.addActionListener(Offsets_from_HEBT1_Button_Listener(self.scl_long_tuneup_controller)) init_energy_lbl = JLabel("<html> SCL Entrance E<SUB>kin</SUB>[MeV] = <html>",JLabel.RIGHT) self.init_energy_text = DoubleInputTextField(0.,DecimalFormat("###.###"),8) #------ Stage 1 Panel stage1_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) stage1_panel.setBorder(etched_border) stage1_panel.add(stage1_lbl) stage1_panel.add(panel_1_1) stage1_panel.add(panel_1_2) #------ Stage 2 Panel stage2_panel = JPanel(FlowLayout(FlowLayout.LEFT,10,3)) stage2_panel.setBorder(etched_border) stage2_panel.add(stage2_lbl) stage2_panel.add(get_offsets_hebt1_button) stage2_panel.add(init_energy_lbl) stage2_panel.add(self.init_energy_text) #-------------------------------------------- self.add(stage1_panel,BorderLayout.NORTH) self.add(stage2_panel,BorderLayout.SOUTH) #------ Statistic run controller self.statistic_state_controller = StatisticStateController()
def __init__(self,dtl_acceptance_scans_controller,dtl_acc_scan_cavity_controller): self.dtl_acceptance_scans_controller = dtl_acceptance_scans_controller self.main_loop_controller = self.dtl_acceptance_scans_controller.main_loop_controller self.dtl_acc_scan_cavity_controller = dtl_acc_scan_cavity_controller self.setLayout(BorderLayout()) self.setBorder(BorderFactory.createEtchedBorder()) etched_border = BorderFactory.createEtchedBorder() #---------------------------------------------------- scan_params_panel_1 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) scan_params_panel_1.setBorder(BorderFactory.createEtchedBorder()) scan_params_panel_1.setBorder(BorderFactory.createTitledBorder(etched_border,"Cavity Amplitude Scan Parameters")) scan_params_panel_2 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) scan_params_panel_2.setBorder(BorderFactory.createTitledBorder(etched_border,"Cavity Phase Scan Parameters")) scan_params_panel_3 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) scan_params_panel_3.setBorder(BorderFactory.createTitledBorder(etched_border,"Cavity Live Parameters")) self.scan_cav_amplitude_button = JRadioButton("Scan Ampl.") scan_params_panel_1.add(self.scan_cav_amplitude_button) #------------------------------------------------------------ min_cav_amp_label = JLabel(" Min=",JLabel.RIGHT) max_cav_amp_label = JLabel(" Max=",JLabel.RIGHT) cav_amp_points_label = JLabel(" Points=",JLabel.RIGHT) time_amp_scan_label = JLabel(" Ampl. Change Time[sec]=",JLabel.RIGHT) self.min_cav_amp_text = DoubleInputTextField(0.,DecimalFormat("#.####"),5) self.max_cav_amp_text = DoubleInputTextField(0.,DecimalFormat("#.####"),5) self.cav_amp_points_text = DoubleInputTextField(3,DecimalFormat("##"),3) self.time_amp_scan_text = DoubleInputTextField(20.,DecimalFormat("###"),3) scan_params_panel_1.add(min_cav_amp_label) scan_params_panel_1.add(self.min_cav_amp_text) scan_params_panel_1.add(max_cav_amp_label) scan_params_panel_1.add(self.max_cav_amp_text) scan_params_panel_1.add(cav_amp_points_label) scan_params_panel_1.add(self.cav_amp_points_text) scan_params_panel_1.add(time_amp_scan_label) scan_params_panel_1.add(self.time_amp_scan_text) #---------------------------------------------- phase_step_label = JLabel("Step[deg]=",JLabel.RIGHT) phase_min_label = JLabel(" Min[deg]=",JLabel.RIGHT) phase_max_label = JLabel(" Max[deg]=",JLabel.RIGHT) phase_scan_time_step_label = JLabel(" Time/Step[sec]=",JLabel.RIGHT) self.phase_step_text = DoubleInputTextField(3.,DecimalFormat("##.##"),5) self.phase_min_text = DoubleInputTextField(-180.,DecimalFormat("####.#"),6) self.phase_max_text = DoubleInputTextField(180.,DecimalFormat("####.#"),6) self.phase_scan_time_step_text = DoubleInputTextField(1.5,DecimalFormat("##.#"),4) scan_params_panel_2.add(phase_step_label) scan_params_panel_2.add(self.phase_step_text) scan_params_panel_2.add(phase_min_label) scan_params_panel_2.add(self.phase_min_text) scan_params_panel_2.add(phase_max_label) scan_params_panel_2.add(self.phase_max_text) scan_params_panel_2.add(phase_scan_time_step_label) scan_params_panel_2.add(self.phase_scan_time_step_text) #---------------------------------------------- cav_ampl_live_label = JLabel("Cavity Ampl.=",JLabel.RIGHT) cav_phase_live_label = JLabel(" Phase[deg]=",JLabel.RIGHT) self.cav_ampl_live_text = DoubleInputTextField(0.,DecimalFormat("#.###"),5) self.cav_phase_live_text = DoubleInputTextField(0.,DecimalFormat("####.##"),7) scan_params_panel_3.add(cav_ampl_live_label) scan_params_panel_3.add(self.cav_ampl_live_text) scan_params_panel_3.add(cav_phase_live_label) scan_params_panel_3.add(self.cav_phase_live_text) #----------------------------------------------- cntrl_upper_panel = JPanel(GridLayout(3,1,1,1)) cntrl_upper_panel.add(scan_params_panel_1) cntrl_upper_panel.add(scan_params_panel_2) cntrl_upper_panel.add(scan_params_panel_3) #---------------------------------------------- scan_res_panel = JPanel(BorderLayout()) #---------------------------------------------- left_scan_res_panel_0 = JPanel(BorderLayout()) scan_progress_panel = self.dtl_acc_scan_cavity_controller.scan_progress_bar.scan_progress_panel left_scan_res_panel_0.add(scan_progress_panel,BorderLayout.CENTER) #--------------------------------------------- left_scan_res_panel_1 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) make_analysis_button = JButton("Make Analysis") make_analysis_button.addActionListener(Make_Analysis_Of_Scan_Button_Listener(self.dtl_acceptance_scans_controller,self.dtl_acc_scan_cavity_controller)) set_new_phase_button = JButton("Set New Phase to EPICS") set_new_phase_button.addActionListener(Set_New_Phase_Button_Listener(self.dtl_acceptance_scans_controller,self.dtl_acc_scan_cavity_controller)) left_scan_res_panel_1.add(make_analysis_button) left_scan_res_panel_1.add(set_new_phase_button) #---------------------------------------------- left_scan_res_panel_2 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) new_cav_phase_label = JLabel("New Phase[deg]=",JLabel.RIGHT) self.new_cav_phase_text = DoubleInputTextField(0.,DecimalFormat("####.##"),7) left_scan_res_panel_2.add(new_cav_phase_label) left_scan_res_panel_2.add(self.new_cav_phase_text) #---------------------------------------------- left_scan_res_panel_3 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) shift_scan_button = JButton("Shift Scan by +10 deg") shift_scan_button.addActionListener(Shift_Scan_Button_Listener(self.dtl_acceptance_scans_controller,self.dtl_acc_scan_cavity_controller)) make_pattern_button = JButton("Make a Pattern") make_pattern_button.addActionListener(Make_Pattern_Button_Listener(self.dtl_acceptance_scans_controller,self.dtl_acc_scan_cavity_controller)) left_scan_res_panel_3.add(shift_scan_button) left_scan_res_panel_3.add(make_pattern_button) #---------------------------------------------- left_scan_res_panel_4 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) acc_scan_width_label = JLabel("Acc. Scan Width[deg]=",JLabel.RIGHT) self.acc_scan_width_text = DoubleInputTextField(0.,DecimalFormat("####.##"),7) left_scan_res_panel_4.add(acc_scan_width_label) left_scan_res_panel_4.add(self.acc_scan_width_text) #---------------------------------------------- left_scan_res_panel_5 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) new_cav_amp_label = JLabel("New Cav. Amplitude =",JLabel.RIGHT) self.new_cav_amp_text = DoubleInputTextField(0.,DecimalFormat("#.####"),7) left_scan_res_panel_5.add(new_cav_amp_label) left_scan_res_panel_5.add(self.new_cav_amp_text) #---------------------------------------------- scan_res_grid_panel = JPanel(GridLayout(6,1,1,1)) scan_res_grid_panel.add(left_scan_res_panel_0) scan_res_grid_panel.add(left_scan_res_panel_1) scan_res_grid_panel.add(left_scan_res_panel_2) scan_res_grid_panel.add(left_scan_res_panel_3) scan_res_grid_panel.add(left_scan_res_panel_4) scan_res_grid_panel.add(left_scan_res_panel_5) scan_res_panel.add(scan_res_grid_panel,BorderLayout.NORTH) #---------------------------------------------- self.scan_data_graph = Acceptance_Graphs_Panel_Holder(self.dtl_acceptance_scans_controller) self.add(cntrl_upper_panel,BorderLayout.NORTH) self.add(self.scan_data_graph.getGraphsPanel(),BorderLayout.CENTER) self.add(scan_res_panel,BorderLayout.WEST)
def __init__(self, linac_wizard_document, transverse_twiss_fitting_controller): self.linac_wizard_document = linac_wizard_document self.transverse_twiss_fitting_controller = transverse_twiss_fitting_controller self.main_panel = JPanel(BorderLayout()) tmp_panel = JPanel(GridLayout(7, 2)) self.eKin_text = DoubleInputTextField(0., DecimalFormat("###.###"), 8) eKin_lbl = JLabel("eKin[MeV]=", JLabel.RIGHT) self.current_text = DoubleInputTextField(0., DecimalFormat("###.###"), 8) current_lbl = JLabel("Curr.[mA]=", JLabel.RIGHT) self.fit_err_text = DoubleInputTextField(0., DecimalFormat("###.###"), 8) fit_err_lbl = JLabel("Fit Err,%=", JLabel.RIGHT) self.fit_err_text.setValue(5.0) self.fit_iter_text = DoubleInputTextField(0., DecimalFormat("#####"), 8) iter_lbl = JLabel("Fit Iterations=", JLabel.RIGHT) self.fit_iter_text.setValue(200) self.fit_iter_left_text = DoubleInputTextField(0., DecimalFormat("#####"), 8) iter_left_lbl = JLabel("Iters. Left=", JLabel.RIGHT) self.avg_diff_text = DoubleInputTextField(0., DecimalFormat("##.####"), 8) avg_diff_lbl = JLabel("Avg.Diff.[mm]=", JLabel.RIGHT) tmp_panel.add(eKin_lbl) tmp_panel.add(self.eKin_text) tmp_panel.add(current_lbl) tmp_panel.add(self.current_text) tmp_panel.add(fit_err_lbl) tmp_panel.add(self.fit_err_text) tmp0_lbl = JLabel("==========", JLabel.RIGHT) tmp1_lbl = JLabel("==========", JLabel.RIGHT) tmp_panel.add(tmp0_lbl) tmp_panel.add(tmp1_lbl) tmp_panel.add(iter_lbl) tmp_panel.add(self.fit_iter_text) tmp_panel.add(iter_left_lbl) tmp_panel.add(self.fit_iter_left_text) tmp_panel.add(avg_diff_lbl) tmp_panel.add(self.avg_diff_text) #----etched border etched_border = BorderFactory.createEtchedBorder() #------buttons panel ------------ one_pass_button = JButton("Make One Pass") one_pass_button.addActionListener( One_Pass_Listener(self.linac_wizard_document)) fit_button = JButton("Start Fitting") fit_button.addActionListener( Twiss_Fitting_Listener(self.linac_wizard_document)) stop_fit_button = JButton("Stop Fitting") stop_fit_button.addActionListener( Stop_Twiss_Fitting_Listener(self.linac_wizard_document)) buttons_panel = JPanel(GridLayout(3, 1)) button0_panel = JPanel(FlowLayout(FlowLayout.CENTER, 3, 3)) button0_panel.add(one_pass_button) button1_panel = JPanel(FlowLayout(FlowLayout.CENTER, 3, 3)) button1_panel.add(fit_button) button2_panel = JPanel(FlowLayout(FlowLayout.CENTER, 3, 3)) button2_panel.add(stop_fit_button) buttons_panel.add(button0_panel) buttons_panel.add(button1_panel) buttons_panel.add(button2_panel) #--------- Final Twiss parameters table ----- self.final_twiss_params_holder = Twiss_Params_Holder() self.finalTwiss_table = JTable( Final_Twiss_Table_Model(self.final_twiss_params_holder)) self.finalTwiss_table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION) self.finalTwiss_table.setFillsViewportHeight(true) self.finalTwiss_table.setPreferredScrollableViewportSize( Dimension(180, 80)) final_to_init_button = JButton("Copy Results To Initial Twiss") final_to_init_button.addActionListener( Copy_Twiss_Listener(self.transverse_twiss_fitting_controller)) button2_panel = JPanel(FlowLayout(FlowLayout.CENTER, 3, 3)) button2_panel.add(final_to_init_button) finalTwiss_panel = JPanel(BorderLayout()) finalTwiss_panel.add(JScrollPane(self.finalTwiss_table), BorderLayout.CENTER) finalTwiss_panel.add(button2_panel, BorderLayout.SOUTH) border = BorderFactory.createTitledBorder( etched_border, "Final Twiss Fitting Results") finalTwiss_panel.setBorder(border) #---------make main panel -------------- tmp1_panel = JPanel(BorderLayout()) tmp1_panel.add(tmp_panel, BorderLayout.NORTH) tmp1_panel.add(buttons_panel, BorderLayout.SOUTH) tmp2_panel = JPanel(BorderLayout()) tmp2_panel.add(tmp1_panel, BorderLayout.WEST) tmp2_panel.add(finalTwiss_panel, BorderLayout.CENTER) self.main_panel.add(tmp2_panel, BorderLayout.NORTH)
shutdown_contract.callFunction("on_shut_down", [Monad.getContext()]) source.appendChild(MonadMessage("Shut down successfully.").toXml(doc)) elif inv.hasParameter("run_startup"): startup_contract = Contract.getNonCoreContract("startup") startup_contract.callFunction("on_start_up", [Monad.getContext()]) elif inv.hasParameter("cancel_backend"): backend_pid = inv.getLong("backend_pid") con = Hiber.session().connection() stmt = con.createStatement() stmt.execute("select pg_terminate_backend(" + str(backend_pid) + ")") stmt.close() Hiber.commit() source.appendChild(MonadMessage("Cancelled backend.").toXml(doc)) df = DecimalFormat("###,###,###,###,##0") runtime = Runtime.getRuntime() source.setAttribute("free-memory", df.format(runtime.freeMemory())) source.setAttribute("max-memory", df.format(runtime.maxMemory())) source.setAttribute("total-memory", df.format(runtime.totalMemory())) source.setAttribute("available-processors", str(runtime.availableProcessors())) source.setAttribute("system-load-average", str(ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage())) mon = JavaSysMon() source.setAttribute("cpu-frequency-in-hz", df.format(mon.cpuFrequencyInHz())) source.setAttribute("current-pid", df.format(mon.currentPid())) source.setAttribute("num-cpus", df.format(mon.numCpus())) source.setAttribute("os-name", mon.osName()) source.setAttribute("uptime-in-seconds", df.format(mon.uptimeInSeconds())) cpu = mon.cpuTimes()
def __init__(self,scl_long_tuneup_controller): #--- scl_long_tuneup_controller the parent document for all SCL tune up controllers self.scl_long_tuneup_controller = scl_long_tuneup_controller self.main_panel = JPanel(BorderLayout()) #----etched border etched_border = BorderFactory.createEtchedBorder() #------top init panel----------------------- top_init_panel = JPanel(BorderLayout()) init_panel = JPanel(BorderLayout()) init_panel0 = JPanel(BorderLayout()) init_button = JButton(" Init BPMs and Cavities ") get_quad_fields_button = JButton(" Get Quad Fields ") restore_init_button = JButton(" Restore Cavities' Phases ") set_unblanked_button = JButton("Un-blank all Cavities") init_button.addActionListener(Init_BPMs_and_Cavities_Button_Listener(self.scl_long_tuneup_controller)) get_quad_fields_button.addActionListener(Get_Quad_Fields_Button_Listener(self.scl_long_tuneup_controller)) restore_init_button.addActionListener(Restore_Init_BPMs_and_Cavities_Button_Listener(self.scl_long_tuneup_controller)) set_unblanked_button.addActionListener(Unblank_All_Cavities_Button_Listener(self.scl_long_tuneup_controller)) expl_text = "Checks response from BPMs and memorizes initial amp./phases of cavities. \n" expl_text = expl_text + " D - Design, I.L. - Initial Live values. \n" expl_text = expl_text + " BPM1 and BPM2 will be used for the cavity phase setup during the raw phase scan.\n" init_text = JTextArea(expl_text) init_panel01 = JPanel(GridLayout(4,1,10,10)) init_panel01.add(init_button) init_panel01.add(get_quad_fields_button) init_panel01.add(restore_init_button) init_panel01.add(set_unblanked_button) init_panel01.setBorder(etched_border) init_panel0.add(init_panel01,BorderLayout.WEST) init_panel0.add(init_text,BorderLayout.CENTER) init_panel1 = JPanel(FlowLayout(FlowLayout.LEFT,5,5)) init_set_bpm1_button = JButton(" Set BPM1 to Selected Cavs ") init_set_bpm2_button = JButton(" Set BPM2 to Selected Cavs ") init_set_bpm3_button = JButton(" Clear BPM1/BPM2 for Selected Cavs ") init_set_bpm1_button.addActionListener(Init_Set_BPM_to_Cav_Button_Listener(self.scl_long_tuneup_controller,1)) init_set_bpm2_button.addActionListener(Init_Set_BPM_to_Cav_Button_Listener(self.scl_long_tuneup_controller,2)) init_set_bpm3_button.addActionListener(Clear_BPM0_BPM1_Button_Listener(self.scl_long_tuneup_controller)) min_bpm_dist_label = JLabel("Min. BPM 1-2 Dist.[m]=",JLabel.RIGHT) self.min_bpm_dist_txt = DoubleInputTextField(22.0,DecimalFormat("###.##"),6) max_bpm_dist_label = JLabel("Max.=",JLabel.RIGHT) self.max_bpm_dist_txt = DoubleInputTextField(75.0,DecimalFormat("###.##"),6) init_panel1.add(init_set_bpm1_button) init_panel1.add(init_set_bpm2_button) init_panel1.add(init_set_bpm3_button) init_panel1.add(min_bpm_dist_label) init_panel1.add(self.min_bpm_dist_txt) init_panel1.add(max_bpm_dist_label) init_panel1.add(self.max_bpm_dist_txt) init_panel.add(init_panel0,BorderLayout.SOUTH) init_panel.add(init_panel1,BorderLayout.NORTH) init_panel.setBorder(etched_border) top_init_panel.add(init_panel,BorderLayout.NORTH) self.bpm_table = JTable(Init_BPMs_Table_Model(self.scl_long_tuneup_controller)) self.cav_table = JTable(Init_Cavities_Table_Model(self.scl_long_tuneup_controller)) self.bpm_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.cav_table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION) self.bpm_table.setFillsViewportHeight(true) self.cav_table.setFillsViewportHeight(true) self.bpm_table.setPreferredScrollableViewportSize(Dimension(300,300)) #self.cav_table.setPreferredScrollableViewportSize(Dimension(120,300)) scrl_panel0 = JScrollPane(self.bpm_table) scrl_panel1 = JScrollPane(self.cav_table) scrl_panel0.setBorder(etched_border) scrl_panel1.setBorder(etched_border) bpm_cav_tables_panel = JPanel(BorderLayout()) bpm_cav_tables_panel.add(scrl_panel0,BorderLayout.WEST) bpm_cav_tables_panel.add(scrl_panel1,BorderLayout.CENTER) top_init_panel.add(bpm_cav_tables_panel,BorderLayout.CENTER) #-------------------------------------------------- self.main_panel.add(top_init_panel,BorderLayout.CENTER) #-------------------------------------------------- self.scl_quad_fields_dict_holder = SCL_Quad_Fields_Dict_Holder(self.scl_long_tuneup_controller)
def __init__(self, scl_long_tuneup_controller): #--- scl_long_tuneup_controller the parent document for all SCL tune up controllers self.scl_long_tuneup_controller = scl_long_tuneup_controller #----etched border etched_border = BorderFactory.createEtchedBorder() #----main panel self.main_panel = JPanel(BorderLayout()) #------top params panel----------------------- right_info_panel = JPanel(BorderLayout()) right_top_control_panel = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) analysis_button = JButton("Find BAD Points") analysis_button.addActionListener(Analyze_Data_Button_Listener(self)) right_top_control_panel.add(analysis_button) #------ maximal bpm phase error after the scan max_phase_err_lbl = JLabel("Max BPM Phase Err = ", JLabel.RIGHT) self.max_phase_err_text = DoubleInputTextField(10.0, DecimalFormat("##.#"), 5) right_top_control_panel.add(max_phase_err_lbl) right_top_control_panel.add(self.max_phase_err_text) #----------------------------------------------- right_bottom_control_panel = JPanel(BorderLayout()) right_bottom_control_panel0 = JPanel(BorderLayout()) right_bottom_control_panel1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) right_bottom_control_panel.add(right_bottom_control_panel0, BorderLayout.NORTH) right_bottom_control_panel.add(right_bottom_control_panel1, BorderLayout.SOUTH) statistics_of_errors_lbl = JLabel("Statistics:", JLabel.RIGHT) self.statistics_of_errors_txt = JTextField() right_bottom_control_panel0.add(statistics_of_errors_lbl, BorderLayout.WEST) right_bottom_control_panel0.add(self.statistics_of_errors_txt, BorderLayout.CENTER) remove_worst_points_button = JButton("Remove Worst Points") remove_worst_points_button.addActionListener( CleanUp_Worst_Phase_Points_Data_Button_Listener(self)) remove_all_bad_bpms_button = JButton("Remove All Bad BPMs") remove_all_bad_bpms_button.addActionListener( CleanUp_All_Bad_BPMs_Button_Listener(self)) right_bottom_control_panel1.add(remove_worst_points_button) right_bottom_control_panel1.add(remove_all_bad_bpms_button) #----------------------------------------------- right_tables_panel = JPanel(GridLayout(1, 3)) right_info_panel.add(right_top_control_panel, BorderLayout.NORTH) right_info_panel.add(right_tables_panel, BorderLayout.CENTER) right_info_panel.add(right_bottom_control_panel, BorderLayout.SOUTH) self.main_panel.add(right_info_panel, BorderLayout.EAST) #------cavities scan table panel -------- self.bad_bpms_amp_phase_graphs_panel = Bad_BPMs_Amp_Phase_Graphs_Panel( self) self.main_panel.add(self.bad_bpms_amp_phase_graphs_panel, BorderLayout.CENTER) #------ let's make tables for a list of cavities, bpms, and bad points indexes self.cavs_with_bad_data_table_model = Cavs_with_Bad_PhaseScan_Table_Model( self) self.cavs_table = JTable(self.cavs_with_bad_data_table_model) self.cavs_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.cavs_table.setFillsViewportHeight(true) self.cavs_table.setPreferredScrollableViewportSize(Dimension(180, 300)) self.cavs_table.getSelectionModel().addListSelectionListener( Cavs_Table_Selection_Listener(self)) self.bpms_table_model = Bad_PhaseScan_BPMs_Table_Model(self) self.bpms_table = JTable(self.bpms_table_model) self.bpms_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.bpms_table.setFillsViewportHeight(true) self.bpms_table.getSelectionModel().addListSelectionListener( BPMs_Table_Selection_Listener(self)) self.bpms_table.setPreferredScrollableViewportSize(Dimension(180, 300)) self.points_table_model = Bad_Points_Table_Model(self) self.points_table = JTable(self.points_table_model) self.points_table.setFillsViewportHeight(true) self.points_table.setPreferredScrollableViewportSize( Dimension(180, 300)) #----- set scroll panes scrl_panel0 = JScrollPane(self.cavs_table) scrl_panel1 = JScrollPane(self.bpms_table) scrl_panel2 = JScrollPane(self.points_table) scrl_panel0.setBorder( BorderFactory.createTitledBorder(etched_border, "Cavs")) scrl_panel1.setBorder( BorderFactory.createTitledBorder(etched_border, "BPMs")) scrl_panel2.setBorder( BorderFactory.createTitledBorder(etched_border, "Bad Points")) right_tables_panel.setBorder(etched_border) right_tables_panel.add(scrl_panel0) right_tables_panel.add(scrl_panel1) right_tables_panel.add(scrl_panel2) #----- dictionary with the bad data self.cavs_to_bpm_dict[cav_wrapper] = [bpm_wrappers,bpms_to_points_dict] self.cavs_to_bpm_dict = {} #----- arrays with bad data for the tables self.cavs_with_bad_data_arr = [] self.bpms_arr = [] self.points_arr = []
def trainClassifier(classifier, matchingExamples, mismatchingExamples): ti = createTrainingInstances(matchingExamples, mismatchingExamples) classifier.buildClassifier(ti) df = DecimalFormat("0.0000") return df.format(classifier.measureOutOfBagError()) #print