def as_text(self, project):
        # Figure out which kind of infiltration will be written for this project
        infiltration = project.options.infiltration.upper()
        if infiltration == "HORTON":
            self.write_infiltration = SectionWriterAsList(
                "[INFILTRATION]", HortonInfiltrationWriter,
                ";;Subcatchment  \tMaxRate   \tMinRate   \tDecay     \tDryTime   \tMaxInfiltration\n"
                ";;--------------\t----------\t----------\t----------\t----------\t----------"
            )
        elif infiltration.startswith("GREEN"):
            self.write_infiltration = SectionWriterAsList(
                "[INFILTRATION]", GreenAmptInfiltrationWriter,
                ";;Subcatchment  \tSuction   \tKsat      \tIMD       \n"
                ";;--------------\t----------\t----------\t----------")
        elif infiltration.startswith("CURVE"):
            self.write_infiltration = SectionWriterAsList(
                "[INFILTRATION]", CurveNumberInfiltrationWriter,
                ";;Subcatchment  \tCurveNum  \t          \tDryTime   \n"
                ";;--------------\t----------\t----------\t----------")

        derived_sections = {}

        subareas = SectionAsList("[SUBAREAS]")
        subareas.value = project.subcatchments.value
        subareas_text = self.write_subareas.as_text(subareas)
        if subareas_text:
            derived_sections[subareas.SECTION_NAME] = subareas_text

        tags_text = TagsWriter.as_text(project)
        if tags_text:
            derived_sections[TagsWriter.SECTION_NAME] = tags_text

        symbols = SectionAsList("[SYMBOLS]")
        symbols.value = project.raingages.value
        symbols_writer = SectionWriterAsList(
            "[SYMBOLS]", CoordinateWriter,
            ";Gage            \tX-Coord   \tY-Coord")
        symbols_text = symbols_writer.as_text(symbols)
        if symbols_text:
            derived_sections[symbols.SECTION_NAME] = symbols_text

        coordinates = SectionAsList("[COORDINATES]")
        coordinates.value = project.all_nodes()
        coord_comment = ";Node            \tX-Coord   \tY-Coord"
        if project.map.crs_name:
            coord_crs_comment = ";CRS=" + project.map.crs_name
            if project.map.crs_unit:
                coord_crs_comment = coord_crs_comment + "|CRS_UNIT=" + project.map.crs_unit
            if coord_crs_comment:
                coord_comment = coord_crs_comment + "\n" + coord_comment

        coordinates_writer = SectionWriterAsList("[COORDINATES]",
                                                 CoordinateWriter,
                                                 coord_comment)
        coordinates_text = coordinates_writer.as_text(coordinates)
        if coordinates_text:
            derived_sections[coordinates.SECTION_NAME] = coordinates_text

        vertices = SectionAsList("[VERTICES]")
        vertices.value = project.all_vertices(True)
        vertices_writer = SectionWriterAsList(
            "[VERTICES]", CoordinateWriter,
            ";Link            \tX-Coord   \tY-Coord")
        vertices_text = vertices_writer.as_text(vertices)
        if vertices_text:
            derived_sections[vertices.SECTION_NAME] = vertices_text

        polygons = SectionAsList("[POLYGONS]")
        polygon_list = []
        for subc in project.subcatchments.value:
            for vertex in subc.vertices:
                vertex.name = subc.name
            polygon_list.append(subc.vertices)
        polygons.value = polygon_list
        polygons_writer = SectionWriterAsList(
            "[POLYGONS]", PolygonWriter,
            ";Link            \tX-Coord   \tY-Coord")
        polygons_text = polygons_writer.as_text(polygons)
        if polygons_text:
            derived_sections[polygons.SECTION_NAME] = polygons_text

        losses = SectionAsList("[LOSSES]")  # (list of Conduit)
        losses.value = project.conduits.value
        losses_text = self.write_losses.as_text(losses)
        if losses_text:
            derived_sections[losses.SECTION_NAME] = losses_text

        inp = InputFileWriterBase.as_text(self, project, derived_sections)

        return inp
    def as_text(self, project):
        derived_sections = {}

        quality_text = QualityWriter.as_text(project)
        if quality_text:
            derived_sections[QualityWriter.SECTION_NAME] = quality_text

        coordinates = SectionAsList("[COORDINATES]")
        coordinates.value = project.all_nodes()
        coord_comment = ";Node            \tX-Coord   \tY-Coord"
        if project.map.crs_name:
            coord_crs_comment = ";CRS=" + project.map.crs_name
            if project.map.crs_unit:
                coord_crs_comment = coord_crs_comment + "|CRS_UNIT=" + project.map.crs_unit
            if coord_crs_comment:
                coord_comment = coord_crs_comment + "\n" + coord_comment

        coordinates_writer = SectionWriterAsList("[COORDINATES]", CoordinateWriter, coord_comment)
        coordinates_text = coordinates_writer.as_text(coordinates)
        if coordinates_text:
            derived_sections[coordinates_writer.SECTION_NAME] = coordinates_text

        vertices = SectionAsList("[VERTICES]")
        vertices.value = project.all_vertices(True)
        vertices_writer = SectionWriterAsList("[VERTICES]", CoordinateWriter,
                                              ";Link            \tX-Coord   \tY-Coord")
        vertices_text = vertices_writer.as_text(vertices)
        if vertices_text:
            derived_sections[vertices_writer.SECTION_NAME] = vertices_text

        tags_text = TagsWriter.as_text(project)
        if tags_text:
            derived_sections[TagsWriter.SECTION_NAME] = tags_text

        mixing = SectionAsList('[MIXING]')
        mixing.value = project.tanks.value
        mixing_text = self.write_mixing.as_text(mixing)
        if mixing_text:
            derived_sections[mixing.SECTION_NAME] = mixing_text

        emitters = SectionAsList('[EMITTERS]')
        emitters.value = project.junctions.value
        emitters_text = self.write_emitters.as_text(emitters)
        if emitters_text:
            derived_sections[emitters.SECTION_NAME] = emitters_text

        status = SectionAsList('[STATUS]')
        status.value = project.all_links()
        status_text = self.write_status.as_text(status)
        if status_text:
           derived_sections[status.SECTION_NAME] = status_text

        inp = InputFileWriterBase.as_text(self, project, derived_sections)
        inp += '\n' + '[END]' + '\n'

        return inp
    def as_text(self, project):
        # Figure out which kind of infiltration will be written for this project
        infiltration = project.options.infiltration.upper()
        if infiltration == "HORTON":
            self.write_infiltration = SectionWriterAsList(
                "[INFILTRATION]", HortonInfiltrationWriter,
                ";;Subcatchment  \tMaxRate   \tMinRate   \tDecay     \tDryTime   \tMaxInfiltration\n"
                ";;--------------\t----------\t----------\t----------\t----------\t----------"
            )
        elif infiltration.startswith("GREEN"):
            self.write_infiltration = SectionWriterAsList(
                "[INFILTRATION]", GreenAmptInfiltrationWriter,
                ";;Subcatchment  \tSuction   \tKsat      \tIMD       \n"
                ";;--------------\t----------\t----------\t----------")
        elif infiltration.startswith("CURVE"):
            self.write_infiltration = SectionWriterAsList(
                "[INFILTRATION]", CurveNumberInfiltrationWriter,
                ";;Subcatchment  \tCurveNum  \t          \tDryTime   \n"
                ";;--------------\t----------\t----------\t----------")

        inp = InputFileWriterBase.as_text(self, project)

        subareas = SectionAsList("[SUBAREAS]")
        subareas.value = project.subcatchments.value
        subareas_text = self.write_subareas.as_text(subareas)
        if subareas_text:
            inp += '\n' + subareas_text + '\n'

        tags_text = self.write_tags.as_text(project)
        if tags_text:
            inp += '\n' + tags_text + '\n'

        symbols = SectionAsList("[SYMBOLS]")
        symbols.value = project.raingages.value
        symbols_writer = SectionWriterAsList(
            "[SYMBOLS]", CoordinateWriter,
            ";Gage            \tX-Coord   \tY-Coord")
        symbols_text = symbols_writer.as_text(symbols)
        if symbols_text:
            inp += '\n' + symbols_text + '\n'

        coordinates = SectionAsList("[COORDINATES]")
        coordinates.value = project.all_nodes()
        coordinates_writer = SectionWriterAsList(
            "[COORDINATES]", CoordinateWriter,
            ";Node            \tX-Coord   \tY-Coord")
        coordinates_text = coordinates_writer.as_text(coordinates)
        if coordinates_text:
            inp += '\n' + coordinates_text + '\n'

        vertices = SectionAsList("[VERTICES]")
        vertices.value = project.all_vertices(True)
        vertices_writer = SectionWriterAsList(
            "[VERTICES]", CoordinateWriter,
            ";Link            \tX-Coord   \tY-Coord")
        vertices_text = vertices_writer.as_text(vertices)
        if vertices_text:
            inp += '\n' + vertices_text + '\n'

        losses = SectionAsList("[LOSSES]")  # (list of Conduit)
        losses.value = project.conduits.value
        losses_text = self.write_losses.as_text(losses)
        if losses_text:
            inp += '\n' + losses_text + '\n'

        return inp
