def test_conduit_section(self):
     """Test CONDUIT section using Project class, data from Example 7"""
     from_text = Project()
     source_text = "[CONDUITS]\n" \
                   " ;;               Inlet            Outlet                      Manning    Inlet      Outlet     Init.      Max.\n" \
                   " ;;Name           Node             Node             Length     N          Offset     Offset     Flow       Flow\n" \
                   " ;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ----------\n" \
                   " C2a              J2a              J2               157.48     0.016      4          4          0          0\n" \
                   " C2               J2               J11              526.0      0.016      4          6          0          0\n" \
                   " C3               J3               J4               109.0      0.016      0          6          0          0\n" \
                   " C4               J4               J5               133.0      0.05       6          4          0          0\n" \
                   " C5               J5               J6               207.0      0.05       4          0          0          0\n" \
                   " C6               J7               J6               140.0      0.05       8          0          0          0\n" \
                   " C7               J6               J8               95.0       0.016      0          0          0          0\n" \
                   " C8               J8               J9               166.0      0.05       0          0          0          0\n" \
                   " C9               J9               J10              320.0      0.05       0          6          0          0\n" \
                   " C10              J10              J11              145.0      0.05       6          6          0          0\n" \
                   " C11              J11              O1               89.0       0.016      0          0          0          0\n" \
                   " C_Aux1           Aux1             J1               377.31     0.016      0          4          0          0\n" \
                   " C_Aux2           Aux2             J2a              239.41     0.016      0          4          0          0\n" \
                   " C_Aux1to2        J1               Aux2             286.06     0.016      4          0          0          0\n" \
                   " C_Aux3           Aux3             J3               444.75     0.05       6          0          0          0\n" \
                   " P1               J1               J5               185.39     0.016      0          0          0          0\n" \
                   " P2               J2a              J2               157.48     0.016      0          0          0          0\n" \
                   " P3               J2               J11              529.22     0.016      0          0          0          0\n" \
                   " P4               Aux3             J4               567.19     0.016      0          0          0          0\n" \
                   " P5               J5               J4               125.98     0.016      0          0          0          0\n" \
                   " P6               J4               J7               360.39     0.016      0          0          0          0\n" \
                   " P7               J7               J10              507.76     0.016      0          0          0          0\n" \
                   " P8               J10              J11              144.50     0.016      0          0          0          0"
     from_text.set_text(source_text)
     project_section = from_text.conduits
     assert Section.match_omit(project_section.get_text(), source_text,
                               " \t-;\n")
    def test_curves(self):
        """Test Curves section"""
        self.my_curve = curves.Curve()
        self.my_curve = curves.Curve()
        self.my_curve.curve_id = "XXX"
        self.my_curve.description = "test curve"
        self.my_curve.curve_type = curves.CurveType.HEADLOSS
        self.my_curve.curve_xy = ((1500, 250), (1400, 200))

        assert self.my_curve.curve_id == "XXX"
        assert self.my_curve.description == "test curve"
        assert self.my_curve.get_text().split() == [';HEADLOSS:', 'test', 'curve',
                                                    'XXX', '1500', '250', 'XXX', '1400', '200'], "incorrect pattern block"

        # Create new project with new text
        test_text = ("[CURVES]",
                     ";ID\tX-Value\tY-Value",
                     ";--\t-------\t-------",
                     ";PUMP: Pump Curve for Pump 9",
                     " 1\t1500\t250\t")
        from_text = Project()
        from_text.set_text('\n'.join(test_text))
        project_curves = from_text.curves
        assert Section.match_omit(project_curves.get_text(), '\n'.join(test_text), " -;\t\n")

        assert len(project_curves.value) == 1
        this_curve = project_curves.value[0]
        assert this_curve.curve_id == '1'
        assert this_curve.description == "Pump Curve for Pump 9"
        assert this_curve.curve_type == curves.CurveType.PUMP
        assert this_curve.curve_xy == [("1500", "250")]
 def test_conduit_section(self):
     """Test CONDUIT section using Project class, data from Example 7"""
     from_text = Project()
     source_text = "[CONDUITS]\n" \
                   " ;;               Inlet            Outlet                      Manning    Inlet      Outlet     Init.      Max.\n" \
                   " ;;Name           Node             Node             Length     N          Offset     Offset     Flow       Flow\n" \
                   " ;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ----------\n" \
                   " C2a              J2a              J2               157.48     0.016      4          4          0          0\n" \
                   " C2               J2               J11              526.0      0.016      4          6          0          0\n" \
                   " C3               J3               J4               109.0      0.016      0          6          0          0\n" \
                   " C4               J4               J5               133.0      0.05       6          4          0          0\n" \
                   " C5               J5               J6               207.0      0.05       4          0          0          0\n" \
                   " C6               J7               J6               140.0      0.05       8          0          0          0\n" \
                   " C7               J6               J8               95.0       0.016      0          0          0          0\n" \
                   " C8               J8               J9               166.0      0.05       0          0          0          0\n" \
                   " C9               J9               J10              320.0      0.05       0          6          0          0\n" \
                   " C10              J10              J11              145.0      0.05       6          6          0          0\n" \
                   " C11              J11              O1               89.0       0.016      0          0          0          0\n" \
                   " C_Aux1           Aux1             J1               377.31     0.016      0          4          0          0\n" \
                   " C_Aux2           Aux2             J2a              239.41     0.016      0          4          0          0\n" \
                   " C_Aux1to2        J1               Aux2             286.06     0.016      4          0          0          0\n" \
                   " C_Aux3           Aux3             J3               444.75     0.05       6          0          0          0\n" \
                   " P1               J1               J5               185.39     0.016      0          0          0          0\n" \
                   " P2               J2a              J2               157.48     0.016      0          0          0          0\n" \
                   " P3               J2               J11              529.22     0.016      0          0          0          0\n" \
                   " P4               Aux3             J4               567.19     0.016      0          0          0          0\n" \
                   " P5               J5               J4               125.98     0.016      0          0          0          0\n" \
                   " P6               J4               J7               360.39     0.016      0          0          0          0\n" \
                   " P7               J7               J10              507.76     0.016      0          0          0          0\n" \
                   " P8               J10              J11              144.50     0.016      0          0          0          0"
     from_text.set_text(source_text)
     project_section = from_text.conduits
     assert Section.match_omit(project_section.get_text(), source_text, " \t-;\n")
Example #4
0
    def test_curves(self):
        """Test Curves section"""
        self.my_curve = curves.Curve()
        self.my_curve = curves.Curve()
        self.my_curve.curve_id = "XXX"
        self.my_curve.description = "test curve"
        self.my_curve.curve_type = curves.CurveType.HEADLOSS
        self.my_curve.curve_xy = ((1500, 250), (1400, 200))

        assert self.my_curve.curve_id == "XXX"
        assert self.my_curve.description == "test curve"
        assert self.my_curve.get_text().split() == [
            ';HEADLOSS:', 'test', 'curve', 'XXX', '1500', '250', 'XXX', '1400',
            '200'
        ], "incorrect pattern block"

        # Create new project with new text
        test_text = ("[CURVES]", ";ID\tX-Value\tY-Value",
                     ";--\t-------\t-------", ";PUMP: Pump Curve for Pump 9",
                     " 1\t1500\t250\t")
        from_text = Project()
        from_text.set_text('\n'.join(test_text))
        project_curves = from_text.curves
        assert Section.match_omit(project_curves.get_text(),
                                  '\n'.join(test_text), " -;\t\n")

        assert len(project_curves.value) == 1
        this_curve = project_curves.value[0]
        assert this_curve.curve_id == '1'
        assert this_curve.description == "Pump Curve for Pump 9"
        assert this_curve.curve_type == curves.CurveType.PUMP
        assert this_curve.curve_xy == [("1500", "250")]
    def runTest(self):
        """Test set_text and get_text"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_sources = from_text.sources

        assert Section.match_omit(project_sources.get_text(), source_text,
                                  " \t-;\n")

        assert project_sources.value[0].id == "JUNCTION-9090"
        assert project_sources.value[0].source_type == SourceType.CONCEN
        assert project_sources.value[0].baseline_strength == "8330"
        assert project_sources.value[0].pattern_id == "Pattern-A"

        assert project_sources.value[1].id == "JUNCTION-9091"
        assert project_sources.value[1].source_type == SourceType.MASS
        assert project_sources.value[1].baseline_strength == "8331"
        assert project_sources.value[1].pattern_id == "Pattern-B"

        assert project_sources.value[2].id == "JUNCTION-9092"
        assert project_sources.value[2].source_type == SourceType.FLOWPACED
        assert project_sources.value[2].baseline_strength == "8332"
        assert project_sources.value[2].pattern_id == "Pattern-C"

        assert project_sources.value[3].id == "JUNCTION-9093"
        assert project_sources.value[3].source_type == SourceType.SETPOINT
        assert project_sources.value[3].baseline_strength == "8333"
        assert project_sources.value[3].pattern_id == "Pattern-D"

        assert project_sources.value[4].id == "JUNCTION-9094"
        assert project_sources.value[4].source_type == SourceType.CONCEN
        assert project_sources.value[4].baseline_strength == "8334"
        assert project_sources.value[4].pattern_id == ""
    def runTest(self):
        """Test set_text and get_text"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_sources = from_text.sources

        assert Section.match_omit(project_sources.get_text(), source_text, " \t-;\n")

        assert project_sources.value[0].id == "JUNCTION-9090"
        assert project_sources.value[0].source_type == SourceType.CONCEN
        assert project_sources.value[0].baseline_strength == "8330"
        assert project_sources.value[0].pattern_id == "Pattern-A"

        assert project_sources.value[1].id == "JUNCTION-9091"
        assert project_sources.value[1].source_type == SourceType.MASS
        assert project_sources.value[1].baseline_strength == "8331"
        assert project_sources.value[1].pattern_id == "Pattern-B"

        assert project_sources.value[2].id == "JUNCTION-9092"
        assert project_sources.value[2].source_type == SourceType.FLOWPACED
        assert project_sources.value[2].baseline_strength == "8332"
        assert project_sources.value[2].pattern_id == "Pattern-C"

        assert project_sources.value[3].id == "JUNCTION-9093"
        assert project_sources.value[3].source_type == SourceType.SETPOINT
        assert project_sources.value[3].baseline_strength == "8333"
        assert project_sources.value[3].pattern_id == "Pattern-D"

        assert project_sources.value[4].id == "JUNCTION-9094"
        assert project_sources.value[4].source_type == SourceType.CONCEN
        assert project_sources.value[4].baseline_strength == "8334"
        assert project_sources.value[4].pattern_id == ""
