openness - dhi content/presences/emea/uk... · pfssection section1 =...

46
Openness Johan Hartnack

Upload: dangkhanh

Post on 13-Mar-2018

262 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

OpennessJohan Hartnack

Page 2: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 3: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

Software empowering you

• Utilize the models in a more free setting

• Integrate model in real time

• Disseminate results to your needs

Page 4: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

controller.Initialize(diagnostics);

controller.Prepare();

controller.Run();

controller.Finish();

Page 5: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

Empowering tools

© DHI

Input and output Optimization and customization Web components

Page 6: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

MIKE SDKSoftware Development Kit

© DHI

Page 7: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 8: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 9: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

How to get the MIKE SDK

© DHI

Page 10: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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)

Page 11: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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)

Page 12: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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.

Page 13: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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.

Page 14: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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;

Page 15: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 16: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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));

Page 17: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 18: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 19: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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);

Page 20: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 21: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 22: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 23: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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();

Page 24: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 25: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 26: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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.*;

Page 27: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 28: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

MIKE 1DNext generation 1D numerical engine

© DHI

Page 29: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

MIKE1D - Vision

One engine

Supporting both Urban and River modelling

Openness

Programmatic interaction with kernel

Optimization

Speed up

Page 30: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

One engine

• Consistency in implementation of urban and river

models

• The best of two worlds in the form of collection

systems and river modelling

Page 31: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 32: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

Openness

• Empowering you to customize your own solutions e.g.

structure types not currently available

• Scripts e.g. easier to work with automated tasks

Page 33: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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)

Page 34: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

Optimization

• Improved simulation speed

− MIKE1D utilizes parallelization techniques

− Observed reductions in run times in the range 0 - 400 %

Page 35: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

MIKE1D

− One engine supporting both Urban and River modelling

− Common functionality

− Common documentation

− Modernization of kernel part

− Component based usage

Page 36: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

• 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

Page 37: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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();

Page 38: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

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

Page 39: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

WEB componentsNext generation 1D numerical engine

© DHI

Page 40: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

Greve – Flood Warning System

MIKE Web technology

Time-series

GIS

Spreadsheets

MIKE Web API

Website

Polymer/Web

Components

Configurable MIKE product Project specific implementation

Page 41: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

User examples

Page 42: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

• App and web based public warning system

Public information on bathing water quality

Page 43: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

Wrap up

© DHI

Page 44: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

Openness - Empowering tools

© DHI

Input and output Optimization and customization Web components

Page 45: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

We are with you all the way

• Support

Contact: [email protected]

Page 46: Openness - DHI content/presences/emea/uk... · PFSSection section1 = target.GetSection("Results", 1); ... (Simulink) • Commercial –expensive! 3.3 3.4 ... C API and .NET API

Thank youJohan Hartnack

© DHI

The presenter acknowledges the work of:

Jesper Gross

Thomas Clausen

Jesper Overgaard

Lars Michael

Lisbeth Petersen