Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Wiki Markup
{scrollbar}

h2. 

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
{color}:

{code:language=python}
# 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
{code}
\\
And add this code to the end of the script :
{code:language=python}
#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

{code}
\\
we start by getting the bounds of the grid. We do this by creating a grid layer (UnstructuredGridLayer) and get the Envelope property:
{code:language=python


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
{code}
\\
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:language=python}


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))
{code}
\\
We can now use these stations to create observation points 


We can now use these stations to create observation points (Feature2DPoint)

...

using

...

the

...

name

...

and

...

geometry

...

of

...

the

...

stations

{:=
Code Block
language
python
}
# 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"
{code}
\\
\\



Wiki Markup
{scrollbar}