def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.columnNames = ["Cavity","Z[m]","Use","<html>RF A<SUB>design</SUB>(MV)<html>"] self.columnNames += ["<html>RF φ<SUB>design</SUB>(deg)<html>",] self.columnNames += ["<html>RF A<SUB>live</SUB>(MV)<html>",] self.columnNames += ["<html>RF φ<SUB>live</SUB>(deg)<html>",] self.columnNames += ["<html>BPM<SUB>1</SUB><html>","<html>BPM<SUB>2</SUB><html>"] self.nf4 = NumberFormat.getInstance() self.nf4.setMaximumFractionDigits(4) self.nf3 = NumberFormat.getInstance() self.nf3.setMaximumFractionDigits(3) self.string_class = String().getClass() self.boolean_class = Boolean(true).getClass()
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.columnNames = ["BPM","Z[m]","Use"] self.nf3 = NumberFormat.getInstance() self.nf3.setMaximumFractionDigits(3) self.string_class = String().getClass() self.boolean_class = Boolean(true).getClass()
def __init__(self): self.ws_rec_table_element_arr = [] self.columnNames = ["#","Name","Use","Dir","Sigma, mm","User Fit","User RMS"] self.nf = NumberFormat.getInstance() self.nf.setMaximumFractionDigits(2) self.boolean_class = Boolean(true).getClass() self.string_class = String().getClass()
def __init__(self): nf = NumberFormat.getInstance() nf.setMinimumFractionDigits(2) nf.setMaximumFractionDigits(2) self.result = JFormattedTextField(nf, border=None, horizontalAlignment=JTextField.RIGHT) self.DTCR = DefaultTableCellRenderer()
def __init__( self ) : nf = NumberFormat.getInstance() nf.setMinimumFractionDigits( 2 ) nf.setMaximumFractionDigits( 2 ) self.result = JFormattedTextField( nf, horizontalAlignment = JTextField.RIGHT )
def __init__(self,ws_direction,transverse_twiss_analysis_Controller): self.ws_direction = ws_direction self.transverse_twiss_analysis_Controller = transverse_twiss_analysis_Controller self.columnNames = ["#","WS/LW","Pos.[m]","Use","S,[mm]","Gauss","RMS"] self.nf = NumberFormat.getInstance() self.nf.setMaximumFractionDigits(2) self.boolean_class = Boolean(true).getClass() self.string_class = String().getClass()
def __init__(self, final_twiss_params_holder): self.final_twiss_params_holder = final_twiss_params_holder self.columnNames = ["Name", "value", "Error"] self.rowNames = [] tmpAxis = ["X", "Y", "Z"] for i in range(3): self.rowNames.append("Alpha " + tmpAxis[i]) self.rowNames.append("Beta " + tmpAxis[i]) self.rowNames.append("Emitt " + tmpAxis[i]) self.nf = NumberFormat.getInstance() self.nf.setMaximumFractionDigits(4) self.string_class = String().getClass()
def __init__(self,final_twiss_params_holder): self.final_twiss_params_holder = final_twiss_params_holder self.columnNames = ["Name","value","Error"] self.rowNames = [] tmpAxis = ["X","Y","Z"] for i in range(3): self.rowNames.append("Alpha "+tmpAxis[i]) self.rowNames.append("Beta "+tmpAxis[i]) self.rowNames.append("Emitt "+tmpAxis[i]) self.nf = NumberFormat.getInstance() self.nf.setMaximumFractionDigits(4) self.string_class = String().getClass()
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.columnNames = ["Cavity","Use","Done"] self.columnNames += ["<html>BPM<SUB>1</SUB><html>","<html>BPM<SUB>2</SUB><html>"] self.columnNames += ["<html>RF φ<SUB>old</SUB>(deg)<html>",] self.columnNames += ["<html>RF φ<SUB>new</SUB>(deg)<html>",] self.columnNames += ["<html>Fit A<SUB>φ</SUB>(deg)<html>",] self.columnNames += ["<html>Fit δA<SUB>φ</SUB>(deg)<html>",] self.columnNames += ["<html>Δφ<SUB>RF</SUB>(deg)<html>",] self.nf3 = NumberFormat.getInstance() self.nf3.setMaximumFractionDigits(3) self.string_class = String().getClass() self.boolean_class = Boolean(true).getClass()
def __init__(self,scl_long_tuneup_controller): # Delta Phi RF are actually the average RF gap phases! self.scl_long_tuneup_controller = scl_long_tuneup_controller self.columnNames = ["Cavity","Use"] self.columnNames += ["<html>Old A<SUB>EPICS</SUB>(MV)<html>",] self.columnNames += ["<html>New A<SUB>EPICS</SUB>(MV)<html>",] self.columnNames += ["<html>A<SUB>New/Old</SUB>(%)<html>",] self.columnNames += ["<html>Old Δφ<SUB>Synch</SUB>(deg)<html>",] self.columnNames += ["<html>New Δφ<SUB>Synch</SUB>(deg)<html>",] self.columnNames += ["<html>Old φ<SUB>EPICS</SUB>(deg)<html>",] self.columnNames += ["<html>New φ<SUB>EPICS</SUB>(deg)<html>",] self.nf3 = NumberFormat.getInstance() self.string_class = String().getClass() self.boolean_class = Boolean(true).getClass()
def __init__(self,scl_long_tuneup_controller): # Delta Phi RF are actually the average RF gap phases! self.scl_long_tuneup_controller = scl_long_tuneup_controller self.columnNames = ["Cavity","Use"] self.columnNames += ["<html>Old A<SUB>EPICS</SUB>(MV)<html>",] self.columnNames += ["<html>New A<SUB>EPICS</SUB>(MV)<html>",] self.columnNames += ["<html>A<SUB>New/Old</SUB>(%)<html>",] self.columnNames += ["<html>Old Δφ<SUB>RF</SUB>(deg)<html>",] self.columnNames += ["<html>New Δφ<SUB>RF</SUB>(deg)<html>",] self.columnNames += ["<html>Old φ<SUB>model</SUB>(deg)<html>",] self.columnNames += ["<html>New φ<SUB>model</SUB>(deg)<html>",] self.columnNames += ["<html>Old φ<SUB>live</SUB>(deg)<html>",] self.columnNames += ["<html>New φ<SUB>live</SUB>(deg)<html>",] self.nf3 = NumberFormat.getInstance() self.string_class = String().getClass() self.boolean_class = Boolean(true).getClass()
def __init__(self,scl_long_tuneup_controller): self.scl_long_tuneup_controller = scl_long_tuneup_controller self.columnNames = ["#","Cavity","Use","Done",] self.columnNames += ["<html>E<SUB>in</SUB>(MeV)<html>",] self.columnNames += ["<html>E<SUB>out</SUB>(MeV)<html>",] self.columnNames += ["<html>ΔE<SUB>k/(k-1)</SUB>(keV)<html>",] self.columnNames += ["<html>BPMs E<SUB>out</SUB>(MeV)<html>",] self.columnNames += ["<html>Model E<SUB>out</SUB>(MeV)<html>",] self.columnNames += ["<html>A<SUB>cav</SUB>(MV)<html>",] self.columnNames += ["<html>φ<SUB>1st gap</SUB>(deg)<html>",] self.columnNames += ["<html>φ<SUB>gap avg</SUB>(deg)<html>",] self.columnNames += ["<html>δE<SUB>fit</SUB>(keV)<html>",] self.columnNames += ["<html>Real Δφ<SUB>RF</SUB>(deg)<html>",] self.nf3 = NumberFormat.getInstance() self.nf3.setMaximumFractionDigits(3) self.string_class = String().getClass() self.boolean_class = Boolean(true).getClass()
def __init__(self, host, port, scenario_name=None): self.scenario_name = scenario_name self.host = host self.port = port self.sharedInstance = None self._numberFormat = NumberFormat.getInstance() self._numberFormat.setMinimumFractionDigits(1) self._numberFormat.setMaximumFractionDigits(3) self._nbCallSuccessSoFar = 0 self._nbCall = 0 self._nbCallError = 0 self._nbCallErrorSoFar = 0 self._nbCall_tps = 0 self._injection_rate = 0 self._sumTime = 0 self._maxTime = 0 self._lastRefresh = System.currentTimeMillis() self.CarbonCache = Thread( CarbonCacheClient.__AggregateReportThread(self, host, port), "TheCarbonCache") self.CarbonCache.start()
def __init__(self): nf = NumberFormat.getInstance() nf.setMinimumFractionDigits(2) nf.setMaximumFractionDigits(2) self.result = JFormattedTextField(nf)
def init_components(self): self.panel0 = JPanel() self.rbgPanel0 = ButtonGroup() self.gbPanel0 = GridBagLayout() self.gbcPanel0 = GridBagConstraints() self.panel0.setLayout(self.gbPanel0) self.host_L = JLabel("Host:") self.host_L.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 1 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.host_L, self.gbcPanel0) self.panel0.add(self.host_L) self.port_L = JLabel("Port:") self.port_L.setEnabled(True) self.gbcPanel0.gridx = 1 self.gbcPanel0.gridy = 1 self.gbcPanel0.gridwidth = 2 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.port_L, self.gbcPanel0) self.panel0.add(self.port_L) self.host_TF = JTextField(10) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 2 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.host_TF, self.gbcPanel0) self.panel0.add(self.host_TF) format = NumberFormat.getInstance() format.setGroupingUsed(False) port_formatter = NumberFormatter(format) port_formatter.setValueClass(Integer) port_formatter.setAllowsInvalid(False) port_formatter.setMinimum(Integer(0)) port_formatter.setMaximum(Integer(65535)) self.port_TF = JFormattedTextField(port_formatter) self.gbcPanel0.gridx = 1 self.gbcPanel0.gridy = 2 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.port_TF, self.gbcPanel0) self.panel0.add(self.port_TF) self.blank_1_L = JLabel(" ") self.blank_1_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 3 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_1_L, self.gbcPanel0) self.panel0.add(self.blank_1_L) self.image_formats_L = JLabel("Format of images (separator \";\"):") self.port_L.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 4 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.image_formats_L, self.gbcPanel0) self.panel0.add(self.image_formats_L) self.image_formats_TF = JTextField(10) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 5 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.image_formats_TF, self.gbcPanel0) self.panel0.add(self.image_formats_TF) self.blank_2_L = JLabel(" ") self.blank_2_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 6 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_2_L, self.gbcPanel0) self.panel0.add(self.blank_2_L) self.min_probability_L = JLabel("Confidence minimum (%):") self.port_L.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 7 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.min_probability_L, self.gbcPanel0) self.panel0.add(self.min_probability_L) min_probabilty_formatter = NumberFormatter(format) min_probabilty_formatter.setValueClass(Integer) min_probabilty_formatter.setAllowsInvalid(False) min_probabilty_formatter.setMinimum(Integer(0)) min_probabilty_formatter.setMaximum(Integer(100)) self.min_probability_TF = JFormattedTextField(min_probabilty_formatter) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 8 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.min_probability_TF, self.gbcPanel0) self.panel0.add(self.min_probability_TF) self.blank_3_L = JLabel(" ") self.blank_3_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 9 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_3_L, self.gbcPanel0) self.panel0.add(self.blank_3_L) self.min_file_size_L = JLabel("Minimum file size (KB):") self.min_file_size_L.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 10 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.min_file_size_L, self.gbcPanel0) self.panel0.add(self.min_file_size_L) min_file_size_formatter = NumberFormatter(format) min_file_size_formatter.setValueClass(Integer) min_file_size_formatter.setAllowsInvalid(False) min_file_size_formatter.setMinimum(Integer(0)) self.min_file_size_TF = JFormattedTextField(min_file_size_formatter) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 11 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.min_file_size_TF, self.gbcPanel0) self.panel0.add(self.min_file_size_TF) self.blank_4_L = JLabel(" ") self.blank_4_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 12 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_4_L, self.gbcPanel0) self.panel0.add(self.blank_4_L) self.detectable_obejcts_BTN = \ JButton("List of Objects to Detect", actionPerformed=self.show_detectable_objects_dialog) # self.save_Settings_BTN.setPreferredSize(Dimension(1, 20)) self.rbgPanel0.add(self.detectable_obejcts_BTN) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 13 self.gbPanel0.setConstraints(self.detectable_obejcts_BTN, self.gbcPanel0) self.panel0.add(self.detectable_obejcts_BTN) self.blank_5_L = JLabel(" ") self.blank_5_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 14 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_5_L, self.gbcPanel0) self.panel0.add(self.blank_5_L) self.error_message = JLabel("", JLabel.CENTER) self.error_message.setForeground(Color.red) self.error_message.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 15 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.error_message, self.gbcPanel0) self.panel0.add(self.error_message) self.message = JLabel("", JLabel.CENTER) self.message.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 16 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.message, self.gbcPanel0) self.panel0.add(self.message) self.save_settings_BTN = JButton("Save Settings", actionPerformed=self.save_settings) # self.save_Settings_BTN.setPreferredSize(Dimension(1, 20)) self.rbgPanel0.add(self.save_settings_BTN) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 17 self.gbPanel0.setConstraints(self.save_settings_BTN, self.gbcPanel0) self.panel0.add(self.save_settings_BTN) self.blank_6_L = JLabel(" ") self.blank_6_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 18 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_6_L, self.gbcPanel0) self.panel0.add(self.blank_6_L) self.blank_7_L = JLabel(" ") self.blank_7_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 19 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_7_L, self.gbcPanel0) self.panel0.add(self.blank_7_L) self.check_server_connection_BTN = \ JButton("Check server connection", actionPerformed=self.check_server_connection) # self.save_Settings_BTN.setPreferredSize(Dimension(1, 20)) self.rbgPanel0.add(self.check_server_connection_BTN) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 20 self.gbPanel0.setConstraints(self.check_server_connection_BTN, self.gbcPanel0) self.panel0.add(self.check_server_connection_BTN) self.blank_8_L = JLabel(" ") self.blank_8_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 21 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_8_L, self.gbcPanel0) self.panel0.add(self.blank_8_L) self.text_editor_BTN = \ JButton("Open config file", actionPerformed=self.open_text_editor) # self.save_Settings_BTN.setPreferredSize(Dimension(1, 20)) self.rbgPanel0.add(self.text_editor_BTN) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 22 self.gbPanel0.setConstraints(self.text_editor_BTN, self.gbcPanel0) self.panel0.add(self.text_editor_BTN) self.add(self.panel0)
def monthlyTable(file, search, twstring): # Create Data Reference from Inputs g = opendss(file) from java.lang import System lineSeparator = System.getProperty( 'line.separator') # '\r\n' # '\n' on unix desiredSpaceCount = 6 g.filterBy(search) # Set time window and create a new ref with this window tw = timeWindow(twstring) ref = DataReference.create(g[0], tw) pref = PeriodAverageProxy( ref, DSSUtil.getTimeFactory().createTimeInterval('1month')) dsi = pref.getData().getIterator() tm = DSSUtil.getTimeFactory().getTimeInstance() tmf = DSSUtil.getTimeFactory().getTimeFormatInstance().create("MMM yyyy") tmf1 = DSSUtil.getTimeFactory().getTimeFormatInstance().create("MMM") tmf2 = DSSUtil.getTimeFactory().getTimeFormatInstance().create("yyyy") from java.lang import Float, Math from java.util import Date sys.add_package('java.text') from java.text import NumberFormat nf = NumberFormat.getInstance() nf.setGroupingUsed(0) nf.setMinimumFractionDigits(1) nf.setMinimumIntegerDigits(1) nf.setMaximumFractionDigits(1) fp = FieldPosition(nf.INTEGER_FIELD) lines = [] lines.append('STUDY: ' + ref.getPathname().getPart(Pathname.F_PART) + space(10) + 'FILE: ' + file + space(10) + Date().toString()) lines.append('') lines.append('Searched: ' + search) lines.append('Units: ' + ref.getData().getAttributes().getYUnits()) lines.append('Project: ' + ref.getPathname().toString()) lines.append('') desiredSpace = space(desiredSpaceCount + nf.getMinimumIntegerDigits() + nf.getMinimumFractionDigits() - 3) startSpace = desiredSpace + space(4) lines.append('YEAR' + desiredSpace + 'OCT' + desiredSpace + 'NOV' + desiredSpace + 'DEC' + desiredSpace + 'JAN' + desiredSpace + 'FEB' + desiredSpace + 'MAR' + desiredSpace + 'APR' + desiredSpace + 'MAY' + desiredSpace + 'JUN' + desiredSpace + 'JUL' + desiredSpace + 'AUG' + desiredSpace + 'SEP' + space(desiredSpaceCount - 3) + 'TOTAL') cl = '' gotOct = 0 yrsum = 0.0 allyrtot = 0.0 yravg = 0.0 totavg = 0.0 totmin = Float.MAX_VALUE totmax = Float.MIN_VALUE nsum = 0 nyears = 0 while not dsi.atEnd(): e = dsi.getElement() date = tm.create(Math.round(e.getX())).toString() mon = date[2:5] if mon == 'OCT': if nsum > 0: yravg = yrsum allyrtot = allyrtot + yrsum nyears = nyears + 1 totmin = Math.min(totmin, yrsum) totmax = Math.max(totmax, yrsum) if cl != '': strbuf = StringBuffer(10) nf.format(yravg, strbuf, fp) cl = cl + space(desiredSpaceCount - fp.getEndIndex()) + strbuf.toString() lines.append(cl) # yrsum = 0.0 nsum = 0 # water year cl = repr(int(tm.create(Math.round(e.getX())).format(tmf2)) + 1) gotOct = 1 # if gotOct: if (e.getY() == -901): strbuf = StringBuffer(10) nf.format(yravg, strbuf, fp) cl = cl + space(desiredSpaceCount) + \ space(nf.getMinimumIntegerDigits() + nf.getMinimumIntegerDigits()) else: strbuf = StringBuffer(10) nf.format(e.getY(), strbuf, fp) cl = cl + space(desiredSpaceCount - fp.getEndIndex()) + strbuf.toString() yrsum = yrsum + e.getY() nsum = nsum + 1 # print tm.create(Math.round(e.getX())).format(tmf), e.getY() # dsi.advance() # # Get average, min, max for each month totavg = allyrtot / nyears minV = Float.MAX_VALUE maxV = Float.MIN_VALUE monavg = { 'OCT': 0.0, 'NOV': 0.0, 'DEC': 0.0, 'JAN': 0.0, 'FEB': 0.0, 'MAR': 0.0, 'APR': 0.0, 'MAY': 0.0, 'JUN': 0.0, 'JUL': 0.0, 'AUG': 0.0, 'SEP': 0.0 } monmin = { 'OCT': minV, 'NOV': minV, 'DEC': minV, 'JAN': minV, 'FEB': minV, 'MAR': minV, 'APR': minV, 'MAY': minV, 'JUN': minV, 'JUL': minV, 'AUG': minV, 'SEP': minV } monmax = { 'OCT': maxV, 'NOV': maxV, 'DEC': maxV, 'JAN': maxV, 'FEB': maxV, 'MAR': maxV, 'APR': maxV, 'MAY': maxV, 'JUN': maxV, 'JUL': maxV, 'AUG': maxV, 'SEP': maxV } numavg = { 'OCT': 0, 'NOV': 0, 'DEC': 0, 'JAN': 0, 'FEB': 0, 'MAR': 0, 'APR': 0, 'MAY': 0, 'JUN': 0, 'JUL': 0, 'AUG': 0, 'SEP': 0 } gotOct = 0 dsi.resetIterator() while not dsi.atEnd(): e = dsi.getElement() date = tm.create(Math.round(e.getX())).toString() mon = date[2:5] if mon == 'OCT': gotOct = 1 if gotOct: if (e.getY() == -901): pass else: monmin[mon] = Math.min(monmin[mon], e.getY()) monmax[mon] = Math.max(monmax[mon], e.getY()) monavg[mon] = monavg[mon] + e.getY() numavg[mon] = numavg[mon] + 1 # # dsi.advance() # lines.append(' ') cl = 'AVG:' for val in monavg.keys(): monavg[val] = monavg[val] / numavg[val] strbuf = StringBuffer(10) nf.format(monavg[val], strbuf, fp) cl = cl + space(desiredSpaceCount - fp.getEndIndex()) + strbuf.toString() # strbuf = StringBuffer(10) nf.format(totavg, strbuf, fp) cl = cl + space(desiredSpaceCount - fp.getEndIndex()) + strbuf.toString() lines.append(cl) # cl = 'MIN:' for val in monmin.keys(): strbuf = StringBuffer(10) nf.format(monmin[val], strbuf, fp) cl = cl + space(desiredSpaceCount - fp.getEndIndex()) + strbuf.toString() # strbuf = StringBuffer(10) nf.format(totmin, strbuf, fp) cl = cl + space(desiredSpaceCount - fp.getEndIndex()) + strbuf.toString() lines.append(cl) # cl = 'MAX:' for val in monmax.keys(): strbuf = StringBuffer(10) nf.format(monmax[val], strbuf, fp) cl = cl + space(desiredSpaceCount - fp.getEndIndex()) + strbuf.toString() # strbuf = StringBuffer(10) nf.format(totmax, strbuf, fp) cl = cl + space(desiredSpaceCount - fp.getEndIndex()) + strbuf.toString() lines.append(cl) # # # f=open(search + '.txt','w') # for line in lines : # f.write(line + lineSeparator) # print line # # f.close() return lines