Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{scrollbar}

Exercise outline

We want to create a station class (data structure) that can hold the data of one station. Then we make a list containing all the stations in the NetCdf file and fill it with the data of the NetCdf file.

Add monitoring points for stations in envelope


Add the following import statements to the region Import libs:

Code Block
languagepython
# DeltaShell libs
from DelftTools.Hydro2D.Features import Feature2DPoint
from DeltaShell.Plugins.FMSuite.FlowFM.Layers import UnstructuredGridLayer


And add this code to the end of the script :

Code Block
languagepython
#region Add monitoring points for stations in envelope

# Get bounding box of grid
gridLayer = UnstructuredGridLayer()
gridLayer.Grid = fmModel.Grid
envelope = gridLayer.Envelope

# Get stations in envelope
stationsInEvelope = []
for station in stationList:
	if (gridLayer.Envelope.Contains(station.geometry.Coordinate)):
		stationsInEvelope.append(station)

print "Nr of stations in grid extend : " + str(len(stationsInEvelope))

# Add monitoring point at station locations
for station in stationsInEvelope:
	observationPoint = Feature2DPoint()
	observationPoint.Name = station.name
	observationPoint.Geometry = station.geometry

	fmModel.Area.ObservationPoints.Add(observationPoint)

	print "Added : " + station.name + " to observation points"

#endregion


we start by getting the bounds of the grid. We do this by creating a grid layer (UnstructuredGridLayer) and get the Envelope property:

Code Block
languagepython
# Get bounding box of grid
gridLayer = UnstructuredGridLayer()
gridLayer.Grid = fmModel.Grid
envelope = gridLayer.Envelope


Now we create a new list for the stations that are in the grid envelope, and loop through all the stations to see if they are in the envelope:

Code Block
languagepython
# Get stations in envelope
stationsInEvelope = []
for station in stationList:
	if (gridLayer.Envelope.Contains(station.geometry.Coordinate)):
		stationsInEvelope.append(station)

print "Nr of stations in grid extend : " + str(len(stationsInEvelope))


We can now use these stations to create observation points (Feature2DPoint) using the name and geometry of the stations

Code Block
languagepython
# Add monitoring point at station locations
for station in stationsInEvelope:
    observationPoint = Feature2DPoint()
    observationPoint.Name = station.name
    observationPoint.Geometry = station.geometry
 
    fmModel.Area.ObservationPoints.Add(observationPoint)
 
    print "Added : " + station.name + " to observation points"



Wiki Markup
{scrollbar}