Skip to content

Instantly share code, notes, and snippets.

View asselapathirana's full-sized avatar

Assela Pathirana asselapathirana

View GitHub Profile
def remove_layers(layer=None):
qinst=QgsProject.instance()
lyrs=['perp', 'fwlshift', 'slope_vector'] if not layer else [layer]
for name in lyrs:
try:
for l in qinst.mapLayersByName(name):
qinst.removeMapLayer(l.id())
except:
print("Layer not found (not an error)")
"""
Reduces the diameter of a pipe gradually and calculates pressure at the end of
pipe for each value of the diameter.
"""
import matplotlib # we need matplotlib for plotting later
matplotlib.use('Qt5Agg') # Not esential. But QtAgg backend seems to work better for plotting
import matplotlib.pyplot as plt # for plotting later
from epanettools import epanettools # import epanet package