How to set values on a time depended FeatureCoverage with a NetCfd store?

If you want to store the values of your feature coverage to NetCdf and you have more then 2 arguments, you usually get the following error "NetCDF currently supports only 1 unlimited dimension".
This is because you should predefine the limit of all arguments except one (usually time)

The following code shows you how to limit your argument (in this case FeatureVariable)

Code to initialize a the time depended FeatureCoverage
var featureCoverage = new FeatureCoverage();

// If you have loaded the NetCfd plugin then this will be done automatically
var store = new NetCdfFunctionStore();
store.CreateNew("TestName.nc");
store.Functions.Add(featureCoverage);

// the data for one time step
var timeStep1 = DateTime.Now;
var valueDictionary = new Dictionary<IFeature, double>{{new Feature(), 1.1},{new Feature, 2.2}};

// Set FixedSize and FeatureVariable values (Normally during Initialization of a model)
featureCoverage.FeatureVariable.FixedSize = valueDictionary.Keys.Count();
featureCoverage.FeatureVariable.SetValues(valueDictionary.Keys);

// Set all values for one time step (Normally during Execute of a model)
// When setting the time step values, it is important to set them in the same sequence as they are declared in FeatureVariable
featureCoverage[timeStep1] = valueDictionary.Values;
  • No labels