import modelskill as ms
= ms.PointObservation("../data/SW/HKNA_Hm0.dfs0", item=0,
hkna =4.2420, y=52.6887,
x="HKNA")
name
= ms.TrackObservation("../data/SW/Alti_c2_Dutch.dfs0", item=3,
c2 ="c2") name
Workflow
A typical ModelSkill workflow consists of these four steps:
- Define Observations
- Define ModelResults
- Match observations and ModelResults in space and time
- Do analysis, plotting, etc with a Comparer
Define Observations
The first step is to define the measurements to be used for the skill assessment. Two types of observation are available:
Let’s assume that we have one PointObservation and one TrackObservation (name
is used to identify the observation, similar to the name
of the model above).
In this case both observations are provided as .dfs0 files but pandas dataframes are also supported in case data are stored in another file format.
Both PointObservation and TrackObservation need the path of the data file, the item number (or item name) and a name. A PointObservation further needs to be initialized with it's x-, y-position.
Define ModelResults
The result of a simulation is stored in one or more result files, e.g. dfsu, dfs0, nc, csv.
The name is used to identify the model result in the plots and tables.
= ms.DfsuModelResult("../data/SW/HKZN_local_2017_DutchCoast.dfsu",
mr ="Sign. Wave Height",
item='HKZN_local') name
Match observations and ModelResults
The match() function returns a Comparer (a single observation) or a ComparerCollection (multiple observations) for further analysis and plotting.
= ms.match([hkna, c2], mr)
cc cc
<ComparerCollection>
Comparers:
0: HKNA - Significant wave height [m]
1: c2 - Significant wave height [m]
See matching page for more information.
Do analysis, plotting, etc with a Comparer
The object returned by the match()
function is a Comparer/ComparerCollection. It holds the matched observation and model data and has methods for plotting and skill assessment.
The primary comparer methods are:
- skill() which returns a SkillTable with the skill scores
- various plot methods of the comparer objects (e.g.
plot.scatter()
,plot.timeseries()
) - sel() method for selecting data
Filtering
In order to select only a subset of the data for analysis, the comparer has a sel()
method which returns a new comparer with the selected data.
This method allow filtering of the data in several ways:
- on
observation
by specifying name or index of one or more observations - on
model
(if more than one is compared) by giving name or index - temporal using the
time
(orstart
andend
) arguments - spatial using the
area
argument given as a bounding box or a polygon
Save / load the ComparerCollection
It can be useful to save the comparer collection for later use. This can be done using the save()
method:
"my_comparer_collection.msk") cc.save(
The comparer collection can be loaded again from disk, using the load()
method:
= ms.load("my_comparer_collection.msk") cc