Example #7
0
    def test_junctions(self):
        """Test JUNCTIONS section through Project class"""
        test_text = r"""
[JUNCTIONS]
;;               Invert     Max.       Init.      Surcharge  Ponded
;;Name           Elev.      Depth      Depth      Depth      Area
;;-------------- ---------- ---------- ---------- ---------- ----------
J1               4973       0          0          0          0
J2               4969       0          0          0          0
J3               4973       0          0          0          0
J4               4971       0          0          0          0
J5               4969.8     0          0          0          0
J6               4969       0          0          0          0
J7               4971.5     0          0          0          0
J8               4966.5     0          0          0          0
J9               4964.8     0          0          0          0
J10              4963.8     0          0          0          0
J11              4963       0          0          0          0
J12              4973.8     0          0          0          0
J13              4970.7     0          0          0          0
J14              4972.9     0          0          0          0
J15              4974.5     0          0          0          0
J16              4973.5     0          0          0          0
J17              4973.5     0          0          0          0
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.junctions
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
 def test_dividers(self):
     """Test DIVIDERS section from Example-1b"""
     from_text = Project()
     source_text = "[DIVIDERS]\n" \
                 ";;Name           Elevation  Diverted Link    Type       Parameters\n" \
                 ";;-------------- ---------- ---------------- ---------- ----------\n" \
                 "10               0          *                CUTOFF     0          0          0"
     from_text.set_text(source_text)
     project_section = from_text.dividers
     assert Section.match_omit(project_section.get_text(), source_text, " \t-;\n")
 def test_dividers(self):
     """Test DIVIDERS section from Example-1b"""
     from_text = Project()
     source_text = "[DIVIDERS]\n" \
                 ";;Name           Elevation  Diverted Link    Type       Parameters\n" \
                 ";;-------------- ---------- ---------------- ---------- ----------\n" \
                 "10               0          *                CUTOFF     0          0          0"
     from_text.set_text(source_text)
     project_section = from_text.dividers
     assert Section.match_omit(project_section.get_text(), source_text,
                               " \t-;\n")
    def test_outfall_section(self):
        """Test OUTFALLS section"""
        test_text = r"""
[OUTFALLS]
;;Name           Elevation  Type       Stage Data       Gated    Route To
;;-------------- ---------- ---------- ---------------- -------- ----------------
18               975        FREE                        NO
18               975        FREE                        NO       xxx
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.outfalls
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
    def test_rdii_section(self):
        test_text = r"""
[RDII]
;;Node             UHgroup          SewerArea
;;----------------------------------------------------------------------
  80408            FLOW             80408
  81009            FLOW             81009
  82309            FLOW             82309
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.rdii
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
    def test_outfall_section(self):
        """Test OUTFALLS section"""
        test_text = r"""
[OUTFALLS]
;;Name           Elevation  Type       Stage Data       Gated    Route To
;;-------------- ---------- ---------- ---------------- -------- ----------------
18               975        FREE                        NO
18               975        FREE                        NO       xxx
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.outfalls
        assert Section.match_omit(project_section.get_text(), test_text,
                                  " \t-;\n")
    def test_treatment_section(self):
        """Test TREATMENT section"""
        test_text = r"""
[TREATMENT]
;;                                  Results: R or C
;;                                  R-Fraction removal
;;                                  C-efflument concentration
;;Node             Pollutant        Result = Func
;;----------------------------------------------------------------------
  Node23            BOD              C = BOD * exp(-0.05*HRT)
  Node24            Lead             R = 0.2 * R_TSS
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.treatment
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
    def test_dwf_section_example8(self):
        """Test DWF section from example 8"""
        from_text = Project()
        source_text = r"""[DWF]
;;                                Average    Time
;;Node           Parameter        Value      Patterns
;;-------------- ---------------- ---------- ----------
J1               FLOW             0.008
J2a              FLOW             0.01
J12              FLOW             0.0125
J13              FLOW             0.0123
Aux3             FLOW             0.004     """
        # --Test set_text
        from_text.set_text(source_text)
        project_section = from_text.dwf
        assert Section.match_omit(project_section.get_text(), source_text, " \t-;\n")
    def test_washoff_section(self):
        """Test WASHOFF section"""
        test_text = r"""
