I'm trying to resample a field using a new set of times (my domain is
time). Here's what I'm trying to do:
//f is a FieldImpl loaded from a netCDF file.
Tuple fTuple = (Tuple)f.getSample(0);
int cols = fTuple.getDimension(); //get number of columns
//f.getDomainSet().getType().toString() gives "Set(Time)"
//time is an array [1][3] of floats
Gridded1DSet newSet = new Gridded1DSet(f.getDomainSet().getType(), time,
time[0].length);
FlatField subField = new FlatField((FunctionType)f.getType(), newSet);
//printing the FunctionType gives "(Real): (Time) -> (MinTemp,MaxTemp)"
float[][] dataArray = new float[cols][time[0].length];
//fill in dataArray here - the test data is below
//Col: 0 Row: 0 Value: 32.0
//Col: 0 Row: 1 Value: NaN
//Col: 0 Row: 2 Value: NaN
//Col: 1 Row: 0 Value: NaN
//Col: 1 Row: 1 Value: NaN
//Col: 1 Row: 2 Value: NaN
//it works up to here
subField.setSamples(dataArray); //this is where it CRASHES
//error message below:
visad.FieldException: setSamples: bad array length
at visad.FlatField.setSamples(FlatField.java:709)
at visad.FlatField.setSamples(FlatField.java:654)
at
au.gov.bom.aifs.autotaf.DataRepresentation.FieldManipulation.resample(FieldManipulation.java:521)
at progTest.main(progTest.java:28)
//printing out the length of dataArray gives rows: 3 cols: 2
//subField.getLength() gives 3
//subField.getRangeDimension() gives 2
Can someone please tell me what I'm doing wrong? It keeps crashing
whenever I try to setSamples but when I check the length of everything,
it looks right.
One thing I noticed was that if at least one of the values in Col: 1 is
not NaN, then it works. Is there a way to setSamples without crashing out
if everything is a NaN?
Thanks.
Eug.
_--_|\ Eugene Tan <E.Tan@xxxxxxxxxx>
/ \ AutoTAF Project Developer
\_.--.*/ Bureau of Meteorology, Melbourne, VIC 3001, Australia
v Telephone: +613 9669 4652