Beispiel #4
0
    def as_text(self, project):

        inp = InputFileWriterBase.as_text(self, project)

        quality_text = QualityWriter.as_text(project)
        if quality_text:
            inp += '\n' + quality_text + '\n'

        coordinates = SectionAsList("[COORDINATES]")
        coordinates.value = project.all_nodes()
        coordinates_writer = SectionWriterAsList("[COORDINATES]", CoordinateWriter,
                                                 ";Node            \tX-Coord   \tY-Coord")
        coordinates_text = coordinates_writer.as_text(coordinates)
        if coordinates_text:
            inp += '\n' + coordinates_text + '\n'

        vertices = SectionAsList("[VERTICES]")
        vertices.value = project.all_vertices(True)
        vertices_writer = SectionWriterAsList("[VERTICES]", CoordinateWriter,
                                              ";Link            \tX-Coord   \tY-Coord")
        vertices_text = vertices_writer.as_text(vertices)
        if vertices_text:
            inp += '\n' + vertices_text + '\n'

        tags_text = TagsWriter.as_text(project)
        if tags_text:
            inp += '\n' + tags_text + '\n'

        mixing = SectionAsList('[MIXING]')
        mixing.value = project.tanks.value
        mixing_text = self.write_mixing.as_text(mixing)
        if mixing_text:
            inp += '\n' + mixing_text + '\n'

        emitters = SectionAsList('[EMITTERS]')
        emitters.value = project.junctions.value
        emitters_text = self.write_emitters.as_text(emitters)
        if emitters_text:
            inp += '\n' + emitters_text + '\n'

        inp += '\n' + '[END]' + '\n'

        return inp