[WASHOFF]
;;                                                               Clean.   BMP
;;LandUse          Pollutant        Function   Coeff1   Coeff2   Effic.   Effic.
;;------------------------------------------------------------------------------
  Residential      TSS              EXP        0.1      1        0        0
  Residential      Lead             EMC        0        0        0        0
  Undeveloped      TSS              EXP        0.1      0.7      0        0
  Undeveloped      Lead             EMC        0        0        0        0
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.washoff
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
    def test_washoff_section(self):
        """Test WASHOFF section"""
        test_text = r"""
[WASHOFF]
;;                                                               Clean.   BMP
;;LandUse          Pollutant        Function   Coeff1   Coeff2   Effic.   Effic.
;;------------------------------------------------------------------------------
  Residential      TSS              EXP        0.1      1        0        0
  Residential      Lead             EMC        0        0        0        0
  Undeveloped      TSS              EXP        0.1      0.7      0        0
  Undeveloped      Lead             EMC        0        0        0        0
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.washoff
        assert Section.match_omit(project_section.get_text(), test_text,
                                  " \t-;\n")
    def test_landuses(self):
        """Test LANDUSES section"""

        test_text = r"""
[LANDUSES]
;;               Cleaning   Fraction   Last
;;Name           Interval   Available  Cleaned
;;-------------- ---------- ---------- ----------
Residential_1    0          0          0
Residential_2    0          0          0
Commercial       0          0          0
LID              0          0          0
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.landuses
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
    def test_dwf_section_example8(self):
        """Test DWF section from example 8"""
        from_text = Project()
        source_text = r"""[DWF]
;;                                Average    Time
;;Node           Parameter        Value      Patterns
;;-------------- ---------------- ---------- ----------
J1               FLOW             0.008
J2a              FLOW             0.01
J12              FLOW             0.0125
J13              FLOW             0.0123
Aux3             FLOW             0.004     """
        # --Test set_text
        from_text.set_text(source_text)
        project_section = from_text.dwf
        assert Section.match_omit(project_section.get_text(), source_text,
                                  " \t-;\n")
    def test_treatment_section(self):
        """Test TREATMENT section"""
        test_text = r"""
[TREATMENT]
;;                                  Results: R or C
;;                                  R-Fraction removal
;;                                  C-efflument concentration
;;Node             Pollutant        Result = Func
;;----------------------------------------------------------------------
  Node23            BOD              C = BOD * exp(-0.05*HRT)
  Node24            Lead             R = 0.2 * R_TSS
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.treatment
        assert Section.match_omit(project_section.get_text(), test_text,
                                  " \t-;\n")
    def test_lid_usage_section(self):
        """Test LIDUSAGE section through Project class
         Test failed as current LID usage only contains one line of LID usage
         Also code compained when I have special character in the comment lines"""
        test_text = r"""
[LID_USAGE]
;34 rain barrels of 12 sq ft each are placed in
;subcatchment S1. They are initially empty and treat 17
;The outflow from the barrels is returned to the
;subcatchments pervious area.
S1 RB14 34 12 0 0 17 1
S2 Swale 1 10000 50 0 0 0 swale.rpt
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.lid_usage
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
Example #21
0
    def test_aquifers(self):
        """Test AQUIFERS section using the Project class"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_section = from_text.aquifers

        assert Section.match_omit(project_section.get_text(), source_text, " \t-;\n")

        val = project_section.value[0]

        assert val.name == "1"
        assert val.porosity == "0.5"
        assert val.wilting_point == "0.15"
        assert val.field_capacity == "0.30"
        assert val.conductivity == "0.1"
        assert val.conductivity_slope == "12"
        assert val.tension_slope == "15.0"
        assert val.upper_evaporation_fraction == "0.35"
        assert val.lower_evaporation_depth == "14.0"
        assert val.lower_groundwater_loss_rate == "0.002"
        assert val.bottom_elevation == "0.0"
        assert val.water_table_elevation == "3.5"
        assert val.unsaturated_zone_moisture == "0.40"
        assert val.upper_evaporation_pattern == ""

        val = project_section.value[1]

        assert val.name == "1"
        assert val.porosity == "2"
        assert val.wilting_point == "3"
        assert val.field_capacity == "4"
        assert val.conductivity == "5"
        assert val.conductivity_slope == "6"
        assert val.tension_slope == "7"
        assert val.upper_evaporation_fraction == "8"
        assert val.lower_evaporation_depth == "9"
        assert val.lower_groundwater_loss_rate == "10"
        assert val.bottom_elevation == "11"
        assert val.water_table_elevation == "12"
        assert val.unsaturated_zone_moisture == "13"
        assert val.upper_evaporation_pattern == "14"

        assert Aquifer.metadata.label_of("name") == "Aquifer Name"
        assert Aquifer.metadata.hint_of("name") == "User-assigned aquifer name."
Example #22
0
    def test_interface_files(self):
        """Test FILES options using the Section class"""
        self.my_options = Files()
        name = self.my_options.SECTION_NAME
        assert name == "[FILES]"

        actual_text = self.my_options.get_text()

        # Expect blank section when there are no contents for the section
        assert actual_text == ''

        self.my_options.save_outflows = "save_outflows.txt"

        expected_text = self.my_options.SECTION_NAME + '\n' + self.my_options.comment
        expected_text += "\nSAVE OUTFLOWS \tsave_outflows.txt"

        actual_text = self.my_options.get_text()
        assert Section.match_omit(actual_text, expected_text, " \t-")
    def test_lid_usage_section(self):
        """Test LIDUSAGE section through Project class
         Test failed as current LID usage only contains one line of LID usage
         Also code compained when I have special character in the comment lines"""
        test_text = r"""
