Re: no coordinate systems/axis in netcdf file - help

Mark Rehbein wrote:

Hi John,

I have noticed that you are actively working on the API as I have seen the
javadoc change on GridCoordSys in the last few hours. I have since
downloaded the library again, as I was using this class for my program.

yes, Im trying to get a stable version out. sorry for the changes.


I have made some progress but have a question and wish to report a
bug/problem.

My question is:

How do I easily convert a java.util.Date to an array index on the time
axis? There is a method  GridCoordSys.findXYCoordElement(double, double,
int[]) which handles converting latitude and longitude to array indexes
and I think it would be useful to have an equivalent for the time axis.

how about:

 /**
* Given a Date, find the corresponding time index on the time coordinate axis.
  * Can only call this is hasDate() is true.
  * This will return
  * <ul>
  *  <li> i, if time(i) <= d < time(i+1).
  *  <li> -1, if d < time(0)
  *  <li> n-1, if d > time(n-1),  where n is length of time coordinates
  * </ul>
  *
  * @param d date to look for
  * @param corresponding time index on the time coordinate axis
  * @throws UnsupportedOperationException is no time axis or isDate() false
  */
 public int findTimeCoordElement(Date d) ;



The bug or problem that I have discovered is a negative seek offset error
as shown below:

<error>

java.io.IOException: Negative seek offset
       at java.io.RandomAccessFile.seek(Native Method)
       at ucar.netcdf.RandomAccessFile.read_(RandomAccessFile.java:508)
       at ucar.netcdf.RandomAccessFile.seek(RandomAccessFile.java:350)
       at
ucar.netcdf.NetcdfFile$V1FloatIo.readArray(NetcdfFile.java:1447)
       at ucar.netcdf.NetcdfFile$V1Io.copyout(NetcdfFile.java:896)
       at ucar.netcdf.Variable.copyout(Variable.java:276)
       at ucar.nc2.Variable.read(Variable.java:184)
       at ucar.nc2.dataset.VariableDS.read(VariableDS.java:334)
       at
aims.app.science.biodiv.sstAtlas.ImageLibrary.readData(ImageLibrary.java:166)
       at
aims.app.science.biodiv.sstAtlas.ImageLibrary.main(ImageLibrary.java:423)
done!

</error>

I have appended the method I have written below for your convenience, if
needed. The method works fine when I use:

latitude= -7.0 and longitude= 157.99
latitude= -27.0 and longitude= 157.99
latitude= -27.0 and longitude= 142.00
latitude= -7.0 and longitude= 142.00

but it throws the above error when using lat= -19.6 and lon= 150.5
which are coordinates within the bounds of coordinates which work!

i assume you found this problem


I have noticed that the *bottom* *left* corner of my images (in lat,lon
coordinates) represents 0,0 in array index coordinates. I would have
expected that the *top* *left* corner of my images (in lat,lon
coordinates) would be represented by 0,0 in array index coordinates.

latitudes are stored both ways: north to south ans south to north.

I am going to add a routine to normalize this in GeoGrid, havent figured out the API yet.



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