UdK-VPT / BuildingSystems

Modelica BuildingSystems library
http://modelica-buildingsystems.de/
BSD 3-Clause "New" or "Revised" License
70 stars 34 forks source link

NcDataReader - wrong definition of constantVariable[:] #17

Closed carlesRT closed 9 years ago

carlesRT commented 9 years ago

The current version of the block Utilities.NcDataReader2.NcDataReader sets the value of the parameters constantVariable[:] to zero. These are the different constant values of the .nc readed file, such as latitude or longitude.

@ainderfurth and I guess that the line of code = fill(0.0,size(varNameConstant,1)) was added intending to deal with those cases were the values for latitude or any oher constant needed by the WeatherDataNetcdfmodel are not defined in the .nc file.

A possible correction is:

parameter Real constantVariable[size(varNameConstant,1)](start={ncEasyGetAttributeDouble(fileName,"",varNameConstant[j]) for j in 1:size(varNameConstant, 1)}) = {ncEasyGetAttributeDouble(fileName,"",varNameConstant[j]) for j in 1:size(varNameConstant, 1)};

The problem which was intended to avoid might happen again... In case the varNameConstant[j] is not found in the .nc file an error will occur with the following message:

ERROR | -43 | netcdf  | NetCDF: Attribute not found

Up to now I did not find a way to check the file before the function is called... I think it might be enough to properly document the model, explaining what to check when this error occurs.

@nytschgeusen Do I prepare a pull request with the suggested changes? should I look depeer into it? or it is enough to document the error?


Start value ( start={ncEasyGetAttributeDouble(fi.... ) not needed