[LID_USAGE]
;34 rain barrels of 12 sq ft each are placed in
;subcatchment S1. They are initially empty and treat 17
;The outflow from the barrels is returned to the
;subcatchments pervious area.
S1 RB14 34 12 0 0 17 1
S2 Swale 1 10000 50 0 0 0 swale.rpt
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.lid_usage
        assert Section.match_omit(project_section.get_text(), test_text,
                                  " \t-;\n")
    def runTest(self):
        """Test files options"""
        self.my_options = files.Files()
        name = self.my_options.SECTION_NAME
        assert name == "[FILES]"

        actual_text = self.my_options.get_text()

        # Expect blank section when there are no contents for the section
        assert actual_text == ''

        self.my_options.save_outflows = "save_outflows.txt"

        expected_text = self.my_options.SECTION_NAME + '\n' + self.my_options.comment
        expected_text += "\nSAVE OUTFLOWS \tsave_outflows.txt"

        actual_text = self.my_options.get_text()
        assert Section.match_omit(actual_text, expected_text, " \t-")
Example #25
0
    def test_landuses(self):
        """Test LANDUSES section"""

        test_text = r"""
[LANDUSES]
;;               Cleaning   Fraction   Last
;;Name           Interval   Available  Cleaned
;;-------------- ---------- ---------- ----------
Residential_1    0          0          0
Residential_2    0          0          0
Commercial       0          0          0
LID              0          0          0
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.landuses
        assert Section.match_omit(project_section.get_text(), test_text,
                                  " \t-;\n")
    def test_dwf_section_example3(self):
        """Test DWF section from example 3"""

        from_text = Project()
        source_text = r"""
[DWF]
;;                                  Average    Time
;;Node             Parameter        Value      Patterns
;;-----------------------------------------------------
  KRO3001          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO6015          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO6016          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO6017          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1002          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1003          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1004          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1005          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1006          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1007          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1008          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1009          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1010          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1012          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1013          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1015          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO2001          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4004          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4008          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4009          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4010          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4011          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4012          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4013          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4014          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4015          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4017          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4018          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4019          FLOW             1          "" "" "DWF" "" "" "" ""
  SU1              FLOW             1          "" "" "DWF" "" "" "" ""
        """
        from_text.set_text(source_text)
        project_section = from_text.dwf
        assert Section.match_omit(project_section.get_text(), source_text,
                                  " \t-;\n")
    def test_dwf_section_example3(self):
        """Test DWF section from example 3"""

        from_text = Project()
        source_text = r"""
[DWF]
;;                                  Average    Time
;;Node             Parameter        Value      Patterns
;;-----------------------------------------------------
  KRO3001          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO6015          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO6016          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO6017          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1002          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1003          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1004          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1005          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1006          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1007          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1008          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1009          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1010          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1012          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1013          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO1015          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO2001          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4004          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4008          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4009          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4010          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4011          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4012          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4013          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4014          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4015          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4017          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4018          FLOW             1          "" "" "DWF" "" "" "" ""
  KRO4019          FLOW             1          "" "" "DWF" "" "" "" ""
  SU1              FLOW             1          "" "" "DWF" "" "" "" ""
        """
        from_text.set_text(source_text)
        project_section = from_text.dwf
        assert Section.match_omit(project_section.get_text(), source_text, " \t-;\n")
    def test_snowpacks_section(self):
        """Test SNOWPACKS section"""
        test_text = r"""
