class SimpleMapTest(unittest.TestCase): """Test MAP section""" TEST_TEXT = [("[MAP]\n" "DIMENSIONS 0.000 0.000 10000.000 10000.000\n" "Units None")] def setUp(self): self.my_options = MapOptions() def runTest(self): name = self.my_options.SECTION_NAME assert name == "[MAP]" expected_text = "[MAP]\n" + \ " DIMENSIONS 0.0 0.0 0.0 0.0\n" + \ " UNITS \tNONE" assert self.my_options.matches(expected_text) for current_map_option in self.TEST_TEXT: self.my_options.set_text(current_map_option) mapxy = [] for s in current_map_option.split(): if s.isdigit(): mapxy.append(float(s)) for i in range(len(mapxy)): assert self.my_options.dimensions[i] == mapxy[i]
def test_writer(self): """Test MapOptionsWriter""" my_options = MapOptions() name = my_options.SECTION_NAME assert name == "[MAP]" test_text = "[MAP]\n" + \ " DIMENSIONS 0.0 0.0 0.0 0.0\n" + \ " UNITS \tNONE" actual_text = MapOptionsWriter.as_text(my_options) msg = '\nSet:'+test_text+'\nGet:'+actual_text self.assertTrue(match(actual_text, test_text), msg)
def __init__(self): """Initialize the sections of an EPANET input file. Any sections not initialized here will be handled by the generic core.project_base.Section class.""" ProjectBase.__init__(self) self.title = Title() self.backdrop = BackdropOptions() # BACKDROP bounding rectangle and file name of backdrop image self.map = MapOptions() # MAP map's bounding rectangle and units self.junctions = SectionAsList("[JUNCTIONS]") # (list of Junction) self.reservoirs = SectionAsList("[RESERVOIRS]") # (list of Reservoir) self.tanks = SectionAsList("[TANKS]") # (list of Tank) self.pipes = SectionAsList("[PIPES]") # (list of Pipe) self.pumps = SectionAsList("[PUMPS]") # (list of Pump) self.valves = SectionAsList("[VALVES]") # (list of Valve) # self.emitters = [(Junction, "emitter_coefficient")] self.patterns = SectionAsList("[PATTERNS]") # (list of Pattern) self.curves = SectionAsList("[CURVES]") # (list of Curve) self.energy = EnergyOptions() self.status = SectionAsList("[STATUS]") # (list of Status) self.controls = Control() self.rules = Rule() self.demands = SectionAsList("[DEMANDS]") # (list of Demand) self.reactions = Reactions() self.sources = SectionAsList("[SOURCES]") # (list of Source) # self.options = MapOptions, self.options = Options() self.times = TimesOptions() self.report = ReportOptions() self.labels = SectionAsList("[LABELS]") # (list of Label) self.backdrop = BackdropOptions() self.calibrations = SectionAsList("[CALIBRATIONS]") # (list of Calibration) self.sections = [ self.title, self.options, self.report, self.junctions, self.tanks, self.reservoirs, self.pipes, self.pumps, self.valves, self.controls, self.patterns, self.curves, self.backdrop, self.map, self.labels] # 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""" 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 setUp(self): self.my_options = MapOptions()
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[]