Reading netCDF (NUWG) file with Plain object

I am accessing netCDF files basically with code below, this works but
doesn't seem efficient. I then set that 2D array (temp_arr) to a
FlatField samples. Is this the best way to read a netCDF file?

int NX = 125;
int NY = 125;
NetcdfFile nc = new NetcdfFile("C:\\grnd.nc", true);
float[][] temp_arr = new float[1][NX*NY];
for (int x=0; x<NX; x++) {
        for (int y=0; y<NY; y++) {
                int index[] = {0,0,y,x};
                temp_arr[0][x*NX + y] = nc.get("rh").getFloat(index);}
        }
}
nc.close();

But I am not sure if that is the most efficient way, I see many examples
of access with objects like the Plain object, but when I use that object
I get errors. Does this mean my netCDF file is not of the right format?

**********************************************************
CODE: 
**********************************************************

public class VerySimple {
   public static void main(String args[])throws Exception{

    //---create a netCDF reader---//
    Plain myPlain = new Plain();

    //---read an image sequence from a netCDF into a data object---//
    DataImpl myDataImpl = myPlain.open("C:\\grnd.nc");
  }
}

**********************************************************
ERRORS:
**********************************************************

Unknown netCDF conventions attribute (NUWG).  Using default view...
Couldn't decode unit attribute (/second) of variable "vor": Encountered
"/" at line 1, column 1.
Was expecting one of:
    <EOF> 
    <INTEGER> ...
    <REAL> ...
    <NAME> ...
    "." ...
    "(" ...
    
Couldn't decode unit attribute (grams/kikogram) of variable "mr": Unit
not in database
Couldn't decode unit attribute (/second) of variable "div": Encountered
"/" at line 1, column 1.
Was expecting one of:
    <EOF> 
    <INTEGER> ...
    <REAL> ...
    <NAME> ...
    "." ...
    "(" ...
    
Couldn't decode unit attribute (none) of variable "fwx": Unit not in
database
Couldn't decode unit attribute (none) of variable "hi": Unit not in
database



  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: