Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #417 from USEPA/dev-ui-py3qt5
Browse files Browse the repository at this point in the history
MTP7r0 release
  • Loading branch information
TongZhai authored Jun 23, 2020
2 parents aa915b2 + 42da06e commit c25cc31
Show file tree
Hide file tree
Showing 112 changed files with 2,412 additions and 659 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@
/.idea/modules.xml
/.idea/workspace.xml
*.pyc
src/ui/SWMM/dist
src/ui/SWMM/build
src/ui/SWMM/output
src/ui/EPANET/dist
src/ui/EPANET/build
src/ui/EPANET/output
*.xml
*.whl
*_my*
*.swo
*.swp
Binary file added .gitignore.swp
Binary file not shown.
6 changes: 3 additions & 3 deletions src/Externals/swmm/outputapi/SMOutputSWIG.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_series(self, output, attribute, start_index=0, num_values=-1):
elif attribute.smo_type == _lib.SMO_link:
tseries = _lib.getlinkseries(output.ptrapi, self._index, attribute.index, start_index, output.num_periods)
elif attribute.smo_type == _lib.SMO_sys:
tseries = _lib.getsystemseries(output.ptrapi, self._index, attribute.index, start_index, output.num_periods)
tseries = _lib.getsystemseries(output.ptrapi, attribute.index, start_index, output.num_periods)
except Exception as e:
print("Error reading series " + self.type_label + " " + str(self.name) + ', att #' + str(attribute.index))
msg_buf = ""
Expand Down Expand Up @@ -564,7 +564,7 @@ def get_time_series(self, type_label, object_id, attribute_name):
import pandas
item = None
if "SYSTEM" in type_label.upper():
item = self.system.items()[0][1] # SwmmOutputSystem
item = self.system.get('-1') # SwmmOutputSystem
else:
item = self.get_items(type_label)[object_id] # SwmmOutputSubcatchment, Link, Node

Expand All @@ -588,7 +588,7 @@ def get_time_series(self, type_label, object_id, attribute_name):

def get_item_unit(self, type_label, object_id, attribute_name):
if "SYSTEM" in type_label.upper():
item = self.system.items()[0][1]
item = self.system.get('-1') # SwmmOutputSystem
else:
item = self.get_items(type_label)[object_id] # SwmmOutputSubcatchment
attribute = item.get_attribute_by_name(attribute_name) # SwmmOutputAttribute
Expand Down
27 changes: 16 additions & 11 deletions src/core/epanet/inp_reader_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,48 @@ def read_section(self, project, section_name, section_text):
self.defer_calibrations = section_text
return
elif section_name_upper == "[PIPES]":
self.check_valid_node_id(project, 'PIPES', section_text)
# self.check_valid_node_id(project, 'PIPES', section_text)
pass
elif section_name_upper == "[PUMPS]":
self.check_valid_node_id(project, 'PUMPS', section_text)
# self.check_valid_node_id(project, 'PUMPS', section_text)
pass
elif section_name_upper == "[VALVES]":
self.check_valid_node_id(project, 'VALVES', section_text)
# self.check_valid_node_id(project, 'VALVES', section_text)
pass
elif section_name_upper == "[DEMANDS]":
self.check_valid_node_id(project, 'DEMANDS', section_text)
# self.check_valid_node_id(project, 'DEMANDS', section_text)
pass
elif section_name_upper == "[SOURCES]":
self.check_valid_node_id(project, 'SOURCES', section_text)
# self.check_valid_node_id(project, 'SOURCES', section_text)
pass
InputFileReader.read_section(self, project, section_name, section_text)

def finished_reading(self, project):
if self.defer_quality:
self.check_valid_node_id(project, 'QUALITY', self.defer_quality)
# self.check_valid_node_id(project, 'QUALITY', self.defer_quality)
QualityReader.read(self.defer_quality, project)
self.defer_quality = None
if self.defer_coordinates:
self.check_valid_node_id(project, 'COORDINATES', self.defer_coordinates)
# self.check_valid_node_id(project, 'COORDINATES', self.defer_coordinates)
CoordinatesReader.read(self.defer_coordinates, project)
self.defer_coordinates = None
if self.defer_vertices:
self.check_valid_link_id(project, 'VERTICES', self.defer_vertices)
# self.check_valid_link_id(project, 'VERTICES', self.defer_vertices)
VerticesReader.read(self.defer_vertices, project)
self.defer_vertices = None
if self.defer_tags:
TagsReader.read(self.defer_tags, project)
self.defer_tags = None
if self.defer_mixing:
self.check_valid_node_id(project, 'MIXING', self.defer_mixing)
# self.check_valid_node_id(project, 'MIXING', self.defer_mixing)
MixingReader.read(self.defer_mixing, project)
self.defer_mixing = None
if self.defer_emitters:
self.check_valid_node_id(project, 'EMITTERS', self.defer_emitters)
# self.check_valid_node_id(project, 'EMITTERS', self.defer_emitters)
EmittersReader.read(self.defer_emitters, project)
self.defer_emitters = None
if self.defer_status:
self.check_valid_link_id(project, 'STATUS', self.defer_status)
# self.check_valid_link_id(project, 'STATUS', self.defer_status)
StatusReader.read(self.defer_status, project)
self.defer_status = None
project.metric = project.options.hydraulics.flow_units in flow_units_metric
Expand Down
10 changes: 6 additions & 4 deletions src/core/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import matplotlib.pyplot as plt
from matplotlib import dates
import colorsys
from matplotlib.cm import get_cmap
import cycler
import datetime
import numpy as np


