realizationDimensionList = new ArrayList<>();
realizationDimensionList.add(realizationDimension);
- Variable myVar = netcdfFileWriter.addVariable(null, REALIZATION_VARIABLE_NAME, DataType.INT, realizationDimensionList);
- netcdfFileWriter.addVariableAttribute(myVar, new Attribute(STANDARD_NAME_ATTRIBUTE_NAME, REALIZATION_VARIABLE_NAME));
- netcdfFileWriter.addVariableAttribute(myVar, new Attribute(LONG_NAME_ATTRIBUTE_NAME, "Index of an ensemble member within an ensemble"));
- netcdfFileWriter.addVariableAttribute(myVar, new Attribute(UNITS_ATTRIBUTE_NAME, "1"));
+ Variable.Builder myVar = NetcdfWriterBuilder.addVariable(REALIZATION_VARIABLE_NAME, DataType.INT, realizationDimensionList);
+ myVar.addAttribute(new Attribute(STANDARD_NAME_ATTRIBUTE_NAME, REALIZATION_VARIABLE_NAME));
+ myVar.addAttribute(new Attribute(LONG_NAME_ATTRIBUTE_NAME, "Index of an ensemble member within an ensemble"));
+ myVar.addAttribute(new Attribute(UNITS_ATTRIBUTE_NAME, "1"));
return realizationDimension;
}
- public static void addGeneralGlobalAttributes(NetcdfFileWriter netcdfFileWriter) {
- netcdfFileWriter.addGroupAttribute(null, new Attribute("institution", "OpenDA Association"));
- netcdfFileWriter.addGroupAttribute(null, new Attribute("source", "Written by OpenDA"));
- netcdfFileWriter.addGroupAttribute(null, new Attribute("history", "Created at " + new Date(System.currentTimeMillis())));
- netcdfFileWriter.addGroupAttribute(null, new Attribute("references", "http://www.openda.org"));
- netcdfFileWriter.addGroupAttribute(null,new Attribute("Conventions", "CF-1.6"));
+ public static void addGeneralGlobalAttributes(NetcdfFormatWriter.Builder NetcdfWriterBuilder) {
+ NetcdfWriterBuilder.addAttribute(new Attribute("institution", "OpenDA Association"));
+ NetcdfWriterBuilder.addAttribute(new Attribute("source", "Written by OpenDA"));
+ NetcdfWriterBuilder.addAttribute(new Attribute("history", "Created at " + new Date(System.currentTimeMillis())));
+ NetcdfWriterBuilder.addAttribute(new Attribute("references", "https://www.openda.org"));
+ NetcdfWriterBuilder.addAttribute(new Attribute("Conventions", "CF-1.6"));
+ }
+
+ public static class MyCancelTask implements CancelTask {
+
+ @Override
+ public boolean isCancel(){
+ return false;
+ }
+
+ @Override
+ public boolean isDone() {
+ return false;
+ }
+
+ @Override
+ public void setDone(boolean b) {
+ // empty method
+ }
+
+ @Override
+ public void setSuccess() {
+ CancelTask.super.setSuccess();
+ }
+
+ @Override
+ public void setError(String s) {
+ // empty method
+ }
+
+ @Override
+ public void setProgress(String s, int i) {
+ // empty method
+ }
}
}
diff --git a/core/java/src/org/openda/exchange/iotools/DataCopier.java b/core/java/src/org/openda/exchange/iotools/DataCopier.java
index 50d938ef8..f2dd058d1 100644
--- a/core/java/src/org/openda/exchange/iotools/DataCopier.java
+++ b/core/java/src/org/openda/exchange/iotools/DataCopier.java
@@ -228,33 +228,6 @@ private static void copyValuesForNamedEnsembleItem(IExchangeItem inputExchangeIt
outputExchangeItem.copyValuesFromItem(inputExchangeItem);
}
-// /**
-// * Copies the values from the exchangeItems with the given inputExchangeItemIds from the input IDataObject
-// * to the exchangeItems with the given outputExchangeItemIds in the output IDataObject.
-// */
-// private void copyValuesForNamedItems(String[] inputExchangeItemIds, String[] outputExchangeItemIds) {
-// if (inputExchangeItemIds.length != outputExchangeItemIds.length) {
-// throw new RuntimeException(getClass().getSimpleName() + ": inputExchangeItemIds length (" +
-// inputExchangeItemIds.length + ") and outputExchangeItemIds length (" +
-// outputExchangeItemIds.length + ") should be the same.");
-// }
-//
-// //copy exchangeItems.
-// for (int n = 0; n < inputExchangeItemIds.length; n++) {
-// copyValuesForNamedItem(inputExchangeItemIds[n], outputExchangeItemIds[n]);
-// }
-// }
-//
-// /**
-// * Copy the values for the exchangeItems with the given ids from input to output IDataObject.
-// */
-// private void copyValuesForNamedItems(String[] exchangeItemIds) {
-// //copy exchangeItems.
-// for (String exchangeItemId : exchangeItemIds) {
-// copyValuesForNamedItem(exchangeItemId, exchangeItemId);
-// }
-// }
-
/**
* Copies all exchangeItems from the input dataObject to the output dataObject.
*/
@@ -322,11 +295,11 @@ public void finish() {
/**
* Help text for the command line
- * @return
+ * @return text string
*/
private static String getUsageMessage() {
- StringBuffer message = new StringBuffer();
- if (BBUtils.RUNNING_ON_LINUX) {
+ StringBuilder message = new StringBuilder();
+ if (BBUtils.RUNNING_ON_LINUX) {
message.append("NAME\n"
+ "\t oda_copy.sh - a tool for copying data between OpenDA data-objects\n");
} else {
@@ -354,7 +327,7 @@ private static String getUsageMessage() {
/**
* Gathers the following variables from the given arguments.
- *
+ *
* inputFilePath: full pathname of input file.
* inputClassName: fully qualified class name of input IDataObject to use to read data from the input file.
* inputArguments: optional one or more arguments that are passed to the input IDataObject initialize method.
@@ -372,7 +345,7 @@ private void processArguments(String[] arguments) {
inputClassName=null;
inputArgs=new String[0];
while(nextArg.startsWith("-")){
- String argValue=null;
+ String argValue;
if((argIndex+1)
* Depending on the nature of the input/output exchangeItems, different value(s) are copied.
* If e.g an outputExchangeItem can only store value(s) for a single time and the corresponding inputExchangeItem stores
* values for an entire time series, then when this method is called the outputExchangeItem only copies the value(s) for the
diff --git a/core/java/src/org/openda/resultwriters/NetcdfResultWriterPureJava.java b/core/java/src/org/openda/resultwriters/NetcdfResultWriterPureJava.java
index 4844affa2..2df1b912f 100644
--- a/core/java/src/org/openda/resultwriters/NetcdfResultWriterPureJava.java
+++ b/core/java/src/org/openda/resultwriters/NetcdfResultWriterPureJava.java
@@ -12,18 +12,14 @@
import java.util.Map;
/**
- * Created by nils on 13/11/15.
+ * @author nils on 13/11/15.
*/
public class NetcdfResultWriterPureJava implements IResultWriter {
- private int defaultMaxSize = Integer.MAX_VALUE;
- private String netcdfnameprefix;
- private Map netcdfFiles = new HashMap();
- private Map notSupportedObjects = new HashMap();
- private Map timeIndex = new HashMap();
-
-
- private File workingDir;
+ private final String netcdfnameprefix;
+ private final Map netcdfFiles = new HashMap<>();
+ private final Map notSupportedObjects = new HashMap<>();
+ private final Map timeIndex = new HashMap<>();
public NetcdfResultWriterPureJava(File workingDir, String configString) {
@@ -36,12 +32,11 @@ public NetcdfResultWriterPureJava(File workingDir, String configString) {
throw new RuntimeException(error);
}
}
- else{
+ else {
workingDir.mkdir();
}
- this.workingDir = workingDir;
- //Check the config string
+ //Check the config string
if (configString.startsWith("...
*
* @author Arno Kockx
*/
public class GridExchangeItemNetcdfWriter {
private final IExchangeItem[] exchangeItems;
- private final NetcdfFileWriter netcdfFileWriter;
+ private final NetcdfFormatWriter NetcdfWriter;
private final Variable timeVariable;
private int currentTimeIndex = -1;
@@ -60,17 +60,10 @@ public GridExchangeItemNetcdfWriter(IExchangeItem[] exchangeItems, File outputFi
this.exchangeItems = exchangeItems;
//create netcdf file.
- try {
- netcdfFileWriter = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, outputFile.getAbsolutePath());
- } catch (IOException e) {
- throw new RuntimeException(getClass().getSimpleName() + ": Error while opening netcdf file " + outputFile.getAbsolutePath() + " Message was: " + e.getMessage(), e);
- }
- //always create large file, in case much data needs to be written.
- netcdfFileWriter.setLargeFile(true);
+ NetcdfFormatWriter.Builder netcdfBuilder = NetcdfFormatWriter.createNewNetcdf3(outputFile.getAbsolutePath());
//create time dimension and variable.
- Dimension timeDimension = NetcdfUtils.createTimeVariable(netcdfFileWriter, NetcdfUtils.TIME_VARIABLE_NAME, -1, NetcdfUtils.createTimeUnitString());
- timeVariable = netcdfFileWriter.findVariable(NetcdfUtils.TIME_VARIABLE_NAME);
+ Dimension timeDimension = NetcdfUtils.createTimeVariable(netcdfBuilder, NetcdfUtils.TIME_VARIABLE_NAME, -1, NetcdfUtils.createTimeUnitString());
//create grid dimensions and variables.
//gather geometryInfos.
@@ -85,25 +78,25 @@ public GridExchangeItemNetcdfWriter(IExchangeItem[] exchangeItems, File outputFi
//create spatial coordinate variables, if not present yet.
//this only adds spatial dimensions, this does not add spatial variables with coordinates,
//because the coordinates are usually not available in exchangeItems that come from models.
- Map geometryInfoGridVariablePropertiesMap = NetcdfUtils.createGridVariables(netcdfFileWriter, geometryInfos.toArray(new IGeometryInfo[geometryInfos.size()]));
+ Map geometryInfoGridVariablePropertiesMap = NetcdfUtils.createGridVariables(netcdfBuilder, geometryInfos.toArray(new IGeometryInfo[geometryInfos.size()]));
//create data variables.
- NetcdfUtils.createDataVariables(netcdfFileWriter, Arrays.asList(exchangeItems), timeDimension, null, null, geometryInfoGridVariablePropertiesMap);
+ NetcdfUtils.createDataVariables(netcdfBuilder, Arrays.asList(exchangeItems), timeDimension, null, null, geometryInfoGridVariablePropertiesMap);
//add global metadata.
- NetcdfUtils.addGlobalAttributes(netcdfFileWriter);
+ NetcdfUtils.addGlobalAttributes(netcdfBuilder);
try {
- netcdfFileWriter.create();
+ NetcdfWriter = netcdfBuilder.build();
} catch (Exception e) {
- throw new RuntimeException(getClass().getSimpleName() + ": Error while creating netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + " Message was: " + e.getMessage(), e);
+ throw new RuntimeException(getClass().getSimpleName() + ": Error while creating netcdf file " + outputFile.getAbsolutePath() + " Message was: " + e.getMessage(), e);
}
-
+ timeVariable = NetcdfWriter.findVariable(NetcdfUtils.TIME_VARIABLE_NAME);
//write grid variables values.
try {
- NetcdfUtils.writeGridVariablesValues(netcdfFileWriter, geometryInfoGridVariablePropertiesMap);
+ NetcdfUtils.writeGridVariablesValues(NetcdfWriter, geometryInfoGridVariablePropertiesMap);
} catch (Exception e) {
- throw new RuntimeException(getClass().getSimpleName() + ": Error while writing grid variable values to netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + " Message was: " + e.getMessage(), e);
+ throw new RuntimeException(getClass().getSimpleName() + ": Error while writing grid variable values to netcdf file " + NetcdfWriter.getOutputFile().getLocation() + " Message was: " + e.getMessage(), e);
}
}
@@ -134,21 +127,21 @@ private void writeTime() {
} else {
if (time != currentTime) {
throw new RuntimeException(getClass().getSimpleName() + ": Cannot write data. Exchange items have different times for time index " + currentTimeIndex
- + " in netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation());
+ + " in netcdf file " + NetcdfWriter.getOutputFile().getLocation());
}
}
}
//write current time.
if (timesWrittenSoFar.contains(currentTime)) {
- throw new RuntimeException(getClass().getSimpleName() + ": Cannot write data. Output netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation()
+ throw new RuntimeException(getClass().getSimpleName() + ": Cannot write data. Output netcdf file " + NetcdfWriter.getOutputFile().getLocation()
+ " already contains data for current time " + new Date(Time.mjdToMillies(currentTime)));
}
try {
- NetcdfUtils.writeTimeVariableSingleValue(netcdfFileWriter, timeVariable, currentTimeIndex, currentTime);
+ NetcdfUtils.writeTimeVariableSingleValue(NetcdfWriter, timeVariable, currentTimeIndex, currentTime);
} catch (Exception e) {
throw new RuntimeException(getClass().getSimpleName() + ": Error while writing time value for current time " + new Date(Time.mjdToMillies(currentTime))
- + " to netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + " Message was: " + e.getMessage(), e);
+ + " to netcdf file " + NetcdfWriter.getOutputFile().getLocation() + " Message was: " + e.getMessage(), e);
}
timesWrittenSoFar.add(currentTime);
}
@@ -212,16 +205,16 @@ private void writeData() {
//write values for current time.
origin[0] = currentTimeIndex;
- Variable dataVariable = NetcdfUtils.getVariableForExchangeItem(netcdfFileWriter.getNetcdfFile(), item);
- NetcdfUtils.writeSelectedData(netcdfFileWriter, dataVariable, origin, dimensions, values);
+ Variable dataVariable = NetcdfUtils.getVariableForExchangeItem(NetcdfWriter.getOutputFile(), item);
+ NetcdfUtils.writeSelectedData(NetcdfWriter, dataVariable, origin, dimensions, values);
}
}
public void close() {
try {
- netcdfFileWriter.close();
+ NetcdfWriter.close();
} catch (IOException e) {
- throw new RuntimeException("Error while closing netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + " Message was: " + e.getMessage(), e);
+ throw new RuntimeException("Error while closing netcdf file " + NetcdfWriter.getOutputFile().getLocation() + " Message was: " + e.getMessage(), e);
}
}
}
diff --git a/core/java/src/org/openda/utils/io/KalmanGainStorage.java b/core/java/src/org/openda/utils/io/KalmanGainStorage.java
index ae2f64bbe..8ad3dde55 100644
--- a/core/java/src/org/openda/utils/io/KalmanGainStorage.java
+++ b/core/java/src/org/openda/utils/io/KalmanGainStorage.java
@@ -34,8 +34,13 @@
import org.openda.utils.*;
import ucar.ma2.Array;
import ucar.ma2.*;
-import ucar.nc2.*;
+import ucar.nc2.Attribute;
+import ucar.nc2.Dimension;
+import ucar.nc2.Variable;
import ucar.nc2.dataset.NetcdfDataset;
+import ucar.nc2.dataset.NetcdfDatasets;
+import ucar.nc2.write.NetcdfFormatWriter;
+import ucar.nc2.write.NetcdfFormatWriter.*;
import java.io.*;
import java.util.*;
@@ -64,11 +69,10 @@ public class KalmanGainStorage {
// set in constructor
private File workingDir;
- private double timeStampAsMJD = Double.MIN_VALUE;;
+ private double timeStampAsMJD = Double.MIN_VALUE;
// properties that be can be overridden before writing
private String storageDirPrefix = "kgStorage_";
- private String columnFilePrefix = "obsColumn_";
private String kalmanGainStorageFileName = "kalmanGainStorage.xml";
private int maxKeepVectorInXMLSize = DefaultMaxKeepVectorInXMLSize;
private boolean useTimeStampInDirectoryName = true;
@@ -103,21 +107,6 @@ public KalmanGainStorage(File workingDir, double timeStampAsMJD) {
this.timeStampAsMJD = timeStampAsMJD;
}
- /**
- * Constructor for creating and writing kalman gain storage object, used to read or to write the kalman gain.
- * The kalman gain is stored in a separate directory, with a separate file for each kalman gain column
- * in the kalman gain matrix.
- *
- * @param workingDir The directory under which the directory for the kalman gain for the
- * specified time stamp must be created
- * @param timeStampAsMJD The time stamp for which the kalman gain is valid
- */
- public KalmanGainStorage(File workingDir, double timeStampAsMJD, boolean useTimeStampInDirectoryName) {
- this.workingDir = workingDir;
- this.timeStampAsMJD = timeStampAsMJD;
- this.useTimeStampInDirectoryName = false;
- }
-
/**
* Constructor for reading kalman gain storage object, used to read the kalman gain.
* The kalman gain is stored with a separate file for each kalman gain column
@@ -138,17 +127,9 @@ public void setStorageDirPrefix(String storageDirPrefix) {
this.storageDirPrefix = storageDirPrefix;
}
- /**
- * Set the prefix to be used for the directory name for storing the kalman gain column files.
- * @param columnFilePrefix The file prefix for.
- */
- public void setColumnFilePrefix(String columnFilePrefix) {
- this.columnFilePrefix = columnFilePrefix;
- }
-
/**
* Set the file type for storage of Kalman gain vectors
- * @param fileType
+ * @param fileType eg netcdf, xml or automatic
*/
public void setColumnFileType(StorageType fileType){
this.gainFileType = fileType;
@@ -188,9 +169,9 @@ public void setComment(String comment) {
}
/**
- * Write the kalman gain matrix to xml file and, in case of large column vectors, to netdcf files.
- * A HashMap is used with Id's for each column. This helps to find the right column matching an observation
- * @param gainVectors each vector corresponds to a column of the the Kalman gain and matches an observation
+ * Write the kalman gain matrix to XML file and, in case of large column vectors, to NetCDF files.
+ * A HashMap is used with Ids for each column. This helps to find the right column matching an observation
+ * @param gainVectors each vector corresponds to a column of the Kalman gain and matches an observation
* @param obsId combination of location and quantity to map observations to the right column
* @param obsTimeOffset For observations at a time preceding the analysis time this gives the offset in days.
*/
@@ -214,7 +195,7 @@ public void writeKalmanGain(HashMap gainVectors,
}
/**
- * Write the kalman gain matrix to xml file and, in case of large column vectors, to netdcf files.
+ * Write the kalman gain matrix to XML file and, in case of large column vectors, to NetCDF files.
*
* @param observationIds The observation identifiers
* @param observationOffsetsInDays The time offset of the observations, expressed in days,
@@ -222,7 +203,7 @@ public void writeKalmanGain(HashMap gainVectors,
* (0 means: same time stamp as the gain,
* negative means before the kalman gain time stamp)
* @param kalmanGainColumns The vectors to be written to the kalman gain column files.
- * @param hk
+ * @param hk ...
*/
public void writeKalmanGain(String[] observationIds, double[] observationOffsetsInDays, IVector[] kalmanGainColumns, double[][] hk) {
if (kalmanGainColumns == null || kalmanGainColumns.length == 0 ) {
@@ -291,6 +272,7 @@ private void fillObservationsXML(String[] observationIds, double[] observationOf
continue;
}
// netCdf-file
+ String columnFilePrefix = "obsColumn_";
String netcdfFileName = columnFilePrefix + String.valueOf(i + 1) + ".nc";
observationXMLChoice.setFileName(netcdfFileName);
if (!kgStorageXML.hasStateSize()) {
@@ -302,32 +284,30 @@ private void fillObservationsXML(String[] observationIds, double[] observationOf
}
private void writeKalmanGainToNetcdfCF(String[] observationIds, double[] observationOffsetsInDays, IVector[] kalmanGainColumns, File directoryForStorage, double[][] hk) {
- NetcdfFileWriter netcdfFileWriter = null;
+ NetcdfFormatWriter netcdfFormatWriter = null;
try {
File file = new File(directoryForStorage, kalmanGainStorageFileName);
- netcdfFileWriter = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, file.getAbsolutePath());
- netcdfFileWriter.setLargeFile(true);
- addGlobalAttributes(netcdfFileWriter);
- Variable timeStampVariable = createTimeStampVariable(netcdfFileWriter);
- Dimension stationDimension = netcdfFileWriter.addDimension(null, STATION_DIMENSION, observationIds.length);
- netcdfFileWriter.addDimension(null, CHAR_LENGTH_ID, STATION_ID_CHAR_LENGTH);
- Variable observationOffsetVariable = createObservationOffsetVariable(netcdfFileWriter);
- Variable hkVariable = hk != null ? createHKVariable(netcdfFileWriter) : null;
- Variable stationVariable = createStationVariable(netcdfFileWriter);
-
- KalmanGainVariableData[] kalmanGainVariableData = getKalmanGainVariableData(kalmanGainColumns, netcdfFileWriter, stationDimension);
- netcdfFileWriter.create();
-
- writeStationData(observationIds, netcdfFileWriter, stationVariable);
- writeTimeStampData(netcdfFileWriter, timeStampVariable);
- writeObservationOffsetData(observationOffsetsInDays, netcdfFileWriter, observationOffsetVariable);
- if (hkVariable != null) writeHK(hk, netcdfFileWriter, hkVariable);
-
+ NetcdfFormatWriter.Builder netcdfBuilder = NetcdfFormatWriter.createNewNetcdf3(file.getAbsolutePath());
+ addGlobalAttributes(netcdfBuilder);
+ createTimeStampVariable(netcdfBuilder);
+ Dimension stationDimension = netcdfBuilder.addDimension(STATION_DIMENSION, observationIds.length);
+ netcdfBuilder.addDimension(CHAR_LENGTH_ID, STATION_ID_CHAR_LENGTH);
+ createObservationOffsetVariable(netcdfBuilder);
+ createStationVariable(netcdfBuilder);
+ boolean hkVariable = hk != null ? createHKVariable(netcdfBuilder) : false;
+
+ KalmanGainVariableData[] kalmanGainVariableData = getKalmanGainVariableData(kalmanGainColumns, netcdfBuilder, stationDimension);
+ netcdfFormatWriter = netcdfBuilder.build();
+
+ writeStationData(observationIds, netcdfFormatWriter);
+ writeTimeStampData(netcdfFormatWriter);
+ writeObservationOffsetData(observationOffsetsInDays, netcdfFormatWriter);
+ if (hkVariable) writeHK(hk, netcdfFormatWriter);
for (int observationIndex = 0; observationIndex < kalmanGainColumns.length; observationIndex++) {
ITreeVector kalmanGainColumnForObservation = (ITreeVector) kalmanGainColumns[observationIndex];
for (KalmanGainVariableData kalmanGainVariableDatum : kalmanGainVariableData) {
- Variable variable = kalmanGainVariableDatum.getVariable();
+ String variableId = kalmanGainVariableDatum.getVariableId();
ITreeVector dataVector = getDataVector(kalmanGainColumnForObservation, kalmanGainVariableDatum);
ArrayList dimensions = kalmanGainVariableDatum.getDimensions();
Array values = null;
@@ -339,7 +319,7 @@ private void writeKalmanGainToNetcdfCF(String[] observationIds, double[] observa
int[] origin = new int[dimensions.size() + 1];
origin[0] = observationIndex;
try {
- netcdfFileWriter.write(variable, origin, values);
+ netcdfFormatWriter.write(variableId, origin, values);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
@@ -349,7 +329,7 @@ private void writeKalmanGainToNetcdfCF(String[] observationIds, double[] observa
throw new RuntimeException(e.getMessage(), e);
} finally {
try {
- if (netcdfFileWriter != null) netcdfFileWriter.close();
+ if (netcdfFormatWriter != null) netcdfFormatWriter.close();
} catch (IOException e) {
Results.putMessage("Unable to close netcdf cf file due to " + e.getMessage());
}
@@ -376,40 +356,40 @@ private Array getData1D(ITreeVector dataVector, ArrayList dimensions)
return arrayDoubleD2;
}
- private void writeObservationOffsetData(double[] observationOffsetsInDays, NetcdfFileWriter netcdfFileWriter, Variable observationOffsetVariable) throws IOException, InvalidRangeException {
+ private void writeObservationOffsetData(double[] observationOffsetsInDays, NetcdfFormatWriter netcdfFormatWriter) throws IOException, InvalidRangeException {
ArrayDouble.D1 observationOffsetArray = new ArrayDouble.D1(observationOffsetsInDays.length);
for (int i = 0; i < observationOffsetsInDays.length; i++) {
observationOffsetArray.set(i, observationOffsetsInDays[i]);
}
- netcdfFileWriter.write(observationOffsetVariable, observationOffsetArray);
+ netcdfFormatWriter.write(OBSERVATION_OFFSET, observationOffsetArray);
}
- private void writeHK(double[][] hk, NetcdfFileWriter netcdfFileWriter, Variable hkVariable) throws IOException, InvalidRangeException {
+ private void writeHK(double[][] hk, NetcdfFormatWriter netcdfFormatWriter) throws IOException, InvalidRangeException {
ArrayDouble.D2 hkArray = new ArrayDouble.D2(hk.length, hk.length);
for (int i = 0; i < hk.length; i++) {
for (int j = 0; j < hk.length; j++) {
hkArray.set(i, j, hk[i][j]);
}
}
- netcdfFileWriter.write(hkVariable, hkArray);
+ netcdfFormatWriter.write("HK", hkArray);
}
- private void writeStationData(String[] observationIds, NetcdfFileWriter netcdfFileWriter, Variable stationVariable) throws IOException, InvalidRangeException {
+ private void writeStationData(String[] observationIds, NetcdfFormatWriter netcdfFormatWriter) throws IOException, InvalidRangeException {
ArrayChar.D2 stationArray = new ArrayChar.D2(observationIds.length, STATION_ID_CHAR_LENGTH);
for (int i = 0; i < observationIds.length; i++) {
String observationId = observationIds[i];
stationArray.setString(i, observationId);
}
- netcdfFileWriter.write(stationVariable, stationArray);
+ netcdfFormatWriter.write(STATION_ID, stationArray);
}
- private void writeTimeStampData(NetcdfFileWriter netcdfFileWriter, Variable timeStampVariable) throws IOException, InvalidRangeException {
+ private void writeTimeStampData(NetcdfFormatWriter netcdfFormatWriter) throws IOException, InvalidRangeException {
ArrayDouble.D1 timeStampArray = new ArrayDouble.D1(1);
timeStampArray.setDouble(0, timeStampAsMJD);
- netcdfFileWriter.write(timeStampVariable, timeStampArray);
+ netcdfFormatWriter.write(TIME_STAMP, timeStampArray);
}
- private KalmanGainVariableData[] getKalmanGainVariableData(IVector[] kalmanGainColumns, NetcdfFileWriter netcdfFileWriter, Dimension stationDimension) {
+ private KalmanGainVariableData[] getKalmanGainVariableData(IVector[] kalmanGainColumns, NetcdfFormatWriter.Builder netcdfFormatWriter, Dimension stationDimension) {
TreeVector kalmanGainColumn = (TreeVector) kalmanGainColumns[0];
ArrayList subTreeVectorIds = kalmanGainColumn.getSubTreeVectorIds();
KalmanGainVariableData[] kalmanGainVariableData = new KalmanGainVariableData[subTreeVectorIds.size()];
@@ -451,19 +431,19 @@ private KalmanGainVariableData[] getKalmanGainVariableData(IVector[] kalmanGainC
}
}
assert shape != null;
- kalmanGainVariableData[subTreeIndex] = createKalmanGainVariableData(netcdfFileWriter, stationDimension, vectorIds, variableId, shape, dataVector);
+ kalmanGainVariableData[subTreeIndex] = createKalmanGainVariableData(netcdfFormatWriter, stationDimension, vectorIds, variableId, shape, dataVector);
}
return kalmanGainVariableData;
}
- private KalmanGainVariableData createKalmanGainVariableData(NetcdfFileWriter netcdfFileWriter, Dimension stationDimension, ArrayList vectorIds, String variableId, int[] shape, ITreeVector dataVector) {
+ private KalmanGainVariableData createKalmanGainVariableData(NetcdfFormatWriter.Builder netcdfFormatWriter, Dimension stationDimension, ArrayList vectorIds, String variableId, int[] shape, ITreeVector dataVector) {
ArrayList dimensions = new ArrayList<>();
dimensions.add(stationDimension);
for (int i = 0; i < shape.length; i++) {
- Dimension dim = netcdfFileWriter.addDimension(null, variableId + "_dimension_" + i, shape[i]);
+ Dimension dim = netcdfFormatWriter.addDimension(variableId + "_dimension_" + i, shape[i]);
dimensions.add(dim);
}
- Variable variable = netcdfFileWriter.addVariable(null, variableId, DataType.DOUBLE, dimensions);
+ Variable.Builder variable = netcdfFormatWriter.addVariable(variableId, DataType.DOUBLE, dimensions);
if (vectorIds.size() > 1) {
String parentVectorId = vectorIds.get(0);
variable.addAttribute(new Attribute(PARENT_VECTOR_ID, parentVectorId));
@@ -473,44 +453,41 @@ private KalmanGainVariableData createKalmanGainVariableData(NetcdfFileWriter net
// Remove station dimension again because stations data are written one by one
Dimension removed = dimensions.remove(0);
assert removed.getShortName().equals(STATION_DIMENSION);
- return new KalmanGainVariableData(variableId, dimensions, variable, dataVector, vectorIds);
+ return new KalmanGainVariableData(variableId, dimensions, dataVector, vectorIds);
}
- private Variable createStationVariable(NetcdfFileWriter netcdfFileWriter) {
- Variable stationVariable = netcdfFileWriter.addVariable(null, STATION_ID, DataType.CHAR, STATION_DIMENSION + ' ' + CHAR_LENGTH_ID);
+ private void createStationVariable(NetcdfFormatWriter.Builder netcdfFormatWriter) {
+ Variable.Builder stationVariable = netcdfFormatWriter.addVariable(STATION_ID, DataType.CHAR, STATION_DIMENSION + ' ' + CHAR_LENGTH_ID);
stationVariable.addAttribute(STATION_IDENTIFICATION_CODE_ATT);
stationVariable.addAttribute(TIME_SERIES_ID_ATT);
- return stationVariable;
}
- private Variable createObservationOffsetVariable(NetcdfFileWriter netcdfFileWriter) {
- Variable observationOffsetVariable = netcdfFileWriter.addVariable(null, OBSERVATION_OFFSET, DataType.DOUBLE, STATION_DIMENSION);
+ private void createObservationOffsetVariable(NetcdfFormatWriter.Builder netcdfFormatWriter) {
+ Variable.Builder observationOffsetVariable = netcdfFormatWriter.addVariable(OBSERVATION_OFFSET, DataType.DOUBLE, STATION_DIMENSION);
observationOffsetVariable.addAttribute(OBSERVATION_OFFSET_LONG_NAME_ATT);
observationOffsetVariable.addAttribute(TIME_STAMP_UNIT_ATT);
- return observationOffsetVariable;
}
- private Variable createHKVariable(NetcdfFileWriter netcdfFileWriter) {
- Variable observationOffsetVariable = netcdfFileWriter.addVariable(null, "HK", DataType.DOUBLE, STATION_DIMENSION + ' ' + STATION_DIMENSION);
+ private boolean createHKVariable(NetcdfFormatWriter.Builder netcdfFormatWriter) {
+ Variable.Builder observationOffsetVariable = netcdfFormatWriter.addVariable("HK", DataType.DOUBLE, STATION_DIMENSION + ' ' + STATION_DIMENSION);
observationOffsetVariable.addAttribute(HK_LONG_NAME_ATT);
observationOffsetVariable.addAttribute(FRACTIONS_UNIT_ATT);
- return observationOffsetVariable;
+ return true;
}
- private Variable createTimeStampVariable(NetcdfFileWriter netcdfFileWriter) {
- Dimension timeStampDimension = netcdfFileWriter.addDimension(null, "time_stamp_dimension", 1);
+ private void createTimeStampVariable(Builder netcdfFormatWriter) {
+ Dimension timeStampDimension = netcdfFormatWriter.addDimension("time_stamp_dimension", 1);
ArrayList dimensionList = new ArrayList<>();
dimensionList.add(timeStampDimension);
- Variable timeStampVariable = netcdfFileWriter.addVariable(null, TIME_STAMP, DataType.DOUBLE, dimensionList);
+ Variable.Builder timeStampVariable = netcdfFormatWriter.addVariable(TIME_STAMP, DataType.DOUBLE, dimensionList);
timeStampVariable.addAttribute(TIME_STAMP_LONG_NAME_ATT);
timeStampVariable.addAttribute(TIME_STAMP_UNIT_ATT);
- return timeStampVariable;
}
- private void addGlobalAttributes(NetcdfFileWriter netcdfFileWriter) {
- netcdfFileWriter.addGroupAttribute(null, new Attribute("title", "Kalman gain data"));
- NetcdfUtils.addGeneralGlobalAttributes(netcdfFileWriter);
- if (comment != null && !comment.isEmpty()) netcdfFileWriter.addGroupAttribute(null, new Attribute("Comment", comment));
+ private void addGlobalAttributes(NetcdfFormatWriter.Builder netcdfBuilder) {
+ netcdfBuilder.addAttribute(new Attribute("title", "Kalman gain data"));
+ NetcdfUtils.addGeneralGlobalAttributes(netcdfBuilder);
+ if (comment != null && !comment.isEmpty()) netcdfBuilder.addAttribute(new Attribute("Comment", comment));
}
private ITreeVector getDataVector(ITreeVector kalmanGainColumnForObservation, KalmanGainVariableData kalmanGainVariableDatum) {
@@ -554,9 +531,6 @@ public double[] getObservationOffsetInDays() {
}
public IVector[] getKalmanGainColumns() {
- if (this.kalmanGainColumns == null) {
- // the values were not in the file
- }
return this.kalmanGainColumns;
}
@@ -631,12 +605,13 @@ public void readKalmanGain(IVector templateTreeVector) {
}
private void readKalmanGainFromNetcdfCF(File directoryForStorage) {
- NetcdfFile netcdfFile;
+ NetcdfDataset netcdfFile;
try {
File file = new File(directoryForStorage, kalmanGainStorageFileName);
- netcdfFile = NetcdfDataset.openDataset(file.getAbsolutePath());
+ netcdfFile = NetcdfDatasets.openDataset(file.getAbsolutePath());
List variables = netcdfFile.getVariables();
Variable stationVariable = netcdfFile.findVariable(STATION_ID);
+ assert stationVariable != null;
int stationLength = stationVariable.getShape(0);
TreeVector[] kalmanGainColumns = new TreeVector[stationLength];
for (int i = 0; i < stationLength; i++) {
@@ -644,6 +619,7 @@ private void readKalmanGainFromNetcdfCF(File directoryForStorage) {
}
readVariables(variables, stationLength, kalmanGainColumns);
this.kalmanGainColumns = kalmanGainColumns;
+ netcdfFile.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -658,11 +634,11 @@ private void readVariables(List variables, int stationLength, TreeVect
continue;
}
if (OBSERVATION_OFFSET.equals(shortName)) {
- this.observationOffsetInDays = (double[]) variable.read().get1DJavaArray(double.class);
+ this.observationOffsetInDays = (double[]) variable.read().get1DJavaArray(DataType.DOUBLE);
continue;
}
if (TIME_STAMP.equals(shortName)) {
- this.timeStampAsMJD = ((double[]) variable.read().get1DJavaArray(double.class))[0];
+ this.timeStampAsMJD = ((double[]) variable.read().get1DJavaArray(DataType.DOUBLE))[0];
continue;
}
if ("HK".equals(shortName)) {
@@ -688,7 +664,7 @@ private void readVariables(List variables, int stationLength, TreeVect
}
private String[] read1DimensionalStringArray(Variable variable) throws IOException {
- Object[] array = (Object[]) variable.read().get1DJavaArray(String.class);
+ Object[] array = (Object[]) variable.read().get1DJavaArray(DataType.STRING);
String[] strings = new String[array.length];
for (int i = 0; i < array.length; i++) {
strings[i] = (String) array[i];
@@ -720,7 +696,7 @@ static String[] read2DCharVariable(Variable variable) throws IOException {
private void read2DimensionalArray(Variable variable, String shortName, int[] shape, int[] shapeForRead, int[] originForRead, TreeVector kalmanGainColumns) throws IOException, InvalidRangeException {
Array read = variable.read(originForRead, shapeForRead);
- double[] doubleArray = (double[]) read.get1DJavaArray(Double.TYPE);
+ double[] doubleArray = (double[]) read.get1DJavaArray(DataType.DOUBLE);
DimensionIndex[] dimensionIndices = {new DimensionIndex(shape[1]), new DimensionIndex(shape[2])};
Vector doubleVector = new Vector(doubleArray);
Attribute parentVectorIdAttribute = variable.findAttribute(PARENT_VECTOR_ID);
@@ -732,7 +708,7 @@ private void read2DimensionalArray(Variable variable, String shortName, int[] sh
private void read1DimensionalArray(Variable variable, String shortName, int[] shape, int[] shapeForRead, int[] originForRead, TreeVector kalmanGainColumns) throws IOException, InvalidRangeException {
Array read = variable.read(originForRead, shapeForRead);
- double[] doubleArray = (double[]) read.get1DJavaArray(Double.TYPE);
+ double[] doubleArray = (double[]) read.get1DJavaArray(DataType.DOUBLE);
DimensionIndex dimensionIndex = new DimensionIndex(shape[1]);
Vector doubleVector = new Vector(doubleArray);
TreeVector vector = new TreeVector(shortName, doubleVector, new DimensionIndex[]{dimensionIndex});
@@ -744,7 +720,7 @@ private void writeKalmanGainColumnToNetCdfFile(String netcdfFileName, IVector ka
}
private IVector readKalmanGainColumnFromNetCdfFile(String netcdfFileName, int columnSize, IVector templateTreeVector) {
- if (templateTreeVector != null && templateTreeVector instanceof CtaTreeVector){
+ if (templateTreeVector instanceof CtaTreeVector){
CtaTreeVector kalmanGainColumn = (CtaTreeVector) templateTreeVector.clone();
kalmanGainColumn.TVimport(netcdfFileName);
return kalmanGainColumn;
@@ -813,7 +789,7 @@ public KalmanGainStorage(File workingDir, String configString, int timeStep, Str
throw new RuntimeException(
"KalmanGainStorage: unknown storage type: " + configString);
}
- String dirName = new StringBuilder().append("tstep_").append(timeStep).toString();
+ String dirName = "tstep_" + timeStep;
this.timeStepDir = new File(workingDir, dirName);
if (!this.timeStepDir.isDirectory()) {
if (this.timeStepDir.exists()) {
@@ -855,7 +831,7 @@ public void readKGain(String usrObsId, Matrix Kmat) {
if (storageType == storeTxt) {
CsvReader csvReader;
- String sfilename = new StringBuilder().append("kg").append(observationIds[aStationList]).append(".txt").toString();
+ String sfilename = "kg" + observationIds[aStationList] + ".txt";
try {
csvReader = new CsvReader(new File(timeStepDir, sfilename));
@@ -876,7 +852,7 @@ public void readKGain(String usrObsId, Matrix Kmat) {
e.printStackTrace();
}
} else if (storageType == storeNetcdf) {
- String ncfilename = new StringBuilder().append("kg").append(observationIds[aStationList]).append(".nc").toString();
+ String ncfilename = "kg" + observationIds[aStationList] + ".nc";
String netcdfname = new File(timeStepDir, ncfilename).getAbsolutePath();
CtaVector ctavec = new CtaVector(stateSize);
CtaTreeVector nckalman = new CtaTreeVector("Kalman gain vector", "KGvec", ctavec);
@@ -919,7 +895,7 @@ public void writeKGain(String usrObsId, Matrix Kmat) {
vals[j] = K[j][aStationList];
}
if (storageType == storeTxt) {
- String sfilename = new StringBuilder().append("kg").append(observationIds[aStationList]).append(".txt").toString();
+ String sfilename = "kg" + observationIds[aStationList] + ".txt";
BufferedOutputStream outputStream;
try {
outputStream = new BufferedOutputStream(new FileOutputStream(new File(timeStepDir, sfilename)));
@@ -933,7 +909,7 @@ public void writeKGain(String usrObsId, Matrix Kmat) {
throw new IllegalArgumentException("No file found");
}
} else if (storageType == storeNetcdf) {
- String ncfilename = new StringBuilder().append("kg").append(observationIds[aStationList]).append(".nc").toString();
+ String ncfilename = "kg" + observationIds[aStationList] + ".nc";
IResultWriter netcdfWriter = new NetcdfResultWriterNative(timeStepDir, ncfilename);
Results.reset();
Results.addResultWriter(netcdfWriter);
@@ -951,17 +927,15 @@ public double getTimeStampAsMjd(){
return timeStampAsMJD;
}
- private class KalmanGainVariableData {
+ private static class KalmanGainVariableData {
private final String variableId;
private final ArrayList dimensions;
- private final Variable variable;
private final ITreeVector dataVector;
- private ArrayList vectorIds;
+ private final ArrayList vectorIds;
- public KalmanGainVariableData(String variableId, ArrayList dimensions, Variable variable, ITreeVector dataVector, ArrayList vectorIds) {
+ public KalmanGainVariableData(String variableId, ArrayList dimensions, ITreeVector dataVector, ArrayList vectorIds) {
this.variableId = variableId;
this.dimensions = dimensions;
- this.variable = variable;
this.dataVector = dataVector;
this.vectorIds = vectorIds;
}
@@ -974,10 +948,6 @@ public ArrayList getDimensions() {
return dimensions;
}
- public Variable getVariable() {
- return variable;
- }
-
public ITreeVector getDataVector() {
return dataVector;
}
diff --git a/core/java/src/org/openda/utils/io/NetCDFFile.java b/core/java/src/org/openda/utils/io/NetCDFFile.java
index ce7f54006..61e0be8c0 100644
--- a/core/java/src/org/openda/utils/io/NetCDFFile.java
+++ b/core/java/src/org/openda/utils/io/NetCDFFile.java
@@ -20,25 +20,23 @@
package org.openda.utils.io;
import ucar.ma2.*;
-import ucar.nc2.*;
+import ucar.nc2.Dimension;
+import ucar.nc2.Variable;
+import ucar.nc2.write.NetcdfFormatWriter;
import java.io.IOException;
import java.io.File;
/**
- * Created by nils van Velzen on 25/09/15.
- *
* This is a simple utility class to write variables to NetCDF. The current implementation is extremely simple but can/will be extended in the future.
*
+ * @author nils van Velzen on 25/09/15.
*/
public class NetCDFFile {
- private File fileName;
- private NetcdfFileWriter netcdfFileWriter;
+ private final File fileName;
private boolean fileIsNotCreated=true;
private Dimension nDim;
- private Dimension timeDim;
- private Variable variable;
//Create and initialize a new NetCDFFile. Nothing happens yet (no files are created)
@@ -47,32 +45,33 @@ public NetCDFFile(File fileName) {
}
- //Write an array to file. Currently we only support a single array per file. The timeindex species the additional axis along we can extend the array in an existing NetCDF file
- public void writeArray(double[] vals, int[] nDims, int iTime, String shortName) throws IOException, InvalidRangeException {
- //Check wether we have to define de header and create the file on first write
+ //Write an array to file. Currently, we only support a single array per file. The time-index specifies the additional axis along we can extend the array in an existing NetCDF file
+ public void writeArray(double[] vals, int iTime, String shortName) throws IOException, InvalidRangeException {
+ //Check whether we have to define de header and create the file on first write
int n=vals.length;
- NetcdfFileWriter netcdfFileWriter;
-
-
+ NetcdfFormatWriter.Builder NetcdfBuilder;
+ NetcdfFormatWriter NetcdfWriter;
Variable myVar;
+
if (this.fileIsNotCreated){
// Create a new file
- netcdfFileWriter = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, fileName.getAbsolutePath());
+ NetcdfBuilder = NetcdfFormatWriter.createNewNetcdf3(fileName.getAbsolutePath());
// Setup Header
- this.nDim = netcdfFileWriter.addDimension(null,"n", n);
- this.timeDim = netcdfFileWriter.addUnlimitedDimension("time");
- myVar = netcdfFileWriter.addVariable(null, shortName, DataType.DOUBLE, "time n");
+ this.nDim = NetcdfBuilder.addDimension("n", n);
+ NetcdfBuilder.addUnlimitedDimension("time");
+ NetcdfBuilder.addVariable(shortName, DataType.DOUBLE, "time n");
// create the file
- netcdfFileWriter.create();
+ NetcdfWriter = NetcdfBuilder.build();
this.fileIsNotCreated=false;
}
else {
- netcdfFileWriter = NetcdfFileWriter.openExisting(this.fileName.getAbsolutePath());
- myVar = netcdfFileWriter.findVariable(shortName);
+ NetcdfBuilder = NetcdfFormatWriter.openExisting(this.fileName.getAbsolutePath());
+ NetcdfWriter = NetcdfBuilder.build();
}
+ myVar = NetcdfWriter.findVariable(shortName);
ArrayDouble.D2 values = new ArrayDouble.D2(1, nDim.getLength());
// Copy the values
@@ -82,10 +81,10 @@ public void writeArray(double[] vals, int[] nDims, int iTime, String shortName)
int[] origin = new int[]{iTime, 0};
- netcdfFileWriter.write(myVar, origin, values);
+ NetcdfWriter.write(myVar, origin, values);
//Always close
- netcdfFileWriter.close();
+ NetcdfWriter.close();
}
}
diff --git a/core/java/src/org/openda/utils/io/ScalarExchangeItemNetcdfWriter.java b/core/java/src/org/openda/utils/io/ScalarExchangeItemNetcdfWriter.java
index 270dd530f..7c9cbefa9 100644
--- a/core/java/src/org/openda/utils/io/ScalarExchangeItemNetcdfWriter.java
+++ b/core/java/src/org/openda/utils/io/ScalarExchangeItemNetcdfWriter.java
@@ -26,7 +26,7 @@
import org.openda.interfaces.IGeometryInfo;
import org.openda.utils.Time;
import ucar.nc2.Dimension;
-import ucar.nc2.NetcdfFileWriter;
+import ucar.nc2.write.NetcdfFormatWriter;
import ucar.nc2.Variable;
import ucar.nc2.Attribute;
@@ -37,18 +37,18 @@
/**
* Writes scalar data from one or more IExchangeItems to a NetCDF file. The data is written per time step.
* This can only handle exchangeItems that contain scalar data for a single timeStep at a time, e.g. a model state scalar exchange item.
- * The written NetCDF files are compliant with the NetCDF CF conventions as much as possible, see http://cfconventions.org/
+ * The written NetCDF files are compliant with the NetCDF CF conventions as much as possible, see ...
*
* @author Arno Kockx
*/
public class ScalarExchangeItemNetcdfWriter {
private final IExchangeItem[] exchangeItems;
- private final NetcdfFileWriter netcdfFileWriter;
+ private final NetcdfFormatWriter netcdfWriter;
private final List stationIds;
private final Variable timeVariable;
private int currentTimeIndex = -1;
- private final List timesWrittenSoFar = new ArrayList();
+ private final List timesWrittenSoFar = new ArrayList<>();
public ScalarExchangeItemNetcdfWriter(IExchangeItem[] exchangeItems, File outputFile, String stationIdVarName, String stationDimensionVarName) {
if (exchangeItems == null) throw new IllegalArgumentException("exchangeItems == null");
@@ -60,44 +60,38 @@ public ScalarExchangeItemNetcdfWriter(IExchangeItem[] exchangeItems, File output
//validate that all exchange items are scalars.
validateExchangeItems(exchangeItems);
- //create netcdf file.
- try {
- //set fill to true, otherwise missing values will not be written for variables that do not have data for all stations.
- netcdfFileWriter = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, outputFile.getAbsolutePath());
- netcdfFileWriter.setFill(true);
- } catch (IOException e) {
- throw new RuntimeException(getClass().getSimpleName() + ": Error while opening netcdf file " + outputFile.getAbsolutePath() + " Message was: " + e.getMessage(), e);
- }
+ //set fill to true, otherwise missing values will not be written for variables that do not have data for all stations.
+ NetcdfFormatWriter.Builder netcdfWriterBuilder = NetcdfFormatWriter.createNewNetcdf3(outputFile.getAbsolutePath());
+ netcdfWriterBuilder.setFill(true);
//create time dimension and variable.
- Dimension timeDimension = NetcdfUtils.createTimeVariable(netcdfFileWriter, NetcdfUtils.TIME_VARIABLE_NAME, -1, NetcdfUtils.createTimeUnitString());
- timeVariable = netcdfFileWriter.findVariable(NetcdfUtils.TIME_VARIABLE_NAME);
+ Dimension timeDimension = NetcdfUtils.createTimeVariable(netcdfWriterBuilder, NetcdfUtils.TIME_VARIABLE_NAME, -1, NetcdfUtils.createTimeUnitString());
+ timeVariable = netcdfWriterBuilder.getRootGroup().build().findVariableOrInParent(NetcdfUtils.TIME_VARIABLE_NAME);
//create station dimension and variable.
//this only adds a station id variable, this does not add spatial variables with coordinates,
//because the coordinates are usually not available in exchangeItems that come from models.
//gather locationIds.
stationIds = NetcdfUtils.getStationIds(Arrays.asList(exchangeItems), null);
- Dimension stationDimension = NetcdfUtils.createStationsVariable(netcdfFileWriter, stationIdVarName, stationDimensionVarName, stationIds.size());
+ Dimension stationDimension = NetcdfUtils.createStationsVariable(netcdfWriterBuilder, stationIdVarName, stationDimensionVarName, stationIds.size());
//create data variables.
- NetcdfUtils.createDataVariables(netcdfFileWriter, Arrays.asList(exchangeItems), timeDimension, null, stationDimension, null);
+ NetcdfUtils.createDataVariables(netcdfWriterBuilder, Arrays.asList(exchangeItems), timeDimension, null, stationDimension, null);
//add global metadata.
- NetcdfUtils.addGlobalAttributes(netcdfFileWriter);
- netcdfFileWriter.addGroupAttribute(null, new Attribute(NetcdfUtils.FEATURE_TYPE_ATTRIBUTE_NAME, NetcdfUtils.TIME_SERIES_FEATURE_TYPE));
-
+ NetcdfUtils.addGlobalAttributes(netcdfWriterBuilder);
+ netcdfWriterBuilder.addAttribute(new Attribute(NetcdfUtils.FEATURE_TYPE_ATTRIBUTE_NAME, NetcdfUtils.TIME_SERIES_FEATURE_TYPE));
try {
- netcdfFileWriter.create();
+ netcdfWriter = netcdfWriterBuilder.build();
} catch (Exception e) {
- throw new RuntimeException(getClass().getSimpleName() + ": Error while creating netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + " Message was: " + e.getMessage(), e);
+ throw new RuntimeException(getClass().getSimpleName() + ": Error while creating netcdf file " + outputFile.getAbsolutePath() + " Message was: " + e.getMessage(), e);
}
//write station variable values.
try {
- NetcdfUtils.writeStationIdVariableValues(netcdfFileWriter, stationIdVarName, stationIds);
+ NetcdfUtils.writeStationIdVariableValues(netcdfWriter, stationIdVarName, stationIds);
} catch (Exception e) {
- throw new RuntimeException(getClass().getSimpleName() + ": Error while writing station variable values to netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + " Message was: " + e.getMessage(), e);
+ throw new RuntimeException(getClass().getSimpleName() + ": Error while writing station variable values to netcdf file " + netcdfWriter.getOutputFile().getLocation() + " Message was: " + e.getMessage(), e);
}
}
@@ -125,6 +119,23 @@ public void writeDataForCurrentTimeStep() {
*/
private void writeTime() {
//get current time.
+ double currentTime = getCurrentTime();
+
+ //write current time.
+ if (timesWrittenSoFar.contains(currentTime)) {
+ throw new RuntimeException(getClass().getSimpleName() + ": Cannot write data. Output netcdf file " + netcdfWriter.getOutputFile().getLocation()
+ + " already contains data for current time " + new Date(Time.mjdToMillies(currentTime)));
+ }
+ try {
+ NetcdfUtils.writeTimeVariableSingleValue(netcdfWriter, timeVariable, currentTimeIndex, currentTime);
+ } catch (Exception e) {
+ throw new RuntimeException(getClass().getSimpleName() + ": Error while writing time value for current time " + new Date(Time.mjdToMillies(currentTime))
+ + " to netcdf file " + netcdfWriter.getOutputFile().getLocation() + " Message was: " + e.getMessage(), e);
+ }
+ timesWrittenSoFar.add(currentTime);
+ }
+
+ private double getCurrentTime() {
double currentTime = Double.NaN;
for (IExchangeItem item : exchangeItems) {
if (item.getTimeInfo() == null || item.getTimeInfo().getTimes() == null || item.getTimeInfo().getTimes().length != 1 || Double.isNaN(item.getTimeInfo().getTimes()[0])) {
@@ -138,23 +149,11 @@ private void writeTime() {
} else {
if (time != currentTime) {
throw new RuntimeException(getClass().getSimpleName() + ": Cannot write data. Exchange items have different times for time index " + currentTimeIndex
- + " in netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation());
+ + " in netcdf file " + netcdfWriter.getOutputFile().getLocation());
}
}
}
-
- //write current time.
- if (timesWrittenSoFar.contains(currentTime)) {
- throw new RuntimeException(getClass().getSimpleName() + ": Cannot write data. Output netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation()
- + " already contains data for current time " + new Date(Time.mjdToMillies(currentTime)));
- }
- try {
- NetcdfUtils.writeTimeVariableSingleValue(netcdfFileWriter, timeVariable, currentTimeIndex, currentTime);
- } catch (Exception e) {
- throw new RuntimeException(getClass().getSimpleName() + ": Error while writing time value for current time " + new Date(Time.mjdToMillies(currentTime))
- + " to netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + " Message was: " + e.getMessage(), e);
- }
- timesWrittenSoFar.add(currentTime);
+ return currentTime;
}
/**
@@ -184,16 +183,16 @@ private void writeData() {
origin[1] = stationIndex;
//write values for current time.
- Variable dataVariable = NetcdfUtils.getVariableForExchangeItem(netcdfFileWriter.getNetcdfFile(), item);
- NetcdfUtils.writeSelectedData(netcdfFileWriter, dataVariable, origin, dimensions, values);
+ Variable dataVariable = NetcdfUtils.getVariableForExchangeItem(netcdfWriter.getOutputFile(), item);
+ NetcdfUtils.writeSelectedData(netcdfWriter, dataVariable, origin, dimensions, values);
}
}
public void close() {
try {
- netcdfFileWriter.close();
+ netcdfWriter.close();
} catch (IOException e) {
- throw new RuntimeException("Error while closing netcdf file " + netcdfFileWriter.getNetcdfFile().getLocation() + " Message was: " + e.getMessage(), e);
+ throw new RuntimeException("Error while closing netcdf file " + netcdfWriter.getOutputFile().getLocation() + " Message was: " + e.getMessage(), e);
}
}
}
diff --git a/core/java/test/org/openda/exchange/dataobjects/NetcdfDataObjectTest.java b/core/java/test/org/openda/exchange/dataobjects/NetcdfDataObjectTest.java
index e5984f28f..39051838f 100644
--- a/core/java/test/org/openda/exchange/dataobjects/NetcdfDataObjectTest.java
+++ b/core/java/test/org/openda/exchange/dataobjects/NetcdfDataObjectTest.java
@@ -55,6 +55,19 @@ public void testReadTimeSeriesEnsemble() {
assertEquals(3, itemValues.length);
}
+ public void testReadTimeSeriesEnsembleFromNetcdf4() {
+ NetcdfDataObject dataObject = new NetcdfDataObject();
+ dataObject.initialize(this.testRunDataDir, new String[]{"netcdf4_timeseries_ensemble.nc", "true", "false", "netcdf4"});
+ int[] ensembleIndices = dataObject.getEnsembleMemberIndices();
+ assertEquals(3, ensembleIndices.length);
+ String[] ensembleIds = dataObject.getEnsembleExchangeItemIds();
+ assertEquals(4, ensembleIds.length);
+ IExchangeItem item = dataObject.getDataObjectExchangeItem("27.waterlevel", 1);
+ assertFalse(item == null);
+ double[] itemValues = item.getValuesAsDoubles();
+ assertEquals(3, itemValues.length);
+ }
+
public void testReadGridEnsemble() {
NetcdfDataObject dataObject = new NetcdfDataObject();
dataObject.initialize(this.testRunDataDir, new String[]{"netcdf_grid_with_ensemble.nc", "true", "false"});
diff --git a/core/java/test/org/openda/exchange/dataobjects/NetcdfFileConcatenaterTest.java b/core/java/test/org/openda/exchange/dataobjects/NetcdfFileConcatenaterTest.java
index 15f784386..b3112ece1 100644
--- a/core/java/test/org/openda/exchange/dataobjects/NetcdfFileConcatenaterTest.java
+++ b/core/java/test/org/openda/exchange/dataobjects/NetcdfFileConcatenaterTest.java
@@ -22,7 +22,9 @@
import junit.framework.TestCase;
import org.openda.blackbox.config.BBUtils;
import org.openda.utils.OpenDaTestSupport;
+import ucar.ma2.DataType;
import ucar.nc2.NetcdfFile;
+import ucar.nc2.NetcdfFiles;
import java.io.File;
import java.io.IOException;
@@ -48,10 +50,12 @@ public void testDelft3dHisFileConcatenation() throws IOException {
File secondFile = new File(this.testRunDataDir, "westerscheldt_part2_his.nc");
NetcdfFileConcatenater.main(new String[]{targetFile.getAbsolutePath(), secondFile.getAbsolutePath()});
// find size of time array for original files and concatenated file
- long size1 = NetcdfFile.open(firstFile.toString()).findVariable("time").read().getSize();
- long size2 = NetcdfFile.open(secondFile.toString()).findVariable("time").read().getSize();
- long size3 = NetcdfFile.open(targetFile.toString()).findVariable("time").read().getSize();
- assertEquals(size3, size1 + size2);
+ int[] size1 = Objects.requireNonNull(NetcdfFiles.open(firstFile.toString()).findVariable("time")).getShape();
+ int[] size2 = Objects.requireNonNull(NetcdfFiles.open(secondFile.toString()).findVariable("time")).getShape();
+ int[] size3 = Objects.requireNonNull(NetcdfFiles.open(targetFile.toString()).findVariable("time")).getShape();
+ for (int i = 0; i < size3.length; ++i) {
+ assertEquals(size3[i], size1[i] + size2[i]);
+ }
}
public void testDflowfmHisfileConcatenation() throws IOException {
@@ -64,10 +68,12 @@ public void testDflowfmHisfileConcatenation() throws IOException {
File secondFile = new File(this.testRunDataDir, "simple_waal_part2_his.nc");
NetcdfFileConcatenater.main(new String[]{targetFile.getAbsolutePath(), secondFile.getAbsolutePath()});
// find size of time array for original files and concatenated file
- long size1 = NetcdfFile.open(firstFile.toString()).findVariable("time").read().getSize();
- long size2 = NetcdfFile.open(secondFile.toString()).findVariable("time").read().getSize();
- long size3 = NetcdfFile.open(targetFile.toString()).findVariable("time").read().getSize();
- assertEquals(size3, size1 + size2);
+ int[] size1 = Objects.requireNonNull(NetcdfFiles.open(firstFile.toString()).findVariable("time")).getShape();
+ int[] size2 = Objects.requireNonNull(NetcdfFiles.open(secondFile.toString()).findVariable("time")).getShape();
+ int[] size3 = Objects.requireNonNull(NetcdfFiles.open(targetFile.toString()).findVariable("time")).getShape();
+ for (int i = 0; i < size3.length; ++i) {
+ assertEquals(size3[i], size1[i] + size2[i]);
+ }
}
public void testNetcdfFixedTimeDimensionConcatenation() {
@@ -154,16 +160,12 @@ public void testNetcdf3Dmap() throws IOException {
}
private static void checkConcatenated3dVariable(File firstFile, File targetFile, File secondFile, String variableName, int split) throws IOException {
- NetcdfFile firstNetcdf = null;
- NetcdfFile secondNetcdf = null;
- NetcdfFile concatenatedNetcdf = null;
- try {
- firstNetcdf = NetcdfFile.open(firstFile.toString());
- secondNetcdf = NetcdfFile.open(secondFile.toString());
- concatenatedNetcdf = NetcdfFile.open(targetFile.toString());
- double[] firstValues = (double[]) firstNetcdf.findVariable(variableName).read().get1DJavaArray(Double.TYPE);
- double[] secondValues = (double[]) secondNetcdf.findVariable(variableName).read().get1DJavaArray(Double.TYPE);
- double[] concatenatedValues = (double[]) concatenatedNetcdf.findVariable(variableName).read().get1DJavaArray(Double.TYPE);
+ try (NetcdfFile firstNetcdf = NetcdfFiles.open(firstFile.toString());
+ NetcdfFile secondNetcdf = NetcdfFiles.open(secondFile.toString());
+ NetcdfFile concatenatedNetcdf = NetcdfFiles.open(targetFile.toString())) {
+ double[] firstValues = (double[]) Objects.requireNonNull(firstNetcdf.findVariable(variableName)).read().get1DJavaArray(DataType.DOUBLE);
+ double[] secondValues = (double[]) Objects.requireNonNull(secondNetcdf.findVariable(variableName)).read().get1DJavaArray(DataType.DOUBLE);
+ double[] concatenatedValues = (double[]) Objects.requireNonNull(concatenatedNetcdf.findVariable(variableName)).read().get1DJavaArray(DataType.DOUBLE);
assertEquals(firstValues.length + secondValues.length - 125, concatenatedValues.length);
for (int i = 0; i < split; i++) {
assertEquals(firstValues[i], concatenatedValues[i]);
@@ -171,10 +173,6 @@ private static void checkConcatenated3dVariable(File firstFile, File targetFile,
for (int i = split; i < concatenatedValues.length; i++) {
assertEquals(secondValues[i - split], concatenatedValues[i]);
}
- } finally {
- if (firstNetcdf != null) firstNetcdf.close();
- if (secondNetcdf != null) secondNetcdf.close();
- if (concatenatedNetcdf != null) concatenatedNetcdf.close();
}
}
@@ -207,10 +205,10 @@ public void testConcatenationOfManyFiles() throws IOException {
NetcdfFile expectedNetcdf = null;
NetcdfFile targetNetcdf = null;
try {
- expectedNetcdf = NetcdfFile.open(expectedFile.toString());
- long expected = expectedNetcdf.findVariable("time").read().getSize();
- targetNetcdf = NetcdfFile.open(targetFile.toString());
- long target = targetNetcdf.findVariable("time").read().getSize();
+ expectedNetcdf = NetcdfFiles.open(expectedFile.toString());
+ long expected = Objects.requireNonNull(expectedNetcdf.findVariable("time")).read().getSize();
+ targetNetcdf = NetcdfFiles.open(targetFile.toString());
+ long target = Objects.requireNonNull(targetNetcdf.findVariable("time")).read().getSize();
assertEquals("Time data matches", expected, target);
} finally {
if (expectedNetcdf != null) expectedNetcdf.close();
@@ -230,10 +228,10 @@ public void testConcatenationOfManyFilesInOneGo() throws IOException {
NetcdfFile expectedNetcdf = null;
NetcdfFile targetNetcdf = null;
try {
- expectedNetcdf = NetcdfFile.open(expectedFile.toString());
- long expected = expectedNetcdf.findVariable("time").read().getSize();
- targetNetcdf = NetcdfFile.open(targetFile.toString());
- long target = targetNetcdf.findVariable("time").read().getSize();
+ expectedNetcdf = NetcdfFiles.open(expectedFile.toString());
+ long expected = Objects.requireNonNull(expectedNetcdf.findVariable("time")).read().getSize();
+ targetNetcdf = NetcdfFiles.open(targetFile.toString());
+ long target = Objects.requireNonNull(targetNetcdf.findVariable("time")).read().getSize();
assertEquals("Time data matches", expected, target);
} finally {
if (expectedNetcdf != null) expectedNetcdf.close();
@@ -242,16 +240,12 @@ public void testConcatenationOfManyFilesInOneGo() throws IOException {
}
private void checkConcatenatedValues(File firstFile, File targetFile, File secondFile, int split) throws IOException {
- NetcdfFile firstNetcdf = null;
- NetcdfFile secondNetcdf = null;
- NetcdfFile concatenatedNetcdf = null;
- try {
- firstNetcdf = NetcdfFile.open(firstFile.toString());
- secondNetcdf = NetcdfFile.open(secondFile.toString());
- concatenatedNetcdf = NetcdfFile.open(targetFile.toString());
- double[] firstValues = (double[]) firstNetcdf.findVariable("Runoff").read().get1DJavaArray(Double.TYPE);
- double[] secondValues = (double[]) secondNetcdf.findVariable("Runoff").read().get1DJavaArray(Double.TYPE);
- double[] concatenatedValues = (double[]) concatenatedNetcdf.findVariable("Runoff").read().get1DJavaArray(Double.TYPE);
+ try (NetcdfFile firstNetcdf = NetcdfFiles.open(firstFile.toString());
+ NetcdfFile secondNetcdf = NetcdfFiles.open(secondFile.toString());
+ NetcdfFile concatenatedNetcdf = NetcdfFiles.open(targetFile.toString())) {
+ double[] firstValues = (double[]) Objects.requireNonNull(firstNetcdf.findVariable("Runoff")).read().get1DJavaArray(DataType.DOUBLE);
+ double[] secondValues = (double[]) Objects.requireNonNull(secondNetcdf.findVariable("Runoff")).read().get1DJavaArray(DataType.DOUBLE);
+ double[] concatenatedValues = (double[]) Objects.requireNonNull(concatenatedNetcdf.findVariable("Runoff")).read().get1DJavaArray(DataType.DOUBLE);
assertEquals(firstValues.length + secondValues.length - 1, concatenatedValues.length);
for (int i = 0; i < split; i++) {
assertEquals(firstValues[i], concatenatedValues[i]);
@@ -259,10 +253,6 @@ private void checkConcatenatedValues(File firstFile, File targetFile, File secon
for (int i = split; i < concatenatedValues.length; i++) {
assertEquals(secondValues[i - 6], concatenatedValues[i]);
}
- } finally {
- if (firstNetcdf != null) firstNetcdf.close();
- if (secondNetcdf != null) secondNetcdf.close();
- if (concatenatedNetcdf != null) concatenatedNetcdf.close();
}
}
}
diff --git a/core/java/test/org/openda/exchange/dataobjects/testData/netcdf4_timeseries_ensemble.nc b/core/java/test/org/openda/exchange/dataobjects/testData/netcdf4_timeseries_ensemble.nc
new file mode 100644
index 000000000..8f2babe01
Binary files /dev/null and b/core/java/test/org/openda/exchange/dataobjects/testData/netcdf4_timeseries_ensemble.nc differ
diff --git a/core/java/test/org/openda/utils/io/KalmanGainStorageTest.java b/core/java/test/org/openda/utils/io/KalmanGainStorageTest.java
index 09d09c2c8..87fa92dd7 100644
--- a/core/java/test/org/openda/utils/io/KalmanGainStorageTest.java
+++ b/core/java/test/org/openda/utils/io/KalmanGainStorageTest.java
@@ -20,14 +20,11 @@
package org.openda.utils.io;
import junit.framework.TestCase;
import org.openda.blackbox.config.BBUtils;
-import org.openda.costa.CtaTreeVector;
-import org.openda.costa.CtaVector;
import org.openda.exchange.timeseries.TimeUtils;
import org.openda.interfaces.ITreeVector;
import org.openda.interfaces.IVector;
import org.openda.utils.OpenDaTestSupport;
import org.openda.utils.TreeVector;
-import org.openda.utils.Vector;
import java.io.File;
import java.io.IOException;
@@ -47,7 +44,7 @@ protected void setUp() throws IOException {
testRunDataDir = testData.getTestRunDataDir();
}
- public void testReadWriteKalmanGainXML() throws Exception {
+ public void testReadWriteKalmanGainXML() {
File kgStorageDir = new File(testRunDataDir, "kgStorage_201102181800");
File kgStorageDirCopy = new File(testRunDataDir, "kgStorage_201102181800_copy");
@@ -63,10 +60,10 @@ public void testReadWriteKalmanGainXML() throws Exception {
kgStorageOut.writeKalmanGain(kgStorageIn.getObservationIds(),
kgStorageIn.getObservationOffsetInDays(), kgStorageIn.getKalmanGainColumns(), null);
- testData.FilesAreIdentical(
- new File(kgStorageDir, "kalmanGainStorage_out.xml"),
- new File(kgStorageDirCopy, "kalmanGainStorage.xml"));
-
+ File outFile = new File(kgStorageDir, "kalmanGainStorage_out.xml");
+ File refFile = new File(kgStorageDirCopy, "kalmanGainStorage.xml");
+ assert(outFile.exists());
+ assert(testData.FilesAreIdentical(outFile, refFile));
}
public void testReadWriteKalmanGainNetcdfCF() {
@@ -82,7 +79,7 @@ public void testReadWriteKalmanGainNetcdfCF() {
assertEquals(8, kalmanGainColumnsIn.length);
String[] observationIds = kgStorageIn.getObservationIds();
- checkKalmanGainContents(timeAsMJD, kgStorageIn, kalmanGainColumnsIn, observationIds);
+ assert(checkKalmanGainContents(timeAsMJD, kgStorageIn, kalmanGainColumnsIn, observationIds));
KalmanGainStorage kgStorageOut = new KalmanGainStorage(testRunDataDir, timeAsMJD);
kgStorageOut.setColumnFileType(KalmanGainStorage.StorageType.netcdf_cf);
@@ -90,7 +87,7 @@ public void testReadWriteKalmanGainNetcdfCF() {
kgStorageOut.writeKalmanGain(observationIds, kgStorageIn.getObservationOffsetInDays(), kalmanGainColumnsIn, kgStorageIn.getHk());
kgStorageOut.readKalmanGain();
- checkKalmanGainContents(timeAsMJD, kgStorageOut, kgStorageOut.getKalmanGainColumns(), kgStorageOut.getObservationIds());
+ assert(checkKalmanGainContents(timeAsMJD, kgStorageOut, kgStorageOut.getKalmanGainColumns(), kgStorageOut.getObservationIds()));
}
public void testReadWriteKalmanGainNetcdfCFHK() throws ParseException {
@@ -124,7 +121,7 @@ public void testReadWriteKalmanGainNetcdfCFHK() throws ParseException {
}
}
- private void checkKalmanGainContents(double timeAsMJD, KalmanGainStorage kgStorageIn, IVector[] kalmanGainColumns, String[] observationIds) {
+ private boolean checkKalmanGainContents(double timeAsMJD, KalmanGainStorage kgStorageIn, IVector[] kalmanGainColumns, String[] observationIds) {
String[] expectedObservationIds = {"WICK.waterlevel", "VLISSGN.waterlevel", "DENHDR.waterlevel", "NORTHSS.waterlevel", "DOVR.waterlevel", "SHEERNS.waterlevel", "HOEKVHLD.waterlevel", "LOWST.waterlevel"};
for (int i = 0; i < expectedObservationIds.length; i++) {
assertEquals(expectedObservationIds[i], observationIds[i]);
@@ -179,6 +176,7 @@ private void checkKalmanGainContents(double timeAsMJD, KalmanGainStorage kgStora
assertEquals(i * 10 + j, hk[i][j], 0.000001);
}
}
+ return true;
}
public void testReadWriteKalmanGainNetcdfCFDoubleState() {
@@ -194,7 +192,7 @@ public void testReadWriteKalmanGainNetcdfCFDoubleState() {
assertEquals(8, kalmanGainColumnsIn.length);
String[] observationIds = kgStorageIn.getObservationIds();
- checkKalmanGainContentsDoubleState(timeAsMJD, kgStorageIn, kalmanGainColumnsIn, observationIds);
+ assert(checkKalmanGainContentsDoubleState(timeAsMJD, kgStorageIn, kalmanGainColumnsIn, observationIds));
KalmanGainStorage kgStorageOut = new KalmanGainStorage(testRunDataDir, timeAsMJD);
kgStorageOut.setColumnFileType(KalmanGainStorage.StorageType.netcdf_cf);
@@ -202,10 +200,10 @@ public void testReadWriteKalmanGainNetcdfCFDoubleState() {
kgStorageOut.writeKalmanGain(observationIds, kgStorageIn.getObservationOffsetInDays(), kalmanGainColumnsIn, null);
kgStorageOut.readKalmanGain();
- checkKalmanGainContentsDoubleState(timeAsMJD, kgStorageOut, kgStorageOut.getKalmanGainColumns(), kgStorageOut.getObservationIds());
+ assert(checkKalmanGainContentsDoubleState(timeAsMJD, kgStorageOut, kgStorageOut.getKalmanGainColumns(), kgStorageOut.getObservationIds()));
}
- private void checkKalmanGainContentsDoubleState(double timeAsMJD, KalmanGainStorage kgStorageIn, IVector[] kalmanGainColumns, String[] observationIds) {
+ private boolean checkKalmanGainContentsDoubleState(double timeAsMJD, KalmanGainStorage kgStorageIn, IVector[] kalmanGainColumns, String[] observationIds) {
String[] expectedObservationIds = {"WICK.waterlevel", "VLISSGN.waterlevel", "DENHDR.waterlevel", "NORTHSS.waterlevel", "DOVR.waterlevel", "SHEERNS.waterlevel", "HOEKVHLD.waterlevel", "LOWST.waterlevel"};
for (int i = 0; i < expectedObservationIds.length; i++) {
assertEquals(expectedObservationIds[i], observationIds[i]);
@@ -244,7 +242,7 @@ private void checkKalmanGainContentsDoubleState(double timeAsMJD, KalmanGainStor
assertEquals("NoiseY", secondStateSubTreeVectorIds.get(0));
double[] secondStateValues = secondStateTreeVector.getValues();
- assertEquals(120 - 0, secondStateValues[0], delta);
+ assertEquals(120 , secondStateValues[0], delta);
assertEquals(120 - 1, secondStateValues[1], delta);
assertEquals(120 - 2, secondStateValues[2], delta);
assertEquals(120 - 13, secondStateValues[13], delta);
@@ -261,109 +259,6 @@ private void checkKalmanGainContentsDoubleState(double timeAsMJD, KalmanGainStor
assertEquals(-0.052612, s1Values[2], delta);
assertEquals(0.015112, s1Values[3], delta);
assertEquals(-0.038791, s1Values[4], delta);
+ return true;
}
-
- private void writeAndReadKalmanGain(double timeAsMJD, int columnSize) {
- // write the kalman gain
- IVector[] kalmanGainColumnsOut = createKalmanGainColumns(columnSize);
- String[] observationIdsOut = {"loc-A", "loc-B", "loc-C", "loc-D"};
- double[] observationOffsetsInDaysOut = {-0.1d, -3d, 0d, 0d};
- String commentOut = "this is a four column kalman gain";
- KalmanGainStorage kgStorageOut = new KalmanGainStorage(testRunDataDir, timeAsMJD);
- kgStorageOut.setComment(commentOut);
- kgStorageOut.setKalmanGainStorageFileName("fourColumnStorage.xml");
- kgStorageOut.writeKalmanGain(observationIdsOut, observationOffsetsInDaysOut, kalmanGainColumnsOut, null);
-
- // read the kalman gain
- KalmanGainStorage kgStorageIn = new KalmanGainStorage(testRunDataDir, timeAsMJD);
- kgStorageIn.setKalmanGainStorageFileName("fourColumnStorage.xml");
- kgStorageIn.readKalmanGain();
- String commentIn = kgStorageIn.getComment();
- assertEquals("Comment out/in", commentOut, commentIn);
-
- String[] observationIdsIn = kgStorageIn.getObservationIds();
- for (int i = 0; i < observationIdsIn.length; i++) {
- assertEquals("observationId out/in", observationIdsOut[i], observationIdsIn[i]);
- }
-
- double[] observationOffsetsInDaysIn = kgStorageIn.getObservationOffsetInDays();
- for (int i = 0; i < observationOffsetsInDaysIn.length; i++) {
- assertEquals("observationOffsetInDays out/in",
- observationOffsetsInDaysOut[i], observationOffsetsInDaysIn[i]);
- }
-
- IVector[] kalmanGainColumnsIn = kgStorageIn.getKalmanGainColumns();
- for (int i = 0; i < kalmanGainColumnsIn.length; i++) {
- for (int j = 0; j < kalmanGainColumnsIn[i].getSize(); j++) {
- assertEquals("Value out/in", kalmanGainColumnsOut[i].getValue(j), kalmanGainColumnsIn[i].getValue(j));
- }
- }
- }
-
- private IVector[] createKalmanGainColumns(int columnSize) {
- // kalman gain column that will be written
- IVector[] kalmanGainColumns = new IVector[4];
- // first kalman gain column
- kalmanGainColumns[0] = new Vector(columnSize);
- kalmanGainColumns[0].setConstant(321.0d);
- // second kalman gain column
- kalmanGainColumns[1] = new Vector(columnSize);
- for (int i = 0; i < kalmanGainColumns[1].getSize(); i++) {
- kalmanGainColumns[1].setValue(i, 101d + 1);
- }
- // third kalman gain column (cta-tree vector)
- kalmanGainColumns[2] = createKgColumnTreeVector("kgColumn3XML", columnSize);
- // third kalman gain column (cta-tree vector)
- kalmanGainColumns[3] = createKgColumnCTATreeVector("kgColumn4Cta", columnSize);
- return kalmanGainColumns;
- }
-
- private TreeVector createKgColumnTreeVector(String treeVectorId, int totalSize) {
- TreeVector treeVector = new TreeVector(treeVectorId);
-
- // tree vector part 1
- double[] part1Values = {999d, 888d, 777d, 666d, 555d, 444d, 333d, 222d, 111d};
- treeVector.addChild("part1", part1Values);
-
- // tree vector part 3
- IVector part3Vector = new Vector(16);
- part3Vector.setConstant(23d);
- treeVector.addChild("part2", part3Vector.getValues());
-
- // tree vector part 2
- double[] part2Values = new double[totalSize- part1Values.length-part3Vector.getSize()];
- for (int i = 0; i < part2Values.length; i++) {
- part2Values[i] = 1010d + i * 10;
- }
- treeVector.addChild("part3", part2Values);
- return treeVector;
- }
-
- private CtaTreeVector createKgColumnCTATreeVector(String treeVectorId, int totalSize) {
-
- // tree vector part 1
- double[] part1Values = {999d, 888d, 777d, 666d, 555d, 444d, 333d, 222d, 111d};
- IVector vec1 = new CtaVector(9);
- vec1.setValues(part1Values);
- CtaTreeVector cta_part1 = new CtaTreeVector("first part", "first", vec1);
-
- // tree vector part 3
- IVector part3Vector = new CtaVector(16);
- part3Vector.setConstant(23d);
- CtaTreeVector cta_part3 = new CtaTreeVector("third part", "third", part3Vector);
-
- // tree vector part 2
- double[] part2Values = new double[totalSize- part1Values.length-part3Vector.getSize()];
- for (int i = 0; i < part2Values.length; i++) {
- part2Values[i] = 1010d + i * 10;
- }
- IVector vec2 = new CtaVector(part2Values.length);
- vec2.setValues(part2Values);
- CtaTreeVector cta_part2 = new CtaTreeVector("second part", "second", vec1);
-
- CtaTreeVector[] subVectors = {cta_part1, cta_part2, cta_part3};
- return new CtaTreeVector(treeVectorId,treeVectorId,subVectors);
-
- }
-
}
diff --git a/core/java/test/org/openda/utils/io/testData/kgStorage_201102181800/kalmanGainStorage.xml b/core/java/test/org/openda/utils/io/testData/kgStorage_201102181800/kalmanGainStorage.xml
index 54414c806..be8be900d 100644
--- a/core/java/test/org/openda/utils/io/testData/kgStorage_201102181800/kalmanGainStorage.xml
+++ b/core/java/test/org/openda/utils/io/testData/kgStorage_201102181800/kalmanGainStorage.xml
@@ -2,7 +2,6 @@
- Test file for openda kalman gain storage
55610.75
2011-02-18T19:00:00.000+01:00
diff --git a/model_delft3d/java/src/org/openda/model_delft3d/NetcdfD3dHisDataObject.java b/model_delft3d/java/src/org/openda/model_delft3d/NetcdfD3dHisDataObject.java
index 74e914a52..e5eebebdd 100644
--- a/model_delft3d/java/src/org/openda/model_delft3d/NetcdfD3dHisDataObject.java
+++ b/model_delft3d/java/src/org/openda/model_delft3d/NetcdfD3dHisDataObject.java
@@ -22,9 +22,11 @@
import org.openda.exchange.dataobjects.NetcdfUtils;
import org.openda.interfaces.*;
import ucar.ma2.Array;
+import ucar.ma2.DataType;
import ucar.nc2.Dimension;
import ucar.nc2.NetcdfFile;
-import ucar.nc2.NetcdfFileWriter;
+import ucar.nc2.dataset.NetcdfDatasets;
+import ucar.nc2.write.NetcdfFormatWriter;
import ucar.nc2.Variable;
import java.io.File;
@@ -60,7 +62,7 @@ public void initialize(File workingDir, String[] arguments) {
File netcdfFilePath = new File(workingDir, arguments[0]);
try {
- netcdfFile = NetcdfFile.open(netcdfFilePath.getAbsolutePath());
+ netcdfFile = NetcdfDatasets.openFile(netcdfFilePath.getAbsolutePath(), new NetcdfUtils.MyCancelTask());
} catch (IOException e) {
throw new RuntimeException("NetcdfD3dHisDataObject could not open netcdf file " + netcdfFilePath.getAbsolutePath());
}
@@ -100,7 +102,7 @@ public IExchangeItem getDataObjectExchangeItem(String exchangeItemID) {
private void readNetCdfVariables() {
//in most netcdfFiles the time and spatial coordinate variables are shared between multiple data variables.
- //Therefore cache timeInfo objects so that time coordinate variables are never read more than once.
+ //Therefore, cache timeInfo objects so that time coordinate variables are never read more than once.
Map timeInfoCache = new HashMap();
// Loading of variable containing stations names
@@ -116,7 +118,7 @@ private void readNetCdfVariables() {
e.printStackTrace();
}
// Extraction of station names
- char[] nameCharArray = (char[]) stationNamesChar.get1DJavaArray(char.class);
+ char[] nameCharArray = (char[]) stationNamesChar.get1DJavaArray(DataType.CHAR);
int stringLength=stationNamesChar.getShape()[1];
for (Variable variable : this.netcdfFile.getVariables()) {
@@ -140,7 +142,7 @@ private void readNetCdfVariables() {
throw new RuntimeException("NetcdfD3dHisDataObject could not read time variable " + timeVariable.getShortName() +
"from netcdf file " + netcdfFile.getLocation());
}
- timesInNetcdfFile = (double[]) timesArray.get1DJavaArray(double.class);
+ timesInNetcdfFile = (double[]) timesArray.get1DJavaArray(DataType.DOUBLE);
}
timeInfoForAllTimeDepVars = new TimeInfo(timesInNetcdfFile);
@@ -217,7 +219,7 @@ private void readNetCdfVariables() {
throw new RuntimeException("NetcdfD3dHisDataObject could not read time variable " + timeVariable.getShortName() +
"from netcdf file " + netcdfFile.getLocation());
}
- timesInNetcdfFile = (double[]) timesArray.get1DJavaArray(double.class);
+ timesInNetcdfFile = (double[]) timesArray.get1DJavaArray(DataType.DOUBLE);
}
timeInfoForAllTimeDepVars = new TimeInfo(timesInNetcdfFile);
@@ -422,7 +424,7 @@ public static void hisFileWriter(String varName, double[] values,File workingDir
NetcdfFile netcdfHisFile;
try {
- netcdfHisFile = NetcdfFile.open(netcdfFilePath.getAbsolutePath());
+ netcdfHisFile = NetcdfDatasets.openFile(netcdfFilePath.getAbsolutePath(), new NetcdfUtils.MyCancelTask());
} catch (IOException e) {
throw new RuntimeException("NetcdfD3dHisDataObject could not open netcdf file " + netcdfFilePath.getAbsolutePath());
}
@@ -502,17 +504,17 @@ public static void hisFileWriter(String varName, double[] values,File workingDir
}
- NetcdfFileWriter netcdfFileWriter = null;
+ NetcdfFormatWriter NetcdfWriter = null;
try {
- netcdfFileWriter = NetcdfFileWriter.openExisting(netcdfFilePath.getAbsolutePath());
+ NetcdfWriter = (NetcdfFormatWriter.openExisting(netcdfFilePath.getAbsolutePath())).build();
} catch (IOException e) {
- e.printStackTrace();
+ throw new RuntimeException(e);
}
- NetcdfUtils.writeSelectedData(netcdfFileWriter,variable, origin, sizeArray, stationValues);
+ NetcdfUtils.writeSelectedData(NetcdfWriter,variable, origin, sizeArray, stationValues);
try {
- netcdfFileWriter.close();
+ NetcdfWriter.close();
netcdfHisFile.close();
} catch (IOException e) {
e.printStackTrace();
diff --git a/model_delft3d/java/src/org/openda/model_delft3d/NetcdfD3dMapDataObject.java b/model_delft3d/java/src/org/openda/model_delft3d/NetcdfD3dMapDataObject.java
index ba3866494..ed7a3f12e 100644
--- a/model_delft3d/java/src/org/openda/model_delft3d/NetcdfD3dMapDataObject.java
+++ b/model_delft3d/java/src/org/openda/model_delft3d/NetcdfD3dMapDataObject.java
@@ -22,9 +22,11 @@
import org.openda.exchange.TimeInfo;
import org.openda.exchange.dataobjects.NetcdfUtils;
import org.openda.interfaces.*;
+import ucar.ma2.DataType;
import ucar.nc2.Dimension;
import ucar.nc2.NetcdfFile;
-import ucar.nc2.NetcdfFileWriter;
+import ucar.nc2.dataset.NetcdfDatasets;
+import ucar.nc2.write.NetcdfFormatWriter;
import ucar.nc2.Variable;
import java.io.File;
@@ -78,7 +80,7 @@ public void initialize(File workingDir, String[] arguments) {
this.runID = arguments[0].substring(5,arguments[0].length()-3);
try {
- netcdfFile = NetcdfFile.open(netcdfFilePath.getAbsolutePath());
+ netcdfFile = NetcdfDatasets.openFile(netcdfFilePath.getAbsolutePath(), new NetcdfUtils.MyCancelTask());
} catch (IOException e) {
throw new RuntimeException("NetcdfD3dMapDataObject could not open netcdf file " + netcdfFilePath.getAbsolutePath());
}
@@ -184,7 +186,7 @@ private void readNetCdfVariables() {
throw new RuntimeException("NetcdfD3dMapDataObject could not read time variable " + timeVariable.getShortName() +
"from netcdf file " + netcdfFile.getLocation());
}
- timesInNetcdfFile = (double[]) timesArray.get1DJavaArray(double.class);
+ timesInNetcdfFile = (double[]) timesArray.get1DJavaArray(DataType.DOUBLE);
}
// get the number of spatial dimensions
@@ -268,12 +270,14 @@ public double[] getExchangeItemValues(String varName) {
// find variable
Variable variable = this.netcdfFile.findVariable(varName);
+ assert variable != null;
int[] origin = createOrigin(variable);
int[] sizeArray = variable.getShape();
//select whole 2D or 3D for last time step. Due to huge sizes if we read all time steps I decided for now to keep only the necessary
ITimeInfo timeInfo = NetcdfUtils.createTimeInfo(variable, this.netcdfFile, timeInfoCache);
+ assert timeInfo != null;
int LastTimeIndex = timeInfo.getTimes().length;
origin[timeDimensionIndex] = LastTimeIndex-1;
sizeArray[timeDimensionIndex] = 1;
@@ -401,18 +405,18 @@ public void writeExchangeItemValues(String varName, double[] values) {
// origin[kmaxOutRestrDimensionIndex] = 0;
//}
- NetcdfFileWriter netcdfFileWriter= null;
+ NetcdfFormatWriter NetcdfFormatWriter= null;
try {
- netcdfFileWriter = NetcdfFileWriter.openExisting(this.netcdfFilePath.getAbsolutePath());
+ NetcdfFormatWriter = NetcdfFormatWriter.openExisting(this.netcdfFilePath.getAbsolutePath()).build();
} catch (IOException e) {
e.printStackTrace();
}
- NetcdfUtils.writeSelectedData(netcdfFileWriter,variable, origin, sizeArray, values);
+ NetcdfUtils.writeSelectedData(NetcdfFormatWriter,variable, origin, sizeArray, values);
try {
- netcdfFileWriter.close();
+ NetcdfFormatWriter.close();
//if (binRestartFile != null) {
//binRestartFile.close();
//}
@@ -483,7 +487,7 @@ public double[] back2RealDomain(double[] expandedDomain, int LastTimeIndex) {
private double[][][] from1dTo3dArray(double[] oneDArray){
- double Domain3D[][][] = new double[mMax][nMax][nLay];
+ double[][][] Domain3D = new double[mMax][nMax][nLay];
int k=0;
for (int lay = 0; lay < nLay; lay++) {
diff --git a/model_delft3d/java/test/org/openda/model_delft3d/NetcdfD3dMapDataObjectTest.java b/model_delft3d/java/test/org/openda/model_delft3d/NetcdfD3dMapDataObjectTest.java
index ee4119023..5bc9222d8 100644
--- a/model_delft3d/java/test/org/openda/model_delft3d/NetcdfD3dMapDataObjectTest.java
+++ b/model_delft3d/java/test/org/openda/model_delft3d/NetcdfD3dMapDataObjectTest.java
@@ -33,7 +33,7 @@ public void testReadGrid() {
System.out.println(Arrays.toString(exchangeItemIDs));
assertEquals("#exchange items", 4, exchangeItemIDs.length);
IExchangeItem exchangeItem = netcdfFile.getDataObjectExchangeItem(exchangeItemIDs[exchangeItemID]);
- assertFalse(exchangeItem == null);
+ assertNotNull(exchangeItem);
double[] exchangeItemValues = exchangeItem.getValuesAsDoubles();
diff --git a/model_dflowfm_blackbox/java/src/org/openda/model_dflowfm/DFlowFMRestartFileWrapper.java b/model_dflowfm_blackbox/java/src/org/openda/model_dflowfm/DFlowFMRestartFileWrapper.java
index 87806d06d..2c99d0e97 100644
--- a/model_dflowfm_blackbox/java/src/org/openda/model_dflowfm/DFlowFMRestartFileWrapper.java
+++ b/model_dflowfm_blackbox/java/src/org/openda/model_dflowfm/DFlowFMRestartFileWrapper.java
@@ -30,7 +30,12 @@
import ucar.ma2.Array;
import ucar.ma2.DataType;
import ucar.ma2.InvalidRangeException;
-import ucar.nc2.*;
+import ucar.nc2.NetcdfFile;
+import ucar.nc2.Attribute;
+import ucar.nc2.Variable;
+import ucar.nc2.dataset.NetcdfDatasets;
+import ucar.nc2.write.NetcdfFileFormat;
+import ucar.nc2.write.NetcdfFormatWriter;
import java.io.File;
import java.io.IOException;
@@ -67,7 +72,7 @@ private class DFlowFMMetaExchangeItem{
int time_index = 0;
String netcdffileName = null;
HashMap ExchangeItems = new LinkedHashMap();
-
+ NetcdfFileFormat netcdfFormat = NetcdfFileFormat.NETCDF3;
/**
* Initialize.
@@ -92,6 +97,9 @@ public void initialize(File workingDir, String[] arguments) {
case EXCHANGE_ITEM_ID_POST_FIX:
exchangeItemIdPostFix = value;
continue;
+ case NetcdfUtils.NETCDF_FORMAT:
+ this.netcdfFormat = NetcdfFileFormat.valueOf(value);
+ continue;
default:
throw new RuntimeException("Unknown key " + key + ". Please specify only " + EXCHANGE_ITEM_ID_POST_FIX + " as key=value pair");
}
@@ -102,7 +110,7 @@ public void initialize(File workingDir, String[] arguments) {
try{
File fileNameFull = getNetcdfFile(workingDir);
netcdffileName = fileNameFull.getAbsolutePath();
- inputFile = NetcdfFile.open(netcdffileName, null);
+ inputFile = NetcdfDatasets.openFile(netcdffileName, new NetcdfUtils.MyCancelTask());
} catch (Exception e) {
throw new RuntimeException("DFlowFMRestartFileWrapper: problem opening file "+ this.fileName + " due to " + e.getMessage(), e);
}
@@ -325,8 +333,10 @@ public IExchangeItem getDataObjectExchangeItem(String ExchangeItemID) {
// Write the NetCDF restart file
public void finish() {
try {
- NetcdfFileWriter netcdfFileWriter= NetcdfFileWriter.openExisting(netcdffileName);
- netcdfFileWriter.setFill(true);
+ NetcdfFormatWriter.Builder NetcdfBuilder= NetcdfFormatWriter.openExisting(netcdffileName);
+ NetcdfBuilder.setFormat(this.netcdfFormat);
+ NetcdfBuilder.setFill(true);
+ NetcdfFormatWriter NetcdfWriter = NetcdfBuilder.build();
//Loop over all exchangeItems
Set keys = this.ExchangeItems.keySet();
@@ -351,9 +361,9 @@ public void finish() {
for (int i=0; i
+rem set DFLOWFMDIR=
+rem or create an environment variable %DFLOWFMDIR%
+if "%DFLOWFMDIR%"=="" goto error_not_defined
+
+set dimr="%DFLOWFMDIR%\x64\bin\run_dimr.bat"
+rem
+rem check if dimr is available
+rem
+if not exist %dimr% goto error_dimr_not_found
+
+rem
+rem start DIMR for D-Flow FM
+rem
+%dimr% %1
+goto eof
+
+rem
+rem error messages
+rem
+
+:error_not_defined
+echo ERROR in ./stochModel/bin/start_dimr.bat:
+echo No installation directory of D-Flow FM specified.
+goto eof
+
+:error_dimr_not_found
+echo ERROR in ./stochModel/bin/start_dimr.bat:
+echo File not found: %dimr%
+goto eof
+
+:eof
+exit /B %ERRORLEVEL%
diff --git a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/dflowfmModel.xml b/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/dflowfmModel.xml
index aaee43218..bbe0d9cb1 100644
--- a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/dflowfmModel.xml
+++ b/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/dflowfmModel.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/dflowfmWrapper.xml b/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/dflowfmWrapper.xml
index 39c7354a3..aac03089b 100644
--- a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/dflowfmWrapper.xml
+++ b/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/dflowfmWrapper.xml
@@ -2,76 +2,70 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- %dimrconfigfile%
-
-
-
-
- runId=%runid%
- sourceRestartFileSubDir=%outputDir%
- targetRestartFileNamePostFix=00000000_000000_rst.nc
- deleteOlderRstFiles=true
-
-
- %concatenated_hisfile%
- %outputDir%/%hisfile%
-
-
- %concatenated_mapfile%
- %outputDir%/%mapfile%
-
-
-
-
-
-
-
- %mdufile%
- mdufile
- useRstForRestart=true
-
-
- %rstfile%
- rstfile
-
-
- %outputDir%/%hisfile%
- hisfile
- true
- false
- stationDimensionVarName=station
-
-
- %meteofile_p%
- meteofile_p
- true
- false
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %dimrconfigfile%
+
+
+
+
+ runId=%runid%
+ sourceRestartFileSubDir=%outputDir%
+ targetRestartFileNamePostFix=00000000_000000_rst.nc
+ deleteOlderRstFiles=true
+
+
+
+
+
+
+
+ %mdufile%
+ mdufile
+ useRstForRestart=true
+
+
+ %rstfile%
+ rstfile
+
+
+ %outputDir%/%hisfile%
+ hisfile
+ true
+ false
+ ncformat=NETCDF4
+ stationDimensionVarName=station
+
+
+ %meteofile_p%
+ meteofile_p
+ true
+ false
+ ncformat=NETCDF4
+
+
diff --git a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/input_dflowfm/dcsmv5_00000000_000000_rst.nc b/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/input_dflowfm/dcsmv5_00000000_000000_rst.nc
index 036a149c0..ab7122f29 100644
Binary files a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/input_dflowfm/dcsmv5_00000000_000000_rst.nc and b/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/input_dflowfm/dcsmv5_00000000_000000_rst.nc differ
diff --git a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/input_dflowfm/unstruc.dia b/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/input_dflowfm/unstruc.dia
deleted file mode 100644
index 8bc2194d7..000000000
--- a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst/stochModel/input_dflowfm/unstruc.dia
+++ /dev/null
@@ -1,4 +0,0 @@
-* Deltares, D-Flow FM Version 1.2.105.67088, Jun 18 2020, 23:39:47
-* Source: https://svn.oss.deltares.nl/repos/delft3d/trunk/
-* File creation date: 13:57:13, 14-04-2022
-** INFO : Command: /p/d-hydro/dimrset/weekly/2.12.09.67490/lnx64/bin/../bin/dflowfm --nodisplay --autostartstop --autostartstop dcsmv5.init.mdu
diff --git a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst_partitioning/stochModel/input_dflowfm/unstruc.dia b/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst_partitioning/stochModel/input_dflowfm/unstruc.dia
deleted file mode 100644
index 8bc2194d7..000000000
--- a/model_dflowfm_blackbox/tests/dcsmv5_kalman_rst_partitioning/stochModel/input_dflowfm/unstruc.dia
+++ /dev/null
@@ -1,4 +0,0 @@
-* Deltares, D-Flow FM Version 1.2.105.67088, Jun 18 2020, 23:39:47
-* Source: https://svn.oss.deltares.nl/repos/delft3d/trunk/
-* File creation date: 13:57:13, 14-04-2022
-** INFO : Command: /p/d-hydro/dimrset/weekly/2.12.09.67490/lnx64/bin/../bin/dflowfm --nodisplay --autostartstop --autostartstop dcsmv5.init.mdu
diff --git a/openda.ipr b/openda.ipr
index 09af9d886..d7ee3eb01 100644
--- a/openda.ipr
+++ b/openda.ipr
@@ -489,9 +489,9 @@
-
+