def cmdOK_Clicked(self): section = self._main_form.project.find_section("COVERAGES") coverage_list = section.value[0:] land_use_count = -1 for land_use in self.local_land_use_list: land_use_count += 1 coverage_found = False for coverage in coverage_list: if coverage.subcatchment_name == self.subcatchment_name and coverage.land_use_name == land_use: # put this back in place coverage_found = True if self.tblGeneric.item(land_use_count, 0) and len( self.tblGeneric.item(land_use_count, 0).text()) > 0: coverage.percent_subcatchment_area = self.tblGeneric.item( land_use_count, 0).text() else: section.value.remove(coverage) if not coverage_found: # add new record if self.tblGeneric.item(land_use_count, 0): value1 = Coverages() value1.subcatchment_name = self.subcatchment_name value1.land_use_name = land_use value1.percent_subcatchment_area = str( self.tblGeneric.item(land_use_count, 0).text()) if section.value == '': section.value = [] section.value.append(value1) self.close()
def cmdOK_Clicked(self): section = self._main_form.project.find_section("COVERAGES") coverage_list = section.value[0:] land_use_count = -1 for land_use in self.local_land_use_list: land_use_count += 1 coverage_found = False for coverage in coverage_list: if coverage.subcatchment_name == self.subcatchment_name and coverage.land_use_name == land_use: # put this back in place coverage_found = True if self.tblGeneric.item(land_use_count,0) and len(self.tblGeneric.item(land_use_count,0).text()) > 0: coverage.percent_subcatchment_area = self.tblGeneric.item(land_use_count,0).text() else: section.value.remove(coverage) if not coverage_found: # add new record if self.tblGeneric.item(land_use_count,0): value1 = Coverages() value1.subcatchment_name = self.subcatchment_name value1.land_use_name = land_use value1.percent_subcatchment_area = str(self.tblGeneric.item(land_use_count,0).text()) if section.value == '': section.value = [] section.value.append(value1) self.close()
def test_default_coverages(self): """Test default, empty string wo section name""" self.my_options = Coverages() name = self.my_options.SECTION_NAME assert name == "[COVERAGES]" actual_text = self.my_options.get_text() assert actual_text == ''
def test_default_coverages(self): """Test default, empty string wo section name""" my_options = Coverages() name = my_options.SECTION_NAME assert name == "[COVERAGES]" actual_text = CoveragesWriter.as_text(my_options) test_text = "" msg = '\nSet:' + test_text + '\nGet:' + actual_text self.assertTrue(match(actual_text, test_text), msg)
class SimpleCoverageTest(unittest.TestCase): """Test COVERAGES section""" def test_coverage(self): """Test one set of Coverage parameters from Example 5""" # --It seems that Coverage class is not used, only Coverages self.my_options = Coverage() test_text = "S2 Residential_1 27" self.my_options.set_text(test_text) # assert self.my_options.subcatchment_name == 'S2' # assert self.my_options.land_use_name == 'Residential_1' # assert self.my_options.percent_subcatchment_area == '27' actual_text = self.my_options.get_text() msg = '\nSet:'+test_text+'\nGet:'+actual_text self.assertTrue(self.my_options.matches(test_text), msg) def test_default_coverages(self): """Test default, empty string wo section name""" self.my_options = Coverages() name = self.my_options.SECTION_NAME assert name == "[COVERAGES]" actual_text = self.my_options.get_text() assert actual_text == '' def test_coverages(self): """Test aquifer parameters in Example 5""" self.my_options = Coverages() test_text = r""" [COVERAGES] ;;Subcatchment Land Use Percent ;;-------------- ---------------- ---------- S1 Residential_1 100 S2 Residential_1 27 S2 Residential_2 73 S3 Residential_1 27 S3 Residential_2 32 S4 Residential_1 9 S4 Residential_2 30 S4 Commercial 26 S5 Commercial 98 S6 Commercial 100 """ self.my_options.set_text(test_text) actual_text = self.my_options.get_text() # display purpose msg = '\nSet:'+test_text+'\nGet:'+actual_text self.assertTrue(self.my_options.matches(test_text), msg)
def test_coverage(self): """Test one set of Coverage parameters from Example 5""" # --It seems that Coverage class is not used, only Coverages self.my_options = Coverage() test_text = "S2 Residential_1 27" self.my_options.set_text(test_text) # assert self.my_options.subcatchment_name == 'S2' # assert self.my_options.land_use_name == 'Residential_1' # assert self.my_options.percent_subcatchment_area == '27' actual_text = self.my_options.get_text() msg = '\nSet:'+test_text+'\nGet:'+actual_text self.assertTrue(self.my_options.matches(test_text), msg)
def test_coverage(self): """Test one set of Coverage parameters from Example 5""" # --It seems that Coverage class is not used, only Coverages self.my_options = Coverage() test_text = "S2 Residential_1 27" self.my_options.set_text(test_text) # assert self.my_options.subcatchment_name == 'S2' # assert self.my_options.land_use_name == 'Residential_1' # assert self.my_options.percent_subcatchment_area == '27' actual_text = self.my_options.get_text() msg = '\nSet:' + test_text + '\nGet:' + actual_text self.assertTrue(self.my_options.matches(test_text), msg)
def cmdOK_Clicked(self): section = self._main_form.project.find_section("COVERAGES") coverage_list = section.value[0:] land_use_count = -1 for land_use in self.local_land_use_list: land_use_count += 1 coverage_found = False for coverage in coverage_list: if coverage.subcatchment_name == self.subcatchment_name and coverage.land_use_name == land_use: # put this back in place coverage_found = True if self.tblGeneric.item(land_use_count, 0) and len( self.tblGeneric.item(land_use_count, 0).text()) > 0: if coverage.percent_subcatchment_area != self.tblGeneric.item( land_use_count, 0).text(): self._main_form.mark_project_as_unsaved() coverage.percent_subcatchment_area = self.tblGeneric.item( land_use_count, 0).text() else: section.value.remove(coverage) self._main_form.mark_project_as_unsaved() if not coverage_found: # add new record if self.tblGeneric.item(land_use_count, 0): value1 = Coverages() value1.subcatchment_name = self.subcatchment_name value1.land_use_name = land_use value1.percent_subcatchment_area = str( self.tblGeneric.item(land_use_count, 0).text()) if section.value == '': section.value = [] section.value.append(value1) self._main_form.mark_project_as_unsaved() self._main_form.program_settings.setValue( "Geometry/" + "frmLandUseAssignment_geometry", self.saveGeometry()) self._main_form.program_settings.setValue( "Geometry/" + "frmLandUseAssignment_state", self.saveState()) self.close()
class SimpleCoverageTest(unittest.TestCase): """Test COVERAGES section""" def test_coverage(self): """Test one set of Coverage parameters from Example 5""" # --It seems that Coverage class is not used, only Coverages self.my_options = Coverage() test_text = "S2 Residential_1 27" self.my_options.set_text(test_text) # assert self.my_options.subcatchment_name == 'S2' # assert self.my_options.land_use_name == 'Residential_1' # assert self.my_options.percent_subcatchment_area == '27' actual_text = self.my_options.get_text() msg = '\nSet:' + test_text + '\nGet:' + actual_text self.assertTrue(self.my_options.matches(test_text), msg) def test_default_coverages(self): """Test default, empty string wo section name""" self.my_options = Coverages() name = self.my_options.SECTION_NAME assert name == "[COVERAGES]" actual_text = self.my_options.get_text() assert actual_text == '' def test_coverages(self): """Test aquifer parameters in Example 5""" self.my_options = Coverages() test_text = r""" [COVERAGES] ;;Subcatchment Land Use Percent ;;-------------- ---------------- ---------- S1 Residential_1 100 S2 Residential_1 27 S2 Residential_2 73 S3 Residential_1 27 S3 Residential_2 32 S4 Residential_1 9 S4 Residential_2 30 S4 Commercial 26 S5 Commercial 98 S6 Commercial 100 """ self.my_options.set_text(test_text) actual_text = self.my_options.get_text() # display purpose msg = '\nSet:' + test_text + '\nGet:' + actual_text self.assertTrue(self.my_options.matches(test_text), msg)
def test_coverages(self): """Test aquifer parameters in Example 5""" self.my_options = Coverages() test_text = r""" [COVERAGES] ;;Subcatchment Land Use Percent ;;-------------- ---------------- ---------- S1 Residential_1 100 S2 Residential_1 27 S2 Residential_2 73 S3 Residential_1 27 S3 Residential_2 32 S4 Residential_1 9 S4 Residential_2 30 S4 Commercial 26 S5 Commercial 98 S6 Commercial 100 """ self.my_options.set_text(test_text) actual_text = self.my_options.get_text() # display purpose msg = '\nSet:' + test_text + '\nGet:' + actual_text self.assertTrue(self.my_options.matches(test_text), msg)
def test_coverages(self): """Test aquifer parameters in Example 5""" self.my_options = Coverages() test_text = r""" [COVERAGES] ;;Subcatchment Land Use Percent ;;-------------- ---------------- ---------- S1 Residential_1 100 S2 Residential_1 27 S2 Residential_2 73 S3 Residential_1 27 S3 Residential_2 32 S4 Residential_1 9 S4 Residential_2 30 S4 Commercial 26 S5 Commercial 98 S6 Commercial 100 """ self.my_options.set_text(test_text) actual_text = self.my_options.get_text() # display purpose msg = '\nSet:'+test_text+'\nGet:'+actual_text self.assertTrue(self.my_options.matches(test_text), msg)
def __init__(self): """Define the fields of a SWMM Project by creating an empty placeholder for each section""" ProjectBase.__init__(self) self.title = Title() # TITLE project title self.options = General() # OPTIONS analysis options self.report = Report() # REPORT output reporting instructions self.files = Files() # FILES interface file options self.backdrop = BackdropOptions( ) # BACKDROP bounding rectangle and file name of backdrop image self.map = MapOptions( ) # MAP map's bounding rectangle and units self.raingages = SectionAsList( "[RAINGAGES]" ) # (list of RainGage) # RAINGAGES rain gage information self.hydrographs = SectionAsList( "[HYDROGRAPHS]") # (list of UnitHydrograph) # unit hydrograph data used to construct RDII inflows self.evaporation = Evaporation() # EVAPORATION evaporation data self.temperature = Temperature( ) # TEMPERATURE air temperature and snow melt data self.adjustments = Adjustments( ) # ADJUSTMENTS monthly climate adjustments self.subcatchments = SectionAsList( "[SUBCATCHMENTS]") # (list of Subcatchment) # basic subcatchment information # self.subareas = [Section] # SUBAREAS subcatchment impervious/pervious sub-area data self.infiltration = SectionAsList("[INFILTRATION]") # (list of str) # subcatchment infiltration parameters self.lid_controls = SectionAsList( "[LID_CONTROLS]") # (list of LIDControl) # low impact development control information self.lid_usage = SectionAsList("[LID_USAGE]") # (list of LIDUsage) # assignment of LID controls to subcatchments self.aquifers = SectionAsList("[AQUIFERS]") # (list of Aquifer) # groundwater aquifer parameters self.groundwater = SectionAsList( "[GROUNDWATER]") # (list of Groundwater) # subcatchment groundwater parameters self.snowpacks = SectionAsList("[SNOWPACKS]") # (list of SnowPack) # subcatchment snow pack parameters self.junctions = SectionAsList("[JUNCTIONS]") # (list of Junction) # junction node information self.outfalls = SectionAsList("[OUTFALLS]") # (list of Outfall) # outfall node information self.dividers = SectionAsList("[DIVIDERS]") # (list of Divider) # flow divider node information self.storage = SectionAsList("[STORAGE]") # (list of StorageUnit) # storage node information self.conduits = SectionAsList("[CONDUITS]") # (list of Conduit) # conduit link information self.pumps = SectionAsList("[PUMPS]") # (list of Pump) # pump link information self.orifices = SectionAsList("[ORIFICES]") # (list of Orifice) # orifice link information self.weirs = SectionAsList("[WEIRS]") # (list of Weir) # weir link information self.outlets = SectionAsList("[OUTLETS]") # (list of Outlet) # outlet link information self.xsections = SectionAsList("[XSECTIONS]") # (list of CrossSection) # conduit, orifice, and weir cross-section geometry self.transects = Transects( ) # transect geometry for conduits with irregular cross-sections self.controls = Controls() # rules that control pump and regulator operation self.events = SectionAsList("[EVENTS]") # (list of Events) self.landuses = SectionAsList( "[LANDUSES]") # (list of Landuse) # land use categories self.buildup = SectionAsList("[BUILDUP]") # (list of Buildup) # buildup functions for pollutants and land uses self.washoff = SectionAsList("[WASHOFF]") # (list of Washoff) # washoff functions for pollutants and land uses self.pollutants = SectionAsList("[POLLUTANTS]") # (list of Pollutant) # pollutant information self.coverages = Coverages( ) # COVERAGES assignment of land uses to subcatchments self.treatment = SectionAsList("[TREATMENT]") # (list of Treatment) # pollutant removal functions at conveyance system nodes self.inflows = SectionAsList("[INFLOWS]") # (list of DirectInflow) # INFLOWS # external hydrograph/pollutograph inflow at nodes self.dwf = SectionAsList("[DWF]") # (list of DryWeatherInflow) # baseline dry weather sanitary inflow at nodes self.patterns = SectionAsList("[PATTERNS]") # (list of Pattern) # periodic variation in dry weather inflow self.rdii = SectionAsList("[RDII]") # (list of RDIInflow) # rainfall-dependent I/I information at nodes self.loadings = InitialLoadings() # initial pollutant loads on subcatchments self.curves = SectionAsList("[CURVES]") # (list of Curve) # CURVES x-y tabular data referenced in other sections self.timeseries = SectionAsList("[TIMESERIES]") # (list of TimeSeries) # time series data referenced in other sections self.labels = SectionAsList("[LABELS]") # (list of Label) # X, Y coordinates and text of labels self.subcentroids = SectionAsList( "[SUBCENTROIDS]") # (list of subcentroids) # X, Y coordinates and text of subcentroids self.sublinks = SectionAsList("[SUBLINKS]") # (list of sublinks) # sublinks information self.sections = [ self.title, self.options, self.evaporation, self.raingages, self.subcatchments, self.infiltration, self.junctions, self.dividers, self.storage, self.outfalls, self.conduits, self.pumps, self.orifices, self.weirs, self.outlets, self.xsections, self.landuses, self.coverages, self.pollutants, self.timeseries, self.patterns, self.curves, self.dwf, self.rdii, self.loadings, self.buildup, self.washoff, self.report, self.events, self.files, self.backdrop, self.map, self.hydrographs, self.temperature, self.adjustments, self.lid_controls, self.lid_usage, self.aquifers, self.groundwater, self.snowpacks, self.transects, self.controls, self.treatment, self.inflows, self.labels, self.subcentroids, self.sublinks ] # Start with a sensible order of sections. self.add_sections_from_attributes( ) # Add any sections not added in the line above, should not be any left.
def __init__(self): """Define the fields of a SWMM Project by creating an empty placeholder for each section""" self.title = Title() # TITLE project title self.options = General() # OPTIONS analysis options self.report = Report() # REPORT output reporting instructions self.files = Files() # FILES interface file options self.backdrop = BackdropOptions( ) # BACKDROP bounding rectangle and file name of backdrop image self.map = MapOptions( ) # MAP map's bounding rectangle and units # self.raingages = [RainGage] # RAINGAGES rain gage information self.hydrographs = SectionAsListGroupByID( "[HYDROGRAPHS]", UnitHydrograph, ";;Hydrograph \tRain Gage/Month \tResponse\tR \tT \tK \tDmax \tDrecov \tDinit \n" ";;--------------\t----------------\t--------\t--------\t--------\t--------\t--------\t--------\t--------" ) # unit hydrograph data used to construct RDII inflows self.evaporation = Evaporation() # EVAPORATION evaporation data self.temperature = Temperature( ) # TEMPERATURE air temperature and snow melt data self.adjustments = Adjustments( ) # ADJUSTMENTS monthly climate adjustments self.subcatchments = SectionAsListOf( "[SUBCATCHMENTS]", Subcatchment, ";;Name \tRain Gage \tOutlet \tArea \t%Imperv \tWidth \t%Slope \tCurbLen \tSnowPack \n" ";;--------------\t----------------\t----------------\t--------\t--------\t--------\t--------\t--------\t----------------" ) # basic subcatchment information # self.subareas = [Section] # SUBAREAS subcatchment impervious/pervious sub-area data self.infiltration = SectionAsListOf("[INFILTRATION]", basestring) # This is set to SectionAsListOf HortonInfiltration or GreenAmptInfiltration or CurveNumberInfiltration on read # subcatchment infiltration parameters self.lid_controls = SectionAsListGroupByID( "[LID_CONTROLS]", LIDControl, ";;Name \tType/Layer\tParameters\n" ";;--------------\t----------\t----------") # low impact development control information self.lid_usage = SectionAsListOf( "[LID_USAGE]", LIDUsage, ";;Subcatchment \tLID Process \tNumber \tArea \tWidth \tInitSat \tFromImp \tToPerv \tRptFile \tDrainTo\n" ";;--------------\t----------------\t-------\t----------\t----------\t----------\t----------\t----------\t------------------------\t----------------" ) # assignment of LID controls to subcatchments self.aquifers = SectionAsListOf( "[AQUIFERS]", Aquifer, ";;Aquifer \tPhi \tWP \tFC \tHydCon\tKslope\tTslope\tUEF \tLED \tLGLR \tBEL \tWTEL \tUZM \tUEF Pat\n" ";;--------------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t-------" ) # groundwater aquifer parameters self.groundwater = SectionAsListOf( "[GROUNDWATER]", Groundwater, ";;Subcatchment \tAquifer \tNode \tEsurf \tA1 \tB1 \tA2 \tB2 \tA3 \tDsw \tEgwt \tEbot \tWgr \tUmc \n" ";;--------------\t----------------\t----------------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------" ) # subcatchment groundwater parameters self.snowpacks = SectionAsListGroupByID( "[SNOWPACKS]", SnowPack, ";;Name \tSurface \tParameters\n" ";;--------------\t----------\t----------") # subcatchment snow pack parameters self.junctions = SectionAsListOf( "[JUNCTIONS]", Junction, ";;Name \tElevation \tMaxDepth \tInitDepth \tSurDepth \tAponded\n" ";;--------------\t----------\t----------\t----------\t----------\t----------" ) # junction node information # self.outfalls = [Outfall] # OUTFALLS # outfall node information # self.dividers = [Divider] # DIVIDERS # flow divider node information # self.storage = [StorageUnit] # STORAGE # storage node information self.conduits = SectionAsListOf( "[CONDUITS]", Conduit, ";;Name \tFrom Node \tTo Node \tLength \tRoughness \tInOffset \tOutOffset \tInitFlow \tMaxFlow \n" ";;--------------\t----------------\t----------------\t----------\t----------\t----------\t----------\t----------\t----------" ) # conduit link information self.pumps = SectionAsListOf( "[PUMPS]", Pump, ";;Name \tFrom Node \tTo Node \tPump Curve \tStatus \tStartup \tShutoff \n" ";;--------------\t----------------\t----------------\t----------------\t--------\t--------\t--------" ) # pump link information # self.orifices = [Orifice] # ORIFICES # orifice link information # self.weirs = [Weir] # WEIRS # weir link information # self.outlets = [Outlet] # OUTLETS # outlet link information self.xsections = SectionAsListOf( "[XSECTIONS]", CrossSection, ";;Link \tShape \tGeom1 \tGeom2 \tGeom3 \tGeom4 \tBarrels \tCulvert \n" ";;--------------\t------------\t----------------\t----------\t----------\t----------\t----------\t----------" ) # conduit, orifice, and weir cross-section geometry self.transects = Transects( ) # TRANSECTS # transect geometry for conduits with irregular cross-sections # self.losses = [Section] # LOSSES # conduit entrance/exit losses and flap valves self.controls = SectionAsListOf( "[CONTROLS]", basestring) # rules that control pump and regulator operation self.landuses = SectionAsListOf( "[LANDUSES]", Landuse, ";; \tSweeping \tFraction \tLast\n" ";;Name \tInterval \tAvailable \tSwept\n" ";;--------------\t----------\t----------\t----------") # land use categories self.buildup = SectionAsListOf( "[BUILDUP]", Buildup, ";;Land Use \tPollutant \tFunction \tCoeff1 \tCoeff2 \tCoeff3 \tPer Unit\n" ";;--------------\t----------------\t----------\t----------\t----------\t----------\t----------" ) # buildup functions for pollutants and land uses self.washoff = SectionAsListOf( "[WASHOFF]", Washoff, ";;Land Use \tPollutant \tFunction \tCoeff1 \tCoeff2 \tSweepRmvl \tBmpRmvl\n" ";;--------------\t----------------\t----------\t----------\t----------\t----------\t----------" ) # washoff functions for pollutants and land uses self.pollutants = SectionAsListOf( "[POLLUTANTS]", Pollutant, ";;Name \tUnits \tCrain \tCgw \tCrdii \tKdecay \tSnowOnly \tCo-Pollutant \tCo-Frac \tCdwf \tCinit\n" ";;--------------\t------\t----------\t----------\t----------\t----------\t----------\t----------------\t----------\t----------\t----------" ) # pollutant information self.coverages = Coverages( ) # COVERAGES # assignment of land uses to subcatchments self.treatment = SectionAsListOf( "[TREATMENT]", Treatment, ";;Node \tPollutant \tFunction\n" ";;--------------\t----------------\t--------") # pollutant removal functions at conveyance system nodes self.inflows = SectionAsListOf( "[INFLOWS]", DirectInflow, ";;Node \tConstituent \tTime Series \tType \tMfactor \tSfactor \tBaseline\tPattern\n" ";;--------------\t----------------\t----------------\t--------\t--------\t--------\t--------\t--------" ) # INFLOWS # external hydrograph/pollutograph inflow at nodes self.dwf = SectionAsListOf( "[DWF]", DryWeatherInflow, ";;Node \tConstituent \tBaseline \tPatterns \n" ";;--------------\t----------------\t----------\t----------") # baseline dry weather sanitary inflow at nodes self.patterns = SectionAsListGroupByID( "[PATTERNS]", Pattern, ";;Name \tType \tMultipliers\n" ";;--------------\t----------\t-----------") # PATTERNS periodic variation in dry weather inflow self.rdii = SectionAsListOf( "[RDII]", RDIInflow, ";;Node \tUnit Hydrograph \tSewer Area\n" ";;--------------\t----------------\t----------") # rainfall-dependent I/I information at nodes self.loadings = SectionAsListOf( "[LOADINGS]", InitialLoading, ";;Subcatchment \tPollutant \tBuildup\n" ";;--------------\t----------------\t----------") # initial pollutant loads on subcatchments self.curves = SectionAsListGroupByID( "[CURVES]", Curve, ";;Name \tType \tX-Value \tY-Value \n" ";;--------------\t----------\t----------\t----------") # CURVES x-y tabular data referenced in other sections self.timeseries = SectionAsListGroupByID( "[TIMESERIES]", TimeSeries, ";;Name \tDate \tTime \tValue\n" ";;--------------\t----------\t----------\t----------") # time series data referenced in other sections # self.polygons = [Section] # POLYGONS # X,Y coordinates for each vertex of subcatchment polygons # self.coordinates = [Section] # COORDINATES # X,Y coordinates for nodes # self.vertices = [Section] # VERTICES # X,Y coordinates for each interior vertex of polyline links # self.labels = [Section] # LABELS # X,Y coordinates and text of labels # self.symbols = [Section] # SYMBOLS # X,Y coordinates for rain gages # X,Y coordinates of the bounding rectangle and file name of the backdrop image. # [TAGS] InputFile.__init__( self ) # Do this after setting attributes so they will all get added to sections[]