[SNOWPACKS]
;;Name           Surface    Parameters
;;-------------- ---------- ----------
sno              PLOWABLE   0.001      0.001      32.0       0.10       0.00       0.00       0.0
sno              IMPERVIOUS 0.001      0.001      32.0       0.10       0.00       0.00       0.00
sno              PERVIOUS   0.001      0.001      32.0       0.10       0.00       0.00       0.00
sno              REMOVAL    1.0        0.0        0.0        0.0        0.0        0.0
s                PLOWABLE   0.001      0.001      32.0       0.10       0.00       0.00       0.0
s                IMPERVIOUS 0.001      0.001      32.0       0.10       0.00       0.00       0.00
s                PERVIOUS   0.001      0.001      32.0       0.10       0.00       0.00       0.00
s                REMOVAL    1.0        0.0        0.0        0.0        0.0        0.0        w
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.snowpacks
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
    def test_subcatchments(self):
        """Test SUBCATCHMENTS section from Example 1"""
        test_text = """[SUBCATCHMENTS]
;;                                                   Total    Pcnt.             Pcnt.    Curb     Snow
;;Name             Raingage         Outlet           Area     Imperv   Width    Slope    Length   Pack
;;----------------------------------------------------------------------------------------------------
  1                RG1              9                10       50       500      0.01     0
  2                RG1              10               10       50       500      0.01     0
  3                RG1              13               5        50       500      0.01     0
  4                RG1              22               5        50       500      0.01     0
  5                RG1              15               15       50       500      0.01     0
  6                RG1              23               12       10       500      0.01     0
  7                RG1              19               4        10       500      0.01     0
  8                RG1              18               10       10       500      0.01     0
"""
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.subcatchments
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
    def test_snowpacks_section(self):
        """Test SNOWPACKS section"""
        test_text = r"""
[SNOWPACKS]
;;Name           Surface    Parameters
;;-------------- ---------- ----------
sno              PLOWABLE   0.001      0.001      32.0       0.10       0.00       0.00       0.0
sno              IMPERVIOUS 0.001      0.001      32.0       0.10       0.00       0.00       0.00
sno              PERVIOUS   0.001      0.001      32.0       0.10       0.00       0.00       0.00
sno              REMOVAL    1.0        0.0        0.0        0.0        0.0        0.0
s                PLOWABLE   0.001      0.001      32.0       0.10       0.00       0.00       0.0
s                IMPERVIOUS 0.001      0.001      32.0       0.10       0.00       0.00       0.00
s                PERVIOUS   0.001      0.001      32.0       0.10       0.00       0.00       0.00
s                REMOVAL    1.0        0.0        0.0        0.0        0.0        0.0        w
        """
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.snowpacks
        assert Section.match_omit(project_section.get_text(), test_text,
                                  " \t-;\n")
 def test_project_section(self):
     """Test EVAPORATION use project section"""
     test_text = ("[EVAPORATION]", ";;Type      \tParameters",
                  ";;----------\t----------", "CONSTANT    \t0.2",
                  "DRY_ONLY    \tNO")
     from_text = Project()
     test_text = '\n'.join(test_text)
     from_text.set_text(test_text)
     project_section = from_text.evaporation
     assert Section.match_omit(project_section.get_text(), test_text,
                               " \t-;\n")
     assert project_section.format == EvaporationFormat.CONSTANT
     assert project_section.constant == "0.2"
     assert project_section.monthly == ()
     assert project_section.timeseries == ''
     assert project_section.monthly_pan_coefficients == ()
     assert project_section.recovery_pattern == ''
     assert project_section.dry_only is False
     actual_text = project_section.get_text()
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     self.assertTrue(project_section.matches(test_text), msg)
 def test_project_section(self):
     """Test EVAPORATION use project section"""
     test_text = ("[EVAPORATION]",
                  ";;Type      \tParameters",
                  ";;----------\t----------",
                  "CONSTANT    \t0.2",
                  "DRY_ONLY    \tNO")
     from_text = Project()
     test_text = '\n'.join(test_text)
     from_text.set_text(test_text)
     project_section = from_text.evaporation
     assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")
     assert project_section.format == EvaporationFormat.CONSTANT
     assert project_section.constant == "0.2"
     assert project_section.monthly == ()
     assert project_section.timeseries == ''
     assert project_section.monthly_pan_coefficients == ()
     assert project_section.recovery_pattern == ''
     assert project_section.dry_only is False
     actual_text = project_section.get_text()
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     self.assertTrue(project_section.matches(test_text), msg)
    def runTest(self):
        """Test set_text and get_text of demand options"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_demands = from_text.demands

        assert Section.match_omit(project_demands.get_text(), source_text, " \t-;\n")

        assert project_demands.value[0].junction_id == "JUNCTION-0"
        assert project_demands.value[0].base_demand == "0.0"
        assert project_demands.value[0].demand_pattern == "PATTERN-1"
        assert project_demands.value[0].category == ''

        assert project_demands.value[1].junction_id == "JUNCTION-1"
        assert project_demands.value[1].base_demand == "0.1"
        assert project_demands.value[1].demand_pattern == "PATTERN-2"
        assert project_demands.value[1].category == ''

        assert project_demands.value[2].junction_id == "JUNCTION-12"
        assert project_demands.value[2].base_demand == "0.2"
        assert project_demands.value[2].demand_pattern == "PATTERN-12"
        assert project_demands.value[2].category == "Category-12"
    def runTest(self):
        """Test set_text and get_text of demand options"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_demands = from_text.demands

        assert Section.match_omit(project_demands.get_text(), source_text,
                                  " \t-;\n")

        assert project_demands.value[0].junction_id == "JUNCTION-0"
        assert project_demands.value[0].base_demand == "0.0"
        assert project_demands.value[0].demand_pattern == "PATTERN-1"
        assert project_demands.value[0].category == ''

        assert project_demands.value[1].junction_id == "JUNCTION-1"
        assert project_demands.value[1].base_demand == "0.1"
        assert project_demands.value[1].demand_pattern == "PATTERN-2"
        assert project_demands.value[1].category == ''

        assert project_demands.value[2].junction_id == "JUNCTION-12"
        assert project_demands.value[2].base_demand == "0.2"
        assert project_demands.value[2].demand_pattern == "PATTERN-12"
        assert project_demands.value[2].category == "Category-12"
