-
Notifications
You must be signed in to change notification settings - Fork 34
Regarding NcDataReader
This page contains work in progress, so if we miss anything or you have a better way, please let us know.
The BuildingSystems
library includes the netCDF reader NcDataReader
from Jörg Rädler. This page does not consider the usage of this plugin, but a detail in its implementation, which in our experience comes along with some problems. These problems have been reproduced with different versions of Dymola
.
The directory \BuildingSystems\Utilities\LibrariesNcDataReader2
contains files, which are used by the NcDataReader
(11 elements). The reader itself is integrated in the BuildingSystems
library as a subpackage in BuildingSystems\Utilities\NcDataReader2
.
The package contains following files:
ncEasyGet1D
ncEasyGetAttributeDouble
ncEasyGetAttributeLong
ncEasyGetAttributeString
NcDataReader
ExampleNcDataReader
Except NcDataReader
, all files call external libraries or header files from the above mentioned directory.
There are three possible ways to call these files: using absolute or relative paths.
All of them have their advantages and disadvantages.
A short documentation for loadResources
functionality could be found here.
Corresponding source code could be found e.g.in BuildingSystems.Utilities.NcDataReader2.Example
:
fileName = Modelica.Utilities.Files.loadResource("modelica://BuildingSystems/Climate/weather/WeatherDataNetcdf/Germany_HamburgTRYnormal_weather.nc");
or e.g. in BuildingSystems.Utilities.NcDataReader2.ncEasyGet1D
as part of an annotation:
annotation (Include="#include <ncDataReaderEA.h>",IncludeDirectory=
"modelica://BuildingSystems/Utilities/LibrariesNcDataReader2/",
Library={"ncDataReader2", "netcdf"},LibraryDirectory=
"modelica://BuildingSystems/Utilities/LibrariesNcDataReader2/");
Advantage
- Independent of storage location of the
BuildingSystems
library - Independent of
Dymola
's working directory
Disadvantage
This syntax is solver-dependent!
Working solvers are: Lsodar
, Dassl
, Euler
, Rkfix2
, Rkfix3
and Rkfix4
.
Other solvers throw error messages corresponding to the NcDataReader
.
This combination of solvers is mentioned two times within the Dymola
documentation - each time in combination with Embedded Server settings. So far, we do no know if this has anything to do with the calls of IncludeDirectory
or LibraryDirectory
.
Using relative paths to include the NcDataReader
libraries and header files, the implementation of the examples from above change to
fileName = "./Climate/weather/WeatherDataNetcdf/Hamburg_meteonorm.nc";
and
annotation (Include="#include <ncDataReaderEA.h>", Library={"ncDataReader2", "netcdf"});
Advantages
- Independent of storage location of the
BuildingSystems
library - Works with all provided solvers in
Dymola
Disadvantage
Examples using this implementation will only be simulated without any error, if the working directory is set to the BuildingSystems
location.
Using absolute paths to include the NcDataReader
libraries and header files, the implementation of, the examples from above change to
fileName = "C:/Users/jmoeckel/Documents/Dymola/BuildingSystem/Climate/weather/WeatherDataNetcdf/Hamburg_meteonorm.nc";
and
annotation (Include="#include <C:/Users/jmoeckel/Documents/Dymola/BuildingSystem/Utilities/LibrariesNcDataReader2/ncDataReaderEA.h>",
Library={"C:/Users/jmoeckel/Documents/Dymola/BuildingSystem/Utilities/LibrariesNcDataReader2/ncDataReader2",
"C:/Users/jmoeckel/Documents/Dymola/BuildingSystem/Utilities/LibrariesNcDataReader2/netcdf"});
Advantages
- Independent of
Dymola
's working directory - Works with all provided solvers in
Dymola
Disadvantage
Examples using this implementation will only be simulated without any error, if the location of the BuildingSystem
library does not change (with respect to the host itsself). This is actually a great problem regarding the portability of the code.
- using the
SaveTotal
command will (of course) not the actual library files. If you want to distribute some models using theNcDataReader
, make sure to additionally include these files. - the above considerations are also true, if using
BuildingSystems.Buildings.Ambiente
. In this package a file with weatherdata could be referenced. Besides the reference, analogue to theNcDataReader
files, the corresponding weatherfile needs to be manually provided.