modelNcDataReader

File reader for external data

Information

Overview

The model NcDataReader reads data from netCDF files (based on HDF) to Modelica. You can read attributes of type integer or double/float/Real as well as one dimensional vectors. Therefore, the NcDataReader represents an alternative for the CombiTimeTable.

You have to select the *.nc file your data is stored in and define the variable's names (varName). With the checkboxes, you can select what type of data/attributes should be read in by the model and define afterwards the names of the variables/attributes.

IMPORTANT: This model needs the external library NcDataReader2. Clone or download the repository and load the Modelica library package (netCDF-DataReader/NcDataReader2/package.mo). Alternatively, if dymosim crashes or simulation does not work, please test the EBC fork of the repository, which uses different binaries.

DDE: DDE needs to find external binaries explicitly. This means either binaries from modelica://NcDataReader2/Resources/Library have to be copied into the current working directy, or the path has to be added to a certain environment variable of operating system. In the example of NcDataReader scripts are added that can also be found in AixLib.html\Resources\Scripts\Dymola\Utilities\Examples.

Further external information

For further information please consider netCDF-DataReader GitHub repository.

Have a look directly at the documentation on how to create netCDF-files (*.nc files) and the different interpolation and extrapolation types.

More information can be found here.

Outlook

If the function NcEasyGetScattered2D works in the future, an implementation to this model should follow. It would substitute CombiTable2D. Please have a look at the documentation on how to create netCDF-files and the different interpolation types. More information on that you find here.

Example Function

AixLib.Utilities.Examples.NcDataReader

Parameters

TypeNameDefaultDescription
StringfileNameFile where external data is stored
Booleanuse_varNamefalseGet variables from fileName
Booleanuse_attNameRealfalseGet real attributes from fileName
Booleanuse_attNameIntfalseGet integer attributes from fileName
String[:]varName{""}Array name in .nc file
String[:]attNameReal{""}Name of attribute of type real in .nc file
String[:]attNameInt{""}Name of attribute of type integer in .nc file
Modelica.Units.SI.Timeoffset0Time period prior current simulation time

Connectors

TypeNameDefaultDescription
Modelica.Blocks.Interfaces.RealOutput[size(varName, 1)]yOutput Vector with all variables
Modelica.Blocks.Interfaces.RealOutput[size(attNameReal, 1)]yAttRealOutput Vector with all attributes of type double
Modelica.Blocks.Interfaces.IntegerOutput[size(attNameInt, 1)]yAttIntOutput Vector with all attributes of type integer

Revisions

  • November 12, 2018 by Philipp Mehrfeld:
    Enhance documentation for script to add binary paths to environment varialbe. Important for DDE simulations #658.
  • Feburary 6, 2017 by Philipp Mehrfeld:
    Revised documentation.
  • December 14, 2016 by Fabian Wuellhorst:
    Implemented.