Example #35
0
    def test_hydrographs(self):
        """Test HYDROGRAPHS section"""
        TEST_TEXT = (
            "[HYDROGRAPHS]",
            ";;Hydrograph\tMonth\tResponse\tR\tT\tK\tDmax\tDrecov\tDinit",
            "UH101 RG1", "UH101 ALL SHORT 0.033 1.0 2.0",
            "UH101 ALL MEDIUM 0.300 3.0 2.0\t1\t2\t3",
            "UH101 ALL LONG 0.033 10.0 2.0", "UH101 JUL SHORT 0.033 0.5 2.0",
            "UH101 JUL MEDIUM 0.011 2.0 2.0")
        from_text = Project()
        source_text = '\n'.join(TEST_TEXT)
        from_text.set_text(source_text)
        project_hydrographs = from_text.hydrographs

        assert Section.match_omit(project_hydrographs.get_text(), source_text,
                                  " \t-;\n")

        assert len(project_hydrographs.value) == 1

        val = project_hydrographs.value[0]

        assert val.group_name == "UH101"
        assert val.rain_gage_id == "RG1"
        assert len(val.value) == 5

        hydrograph_item = val.value[0]
        assert hydrograph_item.hydrograph_month == "ALL"
        assert hydrograph_item.term == "SHORT"
        assert hydrograph_item.response_ratio == "0.033"
        assert hydrograph_item.time_to_peak == "1.0"
        assert hydrograph_item.recession_limb_ratio == "2.0"
        assert hydrograph_item.initial_abstraction_depth == ''
        assert hydrograph_item.initial_abstraction_rate == ''
        assert hydrograph_item.initial_abstraction_amount == ''

        hydrograph_item = val.value[1]
        assert hydrograph_item.hydrograph_month == "ALL"
        assert hydrograph_item.term == "MEDIUM"
        assert hydrograph_item.response_ratio == "0.300"
        assert hydrograph_item.time_to_peak == "3.0"
        assert hydrograph_item.recession_limb_ratio == "2.0"
        assert hydrograph_item.initial_abstraction_depth == '1'
        assert hydrograph_item.initial_abstraction_rate == '2'
        assert hydrograph_item.initial_abstraction_amount == '3'

        hydrograph_item = val.value[2]
        assert hydrograph_item.hydrograph_month == "ALL"
        assert hydrograph_item.term == "LONG"
        assert hydrograph_item.response_ratio == "0.033"
        assert hydrograph_item.time_to_peak == "10.0"
        assert hydrograph_item.recession_limb_ratio == "2.0"
        assert hydrograph_item.initial_abstraction_depth == ''
        assert hydrograph_item.initial_abstraction_rate == ''
        assert hydrograph_item.initial_abstraction_amount == ''

        hydrograph_item = val.value[4]
        assert hydrograph_item.hydrograph_month == "JUL"
        assert hydrograph_item.term == "MEDIUM"
        assert hydrograph_item.response_ratio == "0.011"
        assert hydrograph_item.time_to_peak == "2.0"
        assert hydrograph_item.recession_limb_ratio == "2.0"
        assert hydrograph_item.initial_abstraction_depth == ''
        assert hydrograph_item.initial_abstraction_rate == ''
        assert hydrograph_item.initial_abstraction_amount == ''
    def test_pattern_section(self):
        """test PATTERNS section"""
        test_text = r"""
[PATTERNS]
;;Name           Type       Multipliers
;;-------------- ---------- -----------
;xx
x                MONTHLY    1.0   1.0   1.0   1.0   1.0   1.0
x                           1.0   1.0   1.0   1.0   1.0   1.0"""
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.patterns
        assert Section.match_omit(project_section.get_text(), test_text,
                                  " \t-;\n")

        test_text = r"""[PATTERNS]
;;Name             Type       Multipliers
;;----------------------------------------------------------------------
  DWF              HOURLY     .0151 .01373 .01812 .01098 .01098 .01922
  DWF                         .02773 .03789 .03515 .03982 .02059 .02471
  DWF                         .03021 .03789 .03350 .03158 .03954 .02114
  DWF                         .02801 .03680 .02911 .02334 .02499 .02718"""
        test_text = """
[PATTERNS]
;ID              	Multipliers
;Demand Pattern
 1               	1.0         	1.2         	1.4         	1.6         	1.4         	1.2
 1               	1.0         	0.8         	0.6         	0.4         	0.6         	0.8
        """

        test_text = """[PATTERNS]
;ID              	Multipliers
;Demand Pattern
 1               	1.26        	1.04        	.97         	.97         	.89         	1.19
 1               	1.28        	.67         	.67         	1.34        	2.46        	.97
 1               	.92         	.68         	1.43        	.61         	.31         	.78
 1               	.37         	.67         	1.26        	1.56        	1.19        	1.26
 1               	.6          	1.1         	1.03        	.73         	.88         	1.06
 1               	.99         	1.72        	1.12        	1.34        	1.12        	.97
 1               	1.04        	1.15        	.91         	.61         	.68         	.46
 1               	.51         	.74         	1.12        	1.34        	1.26        	.97
 1               	.82         	1.37        	1.03        	.81         	.88         	.81
 1               	.81
;Pump Station Outflow Pattern
 2               	.96         	.96         	.96         	.96         	.96         	.96
 2               	.62         	0           	0           	0           	0           	0
 2               	.8          	1           	1           	1           	1           	.15
 2               	0           	0           	0           	0           	0           	0
 2               	.55         	.92         	.92         	.92         	.92         	.9
 2               	.9          	.45         	0           	0           	0           	0
 2               	0           	.7          	1           	1           	1           	1
 2               	.2          	0           	0           	0           	0           	0
 2               	0           	.74         	.92         	.92         	.92         	.92
 2               	.92
;Pump Station Fluoride Pattern
 3               	.98         	1.02        	1.05        	.99         	.64         	.46
 3               	.35         	.35         	.35         	.35         	.35         	.35
 3               	.17         	.17         	.13         	.13         	.13         	.15
 3               	.15         	.15         	.15         	.15         	.15         	.15
 3               	.15         	.12         	.1          	.08         	.11         	.09
 3               	.09         	.08         	.08         	.08         	.08         	.08
 3               	.08         	.09         	.07         	.07         	.09         	.09
 3               	.09         	.09         	.09         	.09         	.09         	.09
 3               	.09         	.08         	.35         	.72         	.82         	.92
 3               	1
"""
        # Test Net 3
        test_text = """[PATTERNS]
    def test_pattern_section(self):
        """test PATTERNS section"""
        test_text = r"""
