Hello.
Mostly I am working with an H4 file which already has many Datasets.
I create a copy of a Dataset with a new name or put it in a different group and I update the new dataset with new data.
I have no trouble doing this no matter how many dimensions the dataset has.
When I try to update an existing (one I did not create) 2 dimensional dataset I also have no trouble.
When I try to update an existing (one I did not create) 3 dimensional dataset I can't seem to write to it at all.
any idea what I might be doing incorrectly?
My code is: (this code works on 3D datasets I create but not on ones I don't)
private void ApplyMask(Dataset data, Dataset mask, HashMap dimtype) throws Exception
{
int[] dims = (int[]) dimtype.get("dims") ;
float fill = this.getFillValue(data);
...
else if (data.getRank() == 3) {
long maskstart[] = mask.getStartDims();
long datastart[] = data.getStartDims();
int x,y;
for (int layer = 0; layer < dims[2]; ++layer) {
maskstart[2] = layer ;
datastart[2] = layer ;
float[] dataRead = (float[]) data.read();
float[] maskRead = (float[]) mask.read();
for (int col = 0; col < dims[0] ; col++) {
for (int row = 0; row < dims[1] ; row++) {
x = col * dims[1] + row;
if (maskRead[x] == 1 /* mask positive value */) {
// leave the value there.
// This confirmed that we were writing values to upper layers: dataRead[x] = 44;
}
else { /* mask negative value */
if (dataRead[x] != fill ) {
dataRead[x] = fill;
}
}
}
}
*data.write(dataRead); // this is what seems to fail - as if the permissions on the dataset if such a thing exists are not set properly.*
}
}
Debug statements in the code (left out here) confirm that up until the data.write() dataRead contains desired values.