def set_from(self, project, hydrograph_id): # section = core.swmm.project.UnitHydrograph section = project.find_section("HYDROGRAPHS") hydrograph_list = section.value[0:] self.hydrograph_id = hydrograph_id for hydrograph in hydrograph_list: if hydrograph.group_name == hydrograph_id: # this is the unit hydrograph group we want to edit self.txtGroup.setText(hydrograph.group_name) self.cboHydrograph.setCurrentIndex(0) for value in hydrograph.value: month_index = self.month3.index(value.hydrograph_month) self.cboHydrograph.setItemText( month_index, self.month[month_index] + " (*)") if value.hydrograph_month == 'All': # this is one we want to load row = 2 if value.term == 'Short': row = 0 elif value.term == 'Medium': row = 1 led = QtGui.QLineEdit(str(value.response_ratio)) self.tblPack.setItem( row, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(value.time_to_peak)) self.tblPack.setItem( row, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(value.recession_limb_ratio)) self.tblPack.setItem( row, 2, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(value.initial_abstraction_depth)) self.tblAbstraction.setItem( row, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(value.initial_abstraction_rate)) self.tblAbstraction.setItem( row, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(value.initial_abstraction_amount)) self.tblAbstraction.setItem( row, 2, QtGui.QTableWidgetItem(led.text())) # code to set rain gage combo, to be implemented with rain gages rain_section = project.find_section("RAINGAGES") rain_list = rain_section.value[0:] self.cboRain.clear() selected_index = 0
def set_from(self, project, timeseries_id): # section = core.swmm.project.SnowPack section = project.find_section("TIMESERIES") timeseries_list = section.value[0:] # assume we want to edit the first one self.timeseries_id = timeseries_id for timeseries in timeseries_list: if timeseries.name == timeseries_id: # this is the timeseries we want to edit self.txtTimeseriesName.setText(timeseries.name) self.txtDescription.setText(timeseries.comment) if timeseries.file: if len(timeseries.file) > 0: self.rbnExternal.setChecked(True) self.txtExternalFile.setText(timeseries.file) else: self.rbnTable.setChecked(True) else: self.rbnTable.setChecked(True) if self.rbnTable.isChecked(): point_count = -1 for value in timeseries.values: point_count += 1 led = QtGui.QLineEdit(str(timeseries.dates[point_count])) self.tblTime.setItem(point_count,0,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(timeseries.times[point_count])) self.tblTime.setItem(point_count,1,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(value)) self.tblTime.setItem(point_count,2,QtGui.QTableWidgetItem(led.text()))
def set_from(self, project, timeseries_id): # section = core.swmm.project.SnowPack section = project.find_section("TIMESERIES") timeseries_list = section.value[0:] # assume we want to edit the first one self.timeseries_id = timeseries_id for timeseries in timeseries_list: if timeseries.name == timeseries_id: # this is the timeseries we want to edit self.txtTimeseriesName.setText(timeseries.name) self.txtDescription.setText(timeseries.comment) if timeseries.file: if len(timeseries.file) > 0: self.rbnExternal.setChecked(True) self.txtExternalFile.setText(timeseries.file) else: self.rbnTable.setChecked(True) else: self.rbnTable.setChecked(True) if self.rbnTable.isChecked(): point_count = -1 for value in timeseries.values: point_count += 1 led = QtGui.QLineEdit( str(timeseries.dates[point_count])) self.tblTime.setItem( point_count, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(timeseries.times[point_count])) self.tblTime.setItem( point_count, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(value)) self.tblTime.setItem( point_count, 2, QtGui.QTableWidgetItem(led.text()))
def set_from(self, project, curve_id): # section = core.swmm.project.Curves() section = project.find_section("CURVES") if self.curve_type == "CONTROL": self.cboCurveType.setVisible(False) self.lblCurveType.setVisible(False) self.tblMult.setHorizontalHeaderLabels(("Controller Value","Control Setting")) elif self.curve_type == "DIVERSION": self.cboCurveType.setVisible(False) self.lblCurveType.setVisible(False) self.tblMult.setHorizontalHeaderLabels(("Inflow (CFS)","Outflow (CFS)")) elif self.curve_type == "PUMP": self.cboCurveType.setVisible(True) self.lblCurveType.setVisible(True) self.tblMult.setHorizontalHeaderLabels(("Depth (ft)","Flow (CFS)")) self.cboCurveType.clear() self.cboCurveType.addItems(("TYPE1","TYPE2","TYPE3","TYPE4")) elif self.curve_type == "RATING": self.cboCurveType.setVisible(False) self.lblCurveType.setVisible(False) self.tblMult.setHorizontalHeaderLabels(("Head (ft)","Outflow (CFS)")) elif self.curve_type == "SHAPE": self.cboCurveType.setVisible(False) self.lblCurveType.setVisible(False) self.tblMult.setHorizontalHeaderLabels(("Depth/Full Depth","Width/Full Depth")) elif self.curve_type == "STORAGE": self.cboCurveType.setVisible(False) self.lblCurveType.setVisible(False) self.tblMult.setHorizontalHeaderLabels(("Depth (ft)","Area (ft2)")) elif self.curve_type == "TIDAL": self.cboCurveType.setVisible(False) self.lblCurveType.setVisible(False) self.tblMult.setHorizontalHeaderLabels(("Hour of Day","Stage (ft)")) curve_list = section.value[0:] for curve in curve_list: if curve.curve_id == curve_id and curve.curve_type.name[:4] == self.curve_type[:4]: self.txtCurveID.setText(str(curve.curve_id)) # self.txtDescription.setText(str(curve.description)) if self.curve_type == "PUMP": if curve.curve_type.name == "PUMP1": self.cboCurveType.setCurrentIndex(0) if curve.curve_type.name == "PUMP2": self.cboCurveType.setCurrentIndex(1) if curve.curve_type.name == "PUMP3": self.cboCurveType.setCurrentIndex(2) if curve.curve_type.name == "PUMP4": self.cboCurveType.setCurrentIndex(3) point_count = -1 for point in curve.curve_xy: point_count += 1 led = QtGui.QLineEdit(str(point[0])) self.tblMult.setItem(point_count,0,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(point[1])) self.tblMult.setItem(point_count,1,QtGui.QTableWidgetItem(led.text()))
def set_from(self, project, land_use_id): self.land_use_id = land_use_id section = project.find_section("LANDUSES") land_use_list = section.value[0:] for land_use in land_use_list: if land_use.land_use_name == land_use_id: # this is the land_use we want to edit led = QtGui.QLineEdit(land_use.land_use_name) self.tblGeneral.setItem(0, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(land_use.comment) self.tblGeneral.setItem(1, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(land_use.last_swept) self.tblGeneral.setItem(3, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(land_use.street_sweeping_availability) self.tblGeneral.setItem(4, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(land_use.street_sweeping_interval) self.tblGeneral.setItem(5, 0, QtGui.QTableWidgetItem(led.text())) self.tblGeneral.setCurrentCell(0, 0) section = project.find_section("BUILDUP") buildup_list = section.value[0:] local_column = -1 for pollutant in self.local_pollutant_list: local_column += 1 for buildup in buildup_list: if buildup.land_use_name == land_use_id and pollutant == buildup.pollutant: # this is the land_use we want to edit combobox = QtGui.QComboBox() ui.convenience.set_combo_items(type(buildup.function), combobox) ui.convenience.set_combo( combobox, buildup.function) # BuildupFunction.POW self.tblBuildup.setCellWidget(0, local_column, combobox) led = QtGui.QLineEdit(buildup.max_buildup) self.tblBuildup.setItem(1, local_column, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(buildup.rate_constant) self.tblBuildup.setItem(2, local_column, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(buildup.power_sat_constant) self.tblBuildup.setItem(3, local_column, QtGui.QTableWidgetItem(led.text())) combobox = QtGui.QComboBox() ui.convenience.set_combo_items(type(buildup.normalizer), combobox) ui.convenience.set_combo( combobox, buildup.normalizer) # Normalizer.AREA self.tblBuildup.setCellWidget(4, local_column, combobox) led = QtGui.QLineEdit(buildup.scaling_factor) self.tblBuildup.setItem(5, local_column, QtGui.QTableWidgetItem(led.text())) timeseries_section = project.find_section("TIMESERIES") timeseries_list = timeseries_section.value[0:] combobox = QtGui.QComboBox() combobox.addItem('') selected_index = 0 for value in timeseries_list: combobox.addItem(value.name) if buildup.timeseries == value.name: selected_index = int(combobox.count()) - 1 combobox.setCurrentIndex(selected_index) self.tblBuildup.setCellWidget(6, local_column, combobox) self.tblBuildup.setCurrentCell(0, 0) section = project.find_section("WASHOFF") washoff_list = section.value[0:] local_column = -1 for pollutant in self.local_pollutant_list: local_column += 1 for washoff in washoff_list: if washoff.land_use_name == land_use_id and pollutant == washoff.pollutant: # this is the land_use we want to edit combobox = QtGui.QComboBox() ui.convenience.set_combo_items(type(washoff.function), combobox) ui.convenience.set_combo( combobox, washoff.function) # WashoffFunction.EXP self.tblWashoff.setCellWidget(0, local_column, combobox) led = QtGui.QLineEdit(washoff.coefficient) self.tblWashoff.setItem(1, local_column, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(washoff.exponent) self.tblWashoff.setItem(2, local_column, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(washoff.cleaning_efficiency) self.tblWashoff.setItem(3, local_column, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(washoff.bmp_efficiency) self.tblWashoff.setItem(4, local_column, QtGui.QTableWidgetItem(led.text())) self.tblWashoff.setCurrentCell(0, 0)
def set_from(self, project): # build a local data structure to hold the data at the present, will need to update as pollutants change for item in self.local_pollutant_list: self.local_timeseries_list.append('') self.local_format.append('') self.local_conversion_factor.append('') self.local_scale_factor.append('') self.local_baseline.append('') self.local_baseline_pattern.append('') for item in self.local_pollutant_list: self.local_average_list.append('') self.local_dry_pattern_1_list.append('') self.local_dry_pattern_2_list.append('') self.local_dry_pattern_3_list.append('') self.local_dry_pattern_4_list.append('') # direct_section = core.swmm.project.DirectInflow() # direct_section = project.find_section("INFLOWS") self.cboConstituent.clear() self.cboDryConstituent.clear() self.cboConstituent.addItem('FLOW') self.cboDryConstituent.addItem('FLOW') self.lblAverage.setText('Average Value (' + project.options.flow_units.name + ')') pollutants_section = project.find_section("POLLUTANTS") for value in pollutants_section.value: self.cboConstituent.addItem(value.name) self.cboDryConstituent.addItem(value.name) patterns_section = project.find_section("PATTERNS") self.cboPattern.clear() self.cboDryPattern1.clear() self.cboDryPattern2.clear() self.cboDryPattern3.clear() self.cboDryPattern4.clear() self.cboPattern.addItem('') self.cboDryPattern1.addItem('') self.cboDryPattern2.addItem('') self.cboDryPattern3.addItem('') self.cboDryPattern4.addItem('') for value in patterns_section.value: self.cboPattern.addItem(value.name) self.cboDryPattern1.addItem(value.name) self.cboDryPattern2.addItem(value.name) self.cboDryPattern3.addItem(value.name) self.cboDryPattern4.addItem(value.name) timeseries_section = project.find_section("TIMESERIES") self.cboTimeSeries.clear() self.cboTimeSeries.addItem('') for value in timeseries_section.value: self.cboTimeSeries.addItem(value.name) self.cboInflowType.clear() self.cboInflowType.addItem('CONCEN') self.cboInflowType.addItem('MASS') self.cboConstituent.setCurrentIndex(0) direct_section = self._main_form.project.find_section("INFLOWS") direct_list = direct_section.value[0:] for value in direct_list: if value.node == self.node_id: index = -1 local_column = -1 for item in self.local_pollutant_list: index += 1 if item == value.constituent: local_column = index if local_column > -1: self.local_timeseries_list[local_column] = value.timeseries self.local_format[local_column] = value.format self.local_conversion_factor[local_column] = value.conversion_factor self.local_scale_factor[local_column] = value.scale_factor self.local_baseline[local_column] = value.baseline self.local_baseline_pattern[local_column] = value.baseline_pattern # dry_section = core.swmm.project.DryWeatherInflow() dry_section = self._main_form.project.find_section("DWF") dry_list = dry_section.value[0:] for value in dry_list: if value.node == self.node_id: index = -1 local_column = -1 for item in self.local_pollutant_list: index += 1 if item == value.constituent: local_column = index if local_column > -1: self.local_average_list[local_column] = value.average if value.time_patterns.count(0) > 0: self.local_dry_pattern_1_list[local_column] = value.time_patterns[0] if value.time_patterns.count(0) > 1: self.local_dry_pattern_2_list[local_column] = value.time_patterns[1] if value.time_patterns.count(0) > 2: self.local_dry_pattern_3_list[local_column] = value.time_patterns[2] if value.time_patterns.count(0) > 3: self.local_dry_pattern_4_list[local_column] = value.time_patterns[3] # rdii_section = core.swmm.project.RDIInflow() rdii_section = project.find_section("RDII") hydrograph_section = project.find_section('HYDROGRAPHS') self.cboUnitHydro.clear() self.cboUnitHydro.addItem('') for value in hydrograph_section.value: self.cboUnitHydro.addItem(value.group_name) rdii_list = rdii_section.value[0:] for value in rdii_list: if value.node == self.node_id: self.txtSewershed.setText(value.sewershed_area) selected_index = 0 for index in range(0,self.cboUnitHydro.count()): if self.cboUnitHydro.itemText(index) == value.hydrograph_group: selected_index = index self.cboUnitHydro.setCurrentIndex(selected_index)
def set_from(self, project): # section = core.epanet.project.Control() section = project.find_section("CONTROLS") self.txtControls.setPlainText(str(section.get_text()))
def set_all(self, project): # evap_section = core.swmm.climatology evap_section = project.find_section("EVAPORATION") # "Constant Value","Time Series","Climate File","Monthly Averages","Temperatures" self.evap_pan_list = evap_section.monthly_pan_coefficients self.evap_monthly_list = evap_section.monthly if evap_section.format == EvaporationFormat.UNSET: self.cboEvap.setCurrentIndex(0) self.cboEvap_currentIndexChanged(0) elif evap_section.format == EvaporationFormat.CONSTANT: self.cboEvap.setCurrentIndex(0) self.cboEvap_currentIndexChanged(0) elif evap_section.format == EvaporationFormat.MONTHLY: self.cboEvap.setCurrentIndex(3) self.cboEvap_currentIndexChanged(3) elif evap_section.format == EvaporationFormat.TIMESERIES: self.cboEvap.setCurrentIndex(1) self.cboEvap_currentIndexChanged(1) elif evap_section.format == EvaporationFormat.TEMPERATURE: self.cboEvap.setCurrentIndex(4) self.cboEvap_currentIndexChanged(4) elif evap_section.format == EvaporationFormat.FILE: self.cboEvap.setCurrentIndex(2) self.cboEvap_currentIndexChanged(2) if evap_section.constant == '': evap_section.constant = 0.0 self.txtDaily.setText(str(evap_section.constant)) self.cbxDry.setChecked(evap_section.dry_only) time_series_section = project.find_section("TIMESERIES") time_series_list = time_series_section.value[0:] self.cboEvapTs.clear() selected_index = 0 for value in time_series_list: self.cboEvapTs.addItem(value.name) if value.name == evap_section.timeseries: selected_index = int(self.cboEvapTs.count()) - 1 self.cboEvapTs.setCurrentIndex(selected_index) pattern_section = project.find_section("PATTERNS") pattern_list = pattern_section.value[0:] self.cboMonthly.clear() self.cboMonthly.addItem("") selected_index = 0 previous_pattern = "" for value in pattern_list: if value.name and value.name != previous_pattern: self.cboMonthly.addItem(value.name) previous_pattern = value.name if value.name == evap_section.recovery_pattern: selected_index = int(self.cboMonthly.count()) - 1 self.cboMonthly.setCurrentIndex(selected_index) # temp_section = core.swmm.climatology.climatology temp_section = project.find_section("TEMPERATURE") if temp_section.source == TemperatureSource.UNSET: self.rbnTimeseries.setChecked(False) self.rbnExternal.setChecked(False) self.rbnNoData.setChecked(True) elif temp_section.source == TemperatureSource.TIMESERIES and temp_section.timeseries: self.rbnTimeseries.setChecked(True) self.rbnExternal.setChecked(False) self.rbnNoData.setChecked(False) elif temp_section.source == TemperatureSource.FILE: self.rbnTimeseries.setChecked(False) self.rbnExternal.setChecked(True) self.rbnNoData.setChecked(False) else: self.rbnTimeseries.setChecked(False) self.rbnExternal.setChecked(False) self.rbnNoData.setChecked(True) time_series_section = project.find_section("TIMESERIES") time_series_list = time_series_section.value[0:] self.cboTimeSeries.clear() self.cboTimeSeries.addItem('') selected_index = 0 for value in time_series_list: self.cboTimeSeries.addItem(value.name) if value.name == temp_section.timeseries: selected_index = self.cboTimeSeries.count() self.cboTimeSeries.setCurrentIndex(selected_index) self.txtClimate.setText(temp_section.filename) self.dedStart.setDate( QtCore.QDate.fromString(temp_section.start_date, "MM/dd/yyyy")) if temp_section.start_date: self.cbxStart.setChecked(True) # wind speed tab if temp_section.wind_speed.source == WindSource.MONTHLY: self.rbnMonthly.setChecked(True) monthly_list = temp_section.wind_speed.wind_speed_monthly point_count = -1 for value in monthly_list: point_count += 1 led = QtGui.QLineEdit(str(value)) self.tblWind.setItem(0, point_count, QtGui.QTableWidgetItem(led.text())) elif temp_section.wind_speed.source == WindSource.FILE: self.rbnUseClimate.setChecked(True) # snow melt tab self.txtSnowDivide.setText(str(temp_section.snow_melt.snow_temp)) self.txtSnowATI.setText(str(temp_section.snow_melt.ati_weight)) self.txtSnowMelt.setText( str(temp_section.snow_melt.negative_melt_ratio)) self.txtSnowElevation.setText(str(temp_section.snow_melt.elevation)) self.txtSnowLatitude.setText(str(temp_section.snow_melt.latitude)) self.txtSnowLongitude.setText( str(temp_section.snow_melt.time_correction)) # areal depletion areal_list = temp_section.areal_depletion.adc_impervious point_count = -1 for value in areal_list: point_count += 1 led = QtGui.QLineEdit(str(value)) self.tblAreal.setItem(point_count, 0, QtGui.QTableWidgetItem(led.text())) areal_list = temp_section.areal_depletion.adc_pervious point_count = -1 for value in areal_list: point_count += 1 led = QtGui.QLineEdit(str(value)) self.tblAreal.setItem(point_count, 1, QtGui.QTableWidgetItem(led.text())) # self.tblAreal.resizeColumnsToContents() # adjustments for temp, evap, rain, cond adjustments_section = project.find_section("ADJUSTMENTS") temp_list = adjustments_section.temperature point_count = -1 for value in temp_list: point_count += 1 led = QtGui.QLineEdit(str(value)) self.tblAdjustments.setItem(point_count, 0, QtGui.QTableWidgetItem(led.text())) evap_list = adjustments_section.evaporation point_count = -1 for value in evap_list: point_count += 1 led = QtGui.QLineEdit(str(value)) self.tblAdjustments.setItem(point_count, 1, QtGui.QTableWidgetItem(led.text())) rain_list = adjustments_section.rainfall point_count = -1 for value in rain_list: point_count += 1 led = QtGui.QLineEdit(str(value)) self.tblAdjustments.setItem(point_count, 2, QtGui.QTableWidgetItem(led.text())) cond_list = adjustments_section.soil_conductivity point_count = -1 for value in cond_list: point_count += 1 led = QtGui.QLineEdit(str(value)) self.tblAdjustments.setItem(point_count, 3, QtGui.QTableWidgetItem(led.text()))
def set_link(self, project, link_id): # section = core.swmm.project.CrossSection() section = project.find_section("XSECTIONS") link_list = section.value[0:] # assume we want to edit the first one self.link_id = link_id for value in link_list: if value.link == link_id: # this is the link we want to edit for list_index in range(0, self.listWidget.count()): list_item = self.listWidget.item(list_index) if str(list_item.text()).upper() == value.shape.name: self.listWidget.setCurrentItem(list_item) elif str(list_item.text( )) == 'Force Main' and value.shape.name == 'FORCE_MAIN': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Filled Circular' and value.shape.name == 'FILLED_CIRCULAR': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Closed Rectangular' and value.shape.name == 'RECT_CLOSED': self.listWidget.setCurrentItem(list_item) elif str(list_item.text( )) == 'Rectangular' and value.shape.name == 'RECT_OPEN': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Horizontal Elliptical' and value.shape.name == 'HORIZ_ELLIPSE': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Vertical Elliptical' and value.shape.name == 'VERT_ELLIPSE': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Rectangular Triangular' and value.shape.name == 'RECT_TRIANGULAR': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Rectangular Round' and value.shape.name == 'RECT_ROUND': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Modified Baskethandle' and value.shape.name == 'MODBASKETHANDLE': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Semi-Elliptical' and value.shape.name == 'SEMIELLIPTICAL': self.listWidget.setCurrentItem(list_item) elif str( list_item.text() ) == 'Semi-Circular' and value.shape.name == 'SEMICIRCULAR': self.listWidget.setCurrentItem(list_item) self.sbxNumber.setValue(int(value.barrels)) self.txt1.setText(value.geometry1) self.txt2.setText(value.geometry2) self.txt3.setText(value.geometry3) self.txt4.setText(value.geometry4) # for rect_open sidewalls, set geom3 to 0,1,2 for None, One, Both if value.shape.name == 'RECTANGULAR': self.cboCombo.setCurrentIndex(int(value.geometry3)) # for horizontal and vertical elliptical and arch, combo gets standard sizes if value.shape.name == 'HORIZ_ELLIPSE': self.cboCombo.setCurrentIndex(int(value.geometry3)) if value.shape.name == 'VERT_ELLIPSE': self.cboCombo.setCurrentIndex(int(value.geometry3)) if value.shape.name == 'ARCH': self.cboCombo.setCurrentIndex(int(value.geometry3)) if value.shape.name == 'IRREGULAR': # for irregular, combo needs transect names, dialog opens transect buttons for index in range(0, self.cboCombo.count): if value.transect == self.cboCombo.itemText(index): self.cboCombo.setCurrentIndex(index) if value.shape.name == 'CUSTOM': # for custom, combo needs shape curves, dialog opens shape curve editor for index in range(0, self.cboCombo.count): if value.curve == self.cboCombo.itemText(index): self.cboCombo.setCurrentIndex(index)
def set_from(self, project): # build a local data structure to hold the data at the present, will need to update as pollutants change for item in self.local_pollutant_list: self.local_timeseries_list.append('') self.local_format.append('') self.local_conversion_factor.append('') self.local_scale_factor.append('') self.local_baseline.append('') self.local_baseline_pattern.append('') for item in self.local_pollutant_list: self.local_average_list.append('') self.local_dry_pattern_1_list.append('') self.local_dry_pattern_2_list.append('') self.local_dry_pattern_3_list.append('') self.local_dry_pattern_4_list.append('') # direct_section = core.swmm.project.DirectInflow() # direct_section = project.find_section("INFLOWS") self.cboConstituent.clear() self.cboDryConstituent.clear() self.cboConstituent.addItem('FLOW') self.cboDryConstituent.addItem('FLOW') self.lblAverage.setText('Average Value (' + project.options.flow_units.name + ')') pollutants_section = project.find_section("POLLUTANTS") for value in pollutants_section.value: self.cboConstituent.addItem(value.name) self.cboDryConstituent.addItem(value.name) patterns_section = project.find_section("PATTERNS") self.cboPattern.clear() self.cboDryPattern1.clear() self.cboDryPattern2.clear() self.cboDryPattern3.clear() self.cboDryPattern4.clear() self.cboPattern.addItem('') self.cboDryPattern1.addItem('') self.cboDryPattern2.addItem('') self.cboDryPattern3.addItem('') self.cboDryPattern4.addItem('') for value in patterns_section.value: self.cboPattern.addItem(value.name) self.cboDryPattern1.addItem(value.name) self.cboDryPattern2.addItem(value.name) self.cboDryPattern3.addItem(value.name) self.cboDryPattern4.addItem(value.name) timeseries_section = project.find_section("TIMESERIES") self.cboTimeSeries.clear() self.cboTimeSeries.addItem('') for value in timeseries_section.value: self.cboTimeSeries.addItem(value.name) self.cboInflowType.clear() self.cboInflowType.addItem('CONCEN') self.cboInflowType.addItem('MASS') self.cboConstituent.setCurrentIndex(0) direct_section = self._main_form.project.find_section("INFLOWS") direct_list = direct_section.value[0:] for value in direct_list: if value.node == self.node_id: index = -1 local_column = -1 for item in self.local_pollutant_list: index += 1 if item == value.constituent: local_column = index if local_column > -1: self.local_timeseries_list[local_column] = value.timeseries self.local_format[local_column] = value.format self.local_conversion_factor[ local_column] = value.conversion_factor self.local_scale_factor[local_column] = value.scale_factor self.local_baseline[local_column] = value.baseline self.local_baseline_pattern[ local_column] = value.baseline_pattern # dry_section = core.swmm.project.DryWeatherInflow() dry_section = self._main_form.project.find_section("DWF") dry_list = dry_section.value[0:] for value in dry_list: if value.node == self.node_id: index = -1 local_column = -1 for item in self.local_pollutant_list: index += 1 if item == value.constituent: local_column = index if local_column > -1: self.local_average_list[local_column] = value.average if value.time_patterns.count(0) > 0: self.local_dry_pattern_1_list[ local_column] = value.time_patterns[0] if value.time_patterns.count(0) > 1: self.local_dry_pattern_2_list[ local_column] = value.time_patterns[1] if value.time_patterns.count(0) > 2: self.local_dry_pattern_3_list[ local_column] = value.time_patterns[2] if value.time_patterns.count(0) > 3: self.local_dry_pattern_4_list[ local_column] = value.time_patterns[3] # rdii_section = core.swmm.project.RDIInflow() rdii_section = project.find_section("RDII") hydrograph_section = project.find_section('HYDROGRAPHS') self.cboUnitHydro.clear() self.cboUnitHydro.addItem('') for value in hydrograph_section.value: self.cboUnitHydro.addItem(value.group_name) rdii_list = rdii_section.value[0:] for value in rdii_list: if value.node == self.node_id: self.txtSewershed.setText(value.sewershed_area) selected_index = 0 for index in range(0, self.cboUnitHydro.count()): if self.cboUnitHydro.itemText( index) == value.hydrograph_group: selected_index = index self.cboUnitHydro.setCurrentIndex(selected_index)
def set_from(self, project, pack_id): # section = core.swmm.project.SnowPack section = project.find_section("SNOWPACKS") snow_list = section.value[0:] # assume we want to edit the first one self.pack_id = pack_id for pack in snow_list: if pack.name == pack_id: # this is the snowpack we want to edit self.txtSnow.setText(pack.name) led = QtGui.QLineEdit( str(pack.plowable_minimum_melt_coefficient)) self.tblPack.setItem(0, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(pack.plowable_maximum_melt_coefficient)) self.tblPack.setItem(1, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.plowable_base_temperature)) self.tblPack.setItem(2, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(pack.plowable_fraction_free_water_capacity)) self.tblPack.setItem(3, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.plowable_initial_snow_depth)) self.tblPack.setItem(4, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.plowable_initial_free_water)) self.tblPack.setItem(5, 0, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(pack.impervious_minimum_melt_coefficient)) self.tblPack.setItem(0, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(pack.impervious_maximum_melt_coefficient)) self.tblPack.setItem(1, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_base_temperature)) self.tblPack.setItem(2, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(pack.impervious_fraction_free_water_capacity)) self.tblPack.setItem(3, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_initial_snow_depth)) self.tblPack.setItem(4, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_initial_free_water)) self.tblPack.setItem(5, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_depth_100_cover)) self.tblPack.setItem(6, 1, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(pack.pervious_minimum_melt_coefficient)) self.tblPack.setItem(0, 2, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(pack.pervious_maximum_melt_coefficient)) self.tblPack.setItem(1, 2, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_base_temperature)) self.tblPack.setItem(2, 2, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit( str(pack.pervious_fraction_free_water_capacity)) self.tblPack.setItem(3, 2, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_initial_snow_depth)) self.tblPack.setItem(4, 2, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_initial_free_water)) self.tblPack.setItem(5, 2, QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_depth_100_cover)) self.tblPack.setItem(6, 2, QtGui.QTableWidgetItem(led.text())) self.txtFraction.setText( pack.plowable_fraction_impervious_area) self.txtRemoval1.setText(pack.depth_snow_removal_begins) self.txtRemoval2.setText( pack.fraction_transferred_out_watershed) self.txtRemoval3.setText( pack.fraction_transferred_impervious_area) self.txtRemoval4.setText( pack.fraction_transferred_pervious_area) self.txtRemoval5.setText( pack.fraction_converted_immediate_melt) self.txtRemoval6.setText( pack.fraction_moved_another_subcatchment) self.txtRemoval7.setText(pack.subcatchment_transfer)
def set_link(self, project, link_id): # section = core.swmm.project.CrossSection() section = project.find_section("XSECTIONS") link_list = section.value[0:] # assume we want to edit the first one self.link_id = link_id for value in link_list: if value.link == link_id: # this is the link we want to edit for list_index in range(0,self.listWidget.count()): list_item = self.listWidget.item(list_index) if str(list_item.text()).upper() == value.shape.name: self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Force Main' and value.shape.name == 'FORCE_MAIN': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Filled Circular' and value.shape.name == 'FILLED_CIRCULAR': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Closed Rectangular' and value.shape.name == 'RECT_CLOSED': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Rectangular' and value.shape.name == 'RECT_OPEN': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Horizontal Elliptical' and value.shape.name == 'HORIZ_ELLIPSE': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Vertical Elliptical' and value.shape.name == 'VERT_ELLIPSE': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Rectangular Triangular' and value.shape.name == 'RECT_TRIANGULAR': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Rectangular Round' and value.shape.name == 'RECT_ROUND': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Modified Baskethandle' and value.shape.name == 'MODBASKETHANDLE': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Semi-Elliptical' and value.shape.name == 'SEMIELLIPTICAL': self.listWidget.setCurrentItem(list_item) elif str(list_item.text()) == 'Semi-Circular' and value.shape.name == 'SEMICIRCULAR': self.listWidget.setCurrentItem(list_item) self.sbxNumber.setValue(int(value.barrels)) self.txt1.setText(value.geometry1) self.txt2.setText(value.geometry2) self.txt3.setText(value.geometry3) self.txt4.setText(value.geometry4) # for rect_open sidewalls, set geom3 to 0,1,2 for None, One, Both if value.shape.name == 'RECTANGULAR': self.cboCombo.setCurrentIndex(int(value.geometry3)) # for horizontal and vertical elliptical and arch, combo gets standard sizes if value.shape.name == 'HORIZ_ELLIPSE': self.cboCombo.setCurrentIndex(int(value.geometry3)) if value.shape.name == 'VERT_ELLIPSE': self.cboCombo.setCurrentIndex(int(value.geometry3)) if value.shape.name == 'ARCH': self.cboCombo.setCurrentIndex(int(value.geometry3)) if value.shape.name == 'IRREGULAR': # for irregular, combo needs transect names, dialog opens transect buttons for index in range(0,self.cboCombo.count): if value.transect == self.cboCombo.itemText(index): self.cboCombo.setCurrentIndex(index) if value.shape.name == 'CUSTOM': # for custom, combo needs shape curves, dialog opens shape curve editor for index in range(0,self.cboCombo.count): if value.curve == self.cboCombo.itemText(index): self.cboCombo.setCurrentIndex(index)
def set_from(self, project): # section = core.epanet.project.Control() section = project.find_section("CONTROLS") self.txtControls.setPlainText(str(section.get_text()))
def set_from(self, project, pack_id): # section = core.swmm.project.SnowPack section = project.find_section("SNOWPACKS") snow_list = section.value[0:] # assume we want to edit the first one self.pack_id = pack_id for pack in snow_list: if pack.name == pack_id: # this is the snowpack we want to edit self.txtSnow.setText(pack.name) led = QtGui.QLineEdit(str(pack.plowable_minimum_melt_coefficient)) self.tblPack.setItem(0,0,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.plowable_maximum_melt_coefficient)) self.tblPack.setItem(1,0,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.plowable_base_temperature)) self.tblPack.setItem(2,0,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.plowable_fraction_free_water_capacity)) self.tblPack.setItem(3,0,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.plowable_initial_snow_depth)) self.tblPack.setItem(4,0,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.plowable_initial_free_water)) self.tblPack.setItem(5,0,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_minimum_melt_coefficient)) self.tblPack.setItem(0,1,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_maximum_melt_coefficient)) self.tblPack.setItem(1,1,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_base_temperature)) self.tblPack.setItem(2,1,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_fraction_free_water_capacity)) self.tblPack.setItem(3,1,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_initial_snow_depth)) self.tblPack.setItem(4,1,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_initial_free_water)) self.tblPack.setItem(5,1,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.impervious_depth_100_cover)) self.tblPack.setItem(6,1,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_minimum_melt_coefficient)) self.tblPack.setItem(0,2,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_maximum_melt_coefficient)) self.tblPack.setItem(1,2,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_base_temperature)) self.tblPack.setItem(2,2,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_fraction_free_water_capacity)) self.tblPack.setItem(3,2,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_initial_snow_depth)) self.tblPack.setItem(4,2,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_initial_free_water)) self.tblPack.setItem(5,2,QtGui.QTableWidgetItem(led.text())) led = QtGui.QLineEdit(str(pack.pervious_depth_100_cover)) self.tblPack.setItem(6,2,QtGui.QTableWidgetItem(led.text())) self.txtFraction.setText(pack.plowable_fraction_impervious_area) self.txtRemoval1.setText(pack.depth_snow_removal_begins) self.txtRemoval2.setText(pack.fraction_transferred_out_watershed) self.txtRemoval3.setText(pack.fraction_transferred_impervious_area) self.txtRemoval4.setText(pack.fraction_transferred_pervious_area) self.txtRemoval5.setText(pack.fraction_converted_immediate_melt) self.txtRemoval6.setText(pack.fraction_moved_another_subcatchment) self.txtRemoval7.setText(pack.subcatchment_transfer)