[netcdf-java] java.io.EOFException in at ucar.unidata.io.RandomAccessFile.readShort(RandomAccessFile.java:1019)

Hi everyone,
i'm new to netcdf. I've read this is a generic ml in which one can post problems. This is a problem with the use of the method "public float[] readData(RandomAccessFile raf) throws IOException" of "ucar.nc2.grib.grib1.Grib1Record".

I have this simple method for records debug:

private void recordsDebug(List<Grib1Record> grib1Records, Formatter f){
        if(grib1Records!=null){
            if(grib1Records.size()!=0){
                f.format("%s%n", "size: "+grib1Records.size()+"\n");

                for (Grib1Record grib1Record : grib1Records) {

                    ucar.unidata.io.RandomAccessFile raf = null;
                    try {
raf = new ucar.unidata.io.RandomAccessFile(fileName, "r");
raf.order(ucar.unidata.io.RandomAccessFile.LITTLE_ENDIAN);
                        float values[] = grib1Record.readData(raf);
                        for (float value: values){
                            f.format("%f%n", value);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    } finally {
                        if (raf != null)
                            try {
                                raf.close();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                    }

                }
            }
            else {
                f.format("%s%n",  "size: "+grib1Records.size()+"\n");
            }
        }
        else {
            f.format("%s%n", "No records!\n");
        }
    }

This method gives me EOFException:

java.io.EOFException
at ucar.unidata.io.RandomAccessFile.readShort(RandomAccessFile.java:1019) at ucar.nc2.grib.grib1.Grib1SectionBitMap.getBitmap(Grib1SectionBitMap.java:83)
    at ucar.nc2.grib.grib1.Grib1Record.readData(Grib1Record.java:149)
    at it.next.easy.services.meteo.GribDecoder.recordsDebug

The file i'm trying to read is a grib-1 file, and i actually can read it with ToolsUI. The file contains only two variables:

(50) v-component of current
and (49) u-component of current

and ToolsUI detect many 'Nan'-values when i try to read variable values in
Iosp->GRIB1->GRIB1Collection->Grib1Record(Panel)->ShowData(Option).

If it does some difference, the GRIB1-file i'm taking about is called "<something><suffix>.grib" where suffix is: 2013092600_t000 and the parameters section contains a reference time of "2013-09-26T00:00:00Z" with a list containing only one TimeCoord:

//result of timecoord.tostring

timeCoord: type=integers timeUnit=1 Hour runDate= 2013-09-26T00:00:00Z
    3,  units (1 Hour) since 2013-09-26T00:00:00Z

From these symptoms, can i argue that this file is corrupted?

Thank you for your kind indications,

Teresa Noviello



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