[PATTERNS]
;;Name           Type       Multipliers
;;-------------- ---------- -----------
;xx
x                MONTHLY    1.0   1.0   1.0   1.0   1.0   1.0
x                           1.0   1.0   1.0   1.0   1.0   1.0"""
        from_text = Project()
        from_text.set_text(test_text)
        project_section = from_text.patterns
        assert Section.match_omit(project_section.get_text(), test_text, " \t-;\n")

        test_text=r"""[PATTERNS]
;;Name             Type       Multipliers
;;----------------------------------------------------------------------
  DWF              HOURLY     .0151 .01373 .01812 .01098 .01098 .01922
  DWF                         .02773 .03789 .03515 .03982 .02059 .02471
  DWF                         .03021 .03789 .03350 .03158 .03954 .02114
  DWF                         .02801 .03680 .02911 .02334 .02499 .02718"""
        test_text = """
[PATTERNS]
;ID              	Multipliers
;Demand Pattern
 1               	1.0         	1.2         	1.4         	1.6         	1.4         	1.2
 1               	1.0         	0.8         	0.6         	0.4         	0.6         	0.8
        """

        test_text = """[PATTERNS]
;ID              	Multipliers
;Demand Pattern
 1               	1.26        	1.04        	.97         	.97         	.89         	1.19
 1               	1.28        	.67         	.67         	1.34        	2.46        	.97
 1               	.92         	.68         	1.43        	.61         	.31         	.78
 1               	.37         	.67         	1.26        	1.56        	1.19        	1.26
 1               	.6          	1.1         	1.03        	.73         	.88         	1.06
 1               	.99         	1.72        	1.12        	1.34        	1.12        	.97
 1               	1.04        	1.15        	.91         	.61         	.68         	.46
 1               	.51         	.74         	1.12        	1.34        	1.26        	.97
 1               	.82         	1.37        	1.03        	.81         	.88         	.81
 1               	.81
;Pump Station Outflow Pattern
 2               	.96         	.96         	.96         	.96         	.96         	.96
 2               	.62         	0           	0           	0           	0           	0
 2               	.8          	1           	1           	1           	1           	.15
 2               	0           	0           	0           	0           	0           	0
 2               	.55         	.92         	.92         	.92         	.92         	.9
 2               	.9          	.45         	0           	0           	0           	0
 2               	0           	.7          	1           	1           	1           	1
 2               	.2          	0           	0           	0           	0           	0
 2               	0           	.74         	.92         	.92         	.92         	.92
 2               	.92
;Pump Station Fluoride Pattern
 3               	.98         	1.02        	1.05        	.99         	.64         	.46
 3               	.35         	.35         	.35         	.35         	.35         	.35
 3               	.17         	.17         	.13         	.13         	.13         	.15
 3               	.15         	.15         	.15         	.15         	.15         	.15
 3               	.15         	.12         	.1          	.08         	.11         	.09
 3               	.09         	.08         	.08         	.08         	.08         	.08
 3               	.08         	.09         	.07         	.07         	.09         	.09
 3               	.09         	.09         	.09         	.09         	.09         	.09
 3               	.09         	.08         	.35         	.72         	.82         	.92
 3               	1
"""
        # Test Net 3
        test_text = """[PATTERNS]