class SWMM:
Expand Down Expand Up @@ -98,9 +98,11 @@ def plot_time(output, lines_list, elapsed_flag, start_index, num_steps):
left_y_plot.yaxis.tick_left() # Only show left-axis tics on left axis
plot_on = right_y_plot

color = colorsys.hsv_to_rgb(np.random.rand(), 1, 1)
colors = get_cmap('Dark2').colors
color_cycler = cycler.cycler('color', colors)
plt.rc('axes', prop_cycle=color_cycler)
legend_text = legend_text.strip('"')
new_line = plot_on.plot(x_values, y_values, label=legend_text, c=color)[0]
new_line = plot_on.plot(x_values, y_values, label=legend_text)[0]
lines_plotted.append(new_line)
line_legends.append(legend_text)
old_label = plot_on.get_ylabel()
Expand Down
14 changes: 11 additions & 3 deletions src/core/inp_reader_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,20 +312,28 @@ def _init_section(self):
def read(self, new_text):
section = self._init_section()
comment = ''
keep_per_item_comment = True
new_text = new_text.encode('ascii', errors='ignore') # strip out non-ascii characters
new_text = str(new_text, 'utf-8', 'ignore')
if new_text.startswith('[LANDUSE'):
keep_per_item_comment = True
new_text = new_text.lstrip() # xw20170328, remove heading white spaces indluing /n /t and spaces
for line in new_text.splitlines()[1:]: # process each line after the first one [section name]
# if row starts with semicolon or is blank, add as a comment
if line.lstrip().startswith(';') or not line.strip():
if section.value: # If we have already added items to this section, add comment as a Section
if section.value or len(comment) > 0: # If we have already added items to this section, add comment as a Section
# comment += line xw20170327
if len(comment) > 0: # xw20170327, added \n for multiple lines of comments within a section
comment += "\n" + line
else:
comment += line
else: # If we are still at the beginning of the section, set comment instead of adding a Section
self.set_comment_check_section(section, line)
if line.startswith(';;'):
self.set_comment_check_section(section, line)
elif keep_per_item_comment and line.startswith(';'):
comment = line
else:
if comment:
if keep_per_item_comment and comment:
line = line + ' ' + comment
comment = ''
self.read_item(section, line)
Expand Down
7 changes: 4 additions & 3 deletions src/core/inp_writer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ def as_text(self, project, derived_sections):
else:
writer = SectionWriterAsList(section_name, SectionWriter(), None)
try:
section_text = writer.as_text(section).rstrip('\n')
if section_text and section_text != '[END]': # Skip adding blank sections
section_text_list.append(section_text)
if writer.as_text(section):
section_text = writer.as_text(section).rstrip('\n')
if section_text and section_text != '[END]': # Skip adding blank sections
section_text_list.append(section_text)

# If we have a section order and derived sections to insert,
# insert any derived sections that come directly after this section.
Expand Down
18 changes: 14 additions & 4 deletions src/core/project_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,20 @@ def all_links(self):
def find_link(self, link_name):
for link_group in self.links_groups():
if link_group and link_group.value:
try:
return link_group.find_item(link_name)
except:
return None
possible_match = link_group.find_item(link_name)
if possible_match:
return possible_match
return None

def find_node(self, node_name):
if node_name is None or not isinstance(node_name, str) or node_name == '':
return None
for node_group in self.nodes_groups():
if node_group.value and len(node_group.value) > 0:
existing_node = node_group.find_item(node_name)
if existing_node is not None:
return existing_node
return None

def all_vertices(self, set_names=False):
""" Return a list of Coordinate objects, one for each internal vertices of all links.
Expand Down
10 changes: 5 additions & 5 deletions src/core/swmm/hydrology/lidcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ def __init__(self):
self.drainmat_roughness = "0.1"

self.removal_pollutant1 = ''
self.removal_removal1 = '0'
self.removal_removal1 = ''
self.removal_pollutant2 = ''
self.removal_removal2 = '0'
self.removal_removal2 = ''
self.removal_pollutant3 = ''
self.removal_removal3 = '0'
self.removal_removal3 = ''
self.removal_pollutant4 = ''
self.removal_removal4 = '0'
self.removal_removal4 = ''
self.removal_pollutant5 = ''
self.removal_removal5 = '0'
self.removal_removal5 = ''
22 changes: 22 additions & 0 deletions src/core/swmm/hydrology/subcatchment.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,28 @@ def __init__(self):
self.custom_deep_flow_equation = ''


class GroundwaterFlowType(Enum):
LATERAL = 1
DEEP = 2


class GWF(Section):
"""Defines custom groundwater flow equations for specific subcatchments"""

def __init__(self):
Section.__init__(self)

## Name of the Subcatchment defined in [SUBCATCHMENTS]
self.subcatchment_name = 'None'

## Flow type: LATERAL (for lateral flow to a node of the conveyance network)
## or DEEP (for vertical loss to deep groundwater)
self.groundwater_flow_type = GroundwaterFlowType.LATERAL

## Math formula expressing the rate of groundwater flow
self.custom_equation = ''


class LIDUsage(Section):
"""Specifies how an LID control will be deployed in a subcatchment"""

Expand Down
Loading

0 comments on commit c25cc31

Please sign in to comment.