OpennessJohan Hartnack
The needs are changing
• Models used for:
− On-line systems
− Optimization framework
− Monte Carlo runs
− Web applications
• Requiring easy accessible functionality for
− Model parameter settings
− Reading model results
− Evaluation of model results
Software empowering you
• Utilize the models in a more free setting
• Integrate model in real time
• Disseminate results to your needs
controller.Initialize(diagnostics);
controller.Prepare();
controller.Run();
controller.Finish();
Empowering tools
© DHI
Input and output Optimization and customization Web components
MIKE SDKSoftware Development Kit
© DHI
An SDK is
© DHI
Webopedia:
“Short for Software Development Kit, a programming package that enables a
programmer to develop applications for a specific platform. Typically an SDK includes
one or more APIs, programming tools, and documentation.”
Wikipedia:
“A Software Development Kit (SDK) is typically a set of software development tools that
allows for the creation of applications for a certain software package…” [snip]
API = Application Programmer Interface
The MIKE SDK is:
© DHI
• A small installer program.
• A set of API’s for .NET
− Data File System (DFS)
− Parameter File System (PFS)
• Documentation
• Examples
API = Application Programmer Interface
How to get the MIKE SDK
© DHI
Included in MIKE SDK: Documentation
© DHI
• MIKE SDK Documentation Index (start menu)
• DFS User Guide (PDF)
• DFS API documentation, DHI.Generic.MikeZero.DFS.chm
• FM file specification (PDF)
• PFS API documentation, DHI.PFS.chm
• SDK Examples (zip with examples and test data)
DFS – Data File System
© DHI
• Binary file format
• Generic format for handling
data that is
− spatially distributed
− time varying
• Basis for dfs0+1+2+3+u,
res11, res1d (and xns11)
DFS vs. DFS0+1+2+3+u
© DHI
DFSis a standard for storing certain information in a file.
DFS0+1+2+3+u, res11, res1dA special use of DFS standard.
DFS File content
© DHI
A DFS file is conceptually split into:
• Header section: General information,
as start time, geographic map
projection etc.
• Static data section, static items:
independent of time.
• Dynamic data section: time varying
data.
Projection
© DHI
The DFS file projection contains
• A projection string (WKT)
• A reference longitude and latitude coordinate
• A reference “true north” orientation
Type: Undefined projection (older files)
WKT = “Well Known Text”
IDfsProjection projection = dfsFile.FileInfo.Projection;
string wktString = projection.WKTString;
double lon = projection.Longitude;
double lat = projection.Latitude;
Coordinate systems
© DHI
DFS works with three
coordinate systems:
• Geographical coordinate system
longitude and latitude coordinates
• Projected coordinate system,
Easting and northing coordinates
• User defined coordinate system,
containing x and y coordinates
DFS API
© DHI
A set of interfaces and classes for reading, modifying and creating dfs
files.
// Open a dfs0 fileIDfsFile dfs0File = DfsFileFactory.DfsGenericOpen(dfs0Filename);
// Retrieve number of time steps in fileIDfsFileInfo fileInfo = dfs0File.FileInfo;int steps = fileInfo.TimeAxis.NumberOfTimeSteps;
// Read data of first item, third time stepIDfsItemData data = dfs0File.ReadItemTimeStep(1, 2);double value = System.Convert.ToDouble(data.Data.GetValue(0));
DFS API
© DHI
Split up into two levels:
• Generic DFS: API for accessing DFS file, as a generic DFS
• Specific DFS: API specific for typical types of DFS files:
dfs1+2+3, dfsu
Static Items
© DHI
• No time – one set of values only
• A file can have any number of static
items – number of static items are
not known when opening file.
• Almost same properties as dynamic item – includes data
− Name; user defined description of the item
− EUM quantity, i.e., EUM type and EUM unit
− Spatial axis
− Type of data, being float, double, integer, etc.
− Reference coordinates and orientation
Ways of opening a file
© DHI
• Open: For reading only
• Open-Edit: For editing, file pointer at first item-time step
• Open-Append: For editing, file pointer after last item-time step
All 3 version exist for all file types: Generic, dfs1+2+3+u
dfsFile = DfsFileFactory.DfsGenericOpen(filename);dfsFile = DfsFileFactory.DfsGenericOpenEdit(filename);dfsFile = DfsFileFactory.DfsGenericOpenAppend(filename);
Creating a DFS file – DfsBuilder
© DHI
• Assure file is build correctly, all required data is set.
3 stages, builder handles the first two:
• Define header and dynamic items
• Define and write static items
• Write dynamic item data
Exploring a DFS file in MIKE Zero – Data Utility
© DHI
Started from Mike Zero menu:
• ”File” – ”Options” – ”Data Utility”
Shows:• Header info
− Dynamic item info
− Custom Blocks
• Static item info
Parameter File System – PFS file content
© DHI
Text file:
• Target (out-most section)
• Sections
• Sub-sections
• Keywords
• Parameters double, int, bool, filename, string, CLOB
[Run11]key1 = 2, truekey3 = 3.3, 4, 'someText'key3 = '<CLOB:2,2.7,-4,7.07>'[Results]
[Result] outid = 'default out'file = |.\output.res11|
EndSect // Result
EndSect // Results
EndSect // Run11
PFS API
© DHI
Similar to DFS, just for PFS file
// Loading/Reading the filePFSFile pfsFile = new PFSFile(filePath, false);
// Outmost sectionPFSSection target = pfsFile.GetTarget("Run11", 1);
// Sub-sectionsPFSSection section1 = target.GetSection("Results", 1);PFSSection section2 = section1.GetSection("Result", 1);
// Keywords and paramtersstring bridge = section2.GetKeyword("outid", 1).GetParameter(1).ToString();
Actions
© DHI
Read, modify, delete, add:
• Sections
• Keywords
• Parameters
PFSFile pfsFile = new PFSFile(filePath, false);PFSSection sect = pfsFile.GetTarget("Run11", 1);PFSKeyword keyword = sect.GetKeyword("key3", 1);int intVal = keyword.GetParameter(2).ToInt(); // Read integer parameterkeyword.InsertNewParameterInt(222, 2); // Insert parametersect.DeleteKeyword("key3", 2); // Delete keywordsect.DeleteSection(1); // Delete sub-sectionsect.ModifyName("newName"); // Modify name pfsFile.Write("NewFileName"); // Write modified file
Check: DHI.PFS.chm
MATLAB
© DHI
• Simple GUI, easy to get started
• High level data types (matrices) and programming language
− Faster development (prototyping), less errors
• Powerful graphics.
− 2D, 3D, many different plot-types, simple to use,
with low level control for those wanting it.
• Efficient numerical implementations
− Linear algebra
− Digital Signal Processing
− Simulations of dynamic and embedded
systems (Simulink)
• Commercial – expensive! 3.3 3.4 3.5 3.6 3.7
x 105
6.14
6.16
6.18
6.2
6.22
x 106
-1
-0.5
0
0.5
Surface elevation (m), color using Current speed (m/s)
step 2 (element values)
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
DFS in MATLAB
© DHI
• MATLAB Release 2011a (R2011a) or later is required, (due to .NET 4.0 compatibility)
• DFS classes and interfaces can be used directly
• Add an import DFS assembly
• DHI MATLAB Toolbox: Convenience tools and examples, but not
required!
http://www.mikebydhi.com/Download/DocumentsAndTools/Tools/DHIMatLabToolbox.aspx
NET.addAssembly('DHI.Generic.MikeZero.DFS');import DHI.Generic.MikeZero.DFS.*;
IronPython
© DHI
• OpenSource Python interpreter
• Tightly integrated with .NET
• Script based
• Type less language
IronPython vs. CPython
• IronPython does not include all the packages that CPython does
− matplotlib
• Alternative: CPython with the Python .NET package
MIKE 1DNext generation 1D numerical engine
© DHI
MIKE1D - Vision
One engine
Supporting both Urban and River modelling
Openness
Programmatic interaction with kernel
Optimization
Speed up
One engine
• Consistency in implementation of urban and river
models
• The best of two worlds in the form of collection
systems and river modelling
Example of consistency or cross value
• Consistency :
− Identical Rainfall Runoff models
• Avoiding current differences in Urban models (MIKE 11 vs MIKE Urban)
• Cross value:
− Numerical method improvements benefits both Urban and River
• Improved AD-solution
• Improved low flow handling improves mass balance – particularly in urban
Openness
• Empowering you to customize your own solutions e.g.
structure types not currently available
• Scripts e.g. easier to work with automated tasks
Openness
• OEM-solution:
− Case: MIKE 1D engine integrated in BaSYS
• BaSYS = Pipe network Information and Asset Management system
• Partner: Barthauer Software gmbh (Germany)
• Extendability:
− Case: Probabilistic Flood Risk Modelling (Chao Phraya, Thailand)
• Automated floodplain model schematisation
• Random structure failures simulations based on probability level
associated with probabilistic curves (using MIKE 1D API)
Optimization
• Improved simulation speed
− MIKE1D utilizes parallelization techniques
− Observed reductions in run times in the range 0 - 400 %
MIKE1D
− One engine supporting both Urban and River modelling
− Common functionality
− Common documentation
− Modernization of kernel part
− Component based usage
• Consolidate the existing functionality across products
• Customize your own solution e.g. structure type
• Script using MIKE1D i.e. easier to work with automated
tasks
• Use individual objects in different settings e.g.
hydrology engine to be reused in 2D/3D modelling
MIKE 1D example
© DHI
Diagnostics diagnostics = new Diagnostics("My Diagnostics");
controller = controllerFactory.OpenAndCreate(
Connection.Create(filePath), diagnostics);
IDiagnostics validated = controller.Validate();
controller.Initialize(diagnostics);
controller.Prepare();
controller.Run();
controller.Finish();
Engines with API
© DHI
• FEFLOW: C API and .NET API
• MIKE 1D (”New” MIKE 11/MOUSE): .NET API
• MIKE SHE: .NET API, OpenMI interfaces
• MIKE 11: Through OpenMI interfaces
• MOUSE: COM and OpenMI interfaces
• MIKE 21 classic: .NET API, OpenMI interfaces
WEB componentsNext generation 1D numerical engine
© DHI
Greve – Flood Warning System
MIKE Web technology
Time-series
GIS
Spreadsheets
…
MIKE Web API
Website
Polymer/Web
Components
Configurable MIKE product Project specific implementation
User examples
• App and web based public warning system
Public information on bathing water quality
Wrap up
© DHI
Openness - Empowering tools
© DHI
Input and output Optimization and customization Web components
Thank youJohan Hartnack
© DHI
The presenter acknowledges the work of:
Jesper Gross
Thomas Clausen
Jesper Overgaard
Lars Michael
Lisbeth Petersen