iousprafa / nctoolbox

Automatically exported from code.google.com/p/nctoolbox
0 stars 0 forks source link

Java Exception #60

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a NetCDF file using the matlab commands nccreate, ncwrite and 
ncwriteatt for between 1 and 6 variables

2. Connect to data set using ncgeodataset (object name = nc)

3. The commands (using the 'time' variable as an example) nc.attributes('time') 
or value4key(nc.attributes('time'),'units') yield the error message below for 
all variables EXCEPT the last variable written to the file

4. Only the attributes are affected, variable data can always be retrieved

What is the expected output? What do you see instead?

Error using ucar.ma2.ArrayInt$D0/copyToNDJavaArray
Java exception occurred:
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
    at ucar.ma2.Array.copyToNDJavaArray(Array.java:770)
Caused by: java.lang.IllegalArgumentException
    at java.lang.reflect.Array.multiNewArray(Native Method)
    at java.lang.reflect.Array.newInstance(Array.java:90)
    at ucar.ma2.Array.copyToNDJavaArray(Array.java:768)

Error in ncdataset/attributes (line 269)
                        a{i, 2} = at.getValues().copyToNDJavaArray();

Error in ncgeodataset/subsref (line 378)
                            B = builtin('subsref',obj,g);

What version of the product are you using? On what operating system?
Mac 10.7.5
MATLAB Version 7.13.0.564 (R2011b)
Java 1.6.0_37-b06-434-11M3909

Please provide any additional information below.

Original issue reported on code.google.com by barnett....@gmail.com on 11 Feb 2013 at 4:25

GoogleCodeExporter commented 8 years ago
Can you attach a sample netcdf file that causes this error?

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 4:32

GoogleCodeExporter commented 8 years ago
Attached is a file, as requested. The 'time' variable was the last one written 
to the file.

Original comment by barnett....@gmail.com on 11 Feb 2013 at 4:35

Attachments:

GoogleCodeExporter commented 8 years ago
For my reference, Here's the CDL for the attached file:

netcdf /Users/brian/Downloads/Canada_DAILY_EASE-F13-NL2000.37 {
 dimensions:
   Y = 212;
   T = 366;
   X = 401;
 variables:
   double time(T=366);
     :units = "hours since 2000-01-01 00:00:00 00:00";
     :standard_name = "time";
     :long_name = "time";
     :_FillValue = -1000000.0; // double
     :_CoordinateAxisType = "Time";
   double longitude(X=401, Y=212);
     :_Netcdf4Dimid = 1; // int
     :units = "degrees_east";
     :standard_name = "longitude";
     :long_name = "longitude";
     :_FillValue = -1000000.0; // double
     :_CoordinateAxisType = "Lon";
   double latitude(X=401, Y=212);
     :_Netcdf4Dimid = 1; // int
     :units = "degrees_north";
     :standard_name = "latitude";
     :long_name = "latitude";
     :_FillValue = -1000000.0; // double
     :_CoordinateAxisType = "Lat";
}

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 4:40

GoogleCodeExporter commented 8 years ago
I executed the following on :
Mac OS X 10.8.2
Matlab version 8.0.0.783 (R2012b)
Java 1.6.0_37-b06-434-11M3909 with Apple Inc. Java HotSpot(TM) 64-Bit Server VM 
mixed mode
nctoolbox version: HEAD (694674eae0) from https://github.com/nctoolbox/nctoolbox

>> n = ncgeodataset('/Users/brian/Downloads/Canada_DAILY_EASE-F13-NL2000.37')

n = 

  ncgeodataset handle

  Properties:
     location: '/Users/brian/Downloads/Canada_DAILY_EASE-F13-NL2000.37'
       netcdf: [1x1 ucar.nc2.dataset.NetcdfDataset]
    variables: {3x1 cell}

  Methods, Events, Superclasses

>> n.attributes('time')

ans = 

    'units'                  'hours since 2000-01-01 00:00:00 00:00'
    'standard_name'          'time'                                 
    'long_name'              'time'                                 
    '_FillValue'             [                             -1000000]
    '_CoordinateAxisType'    'Time'

>> value4key(n.attributes('time'),'units')

ans =

hours since 2000-01-01 00:00:00 00:00

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 4:45

GoogleCodeExporter commented 8 years ago
Yes, the time variable was the last one written to the file, so it also gives 
the proper response on my system (as in step 3 above). However, the latitude 
and longitude variables give the error message. Is it the same for you?

Original comment by barnett....@gmail.com on 11 Feb 2013 at 4:48

GoogleCodeExporter commented 8 years ago
Hmmm, I can't duplicate the issue. I don't know how recent your version of 
nctoolbox is. The first thing you could do is get the latest from 
https://github.com/nctoolbox/nctoolbox/tags and see if that makes the problem 
go away. If it doesn't address the issue let me know.

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 4:50

GoogleCodeExporter commented 8 years ago
OK, yes, I can duplicate it with 'latitude' and 'longitude'. 

>> n.attributes('latitude')
Error using ncdataset/attributes (line 269)
Java exception occurred:
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
    at ucar.ma2.Array.copyToNDJavaArray(Array.java:770)
Caused by: java.lang.IllegalArgumentException
    at java.lang.reflect.Array.multiNewArray(Native Method)
    at java.lang.reflect.Array.newInstance(Array.java:90)
    at ucar.ma2.Array.copyToNDJavaArray(Array.java:768)

Error in ncgeodataset/subsref (line 378)
                            B = builtin('subsref',obj,g);

>> n.attributes('longitude')
Error using ncdataset/attributes (line 269)
Java exception occurred:
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
    at ucar.ma2.Array.copyToNDJavaArray(Array.java:770)
Caused by: java.lang.IllegalArgumentException
    at java.lang.reflect.Array.multiNewArray(Native Method)
    at java.lang.reflect.Array.newInstance(Array.java:90)
    at ucar.ma2.Array.copyToNDJavaArray(Array.java:768)

Error in ncgeodataset/subsref (line 378)
                            B = builtin('subsref',obj,g);

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 4:52

GoogleCodeExporter commented 8 years ago
OK, I found what's going on. Give me a little bit to fix it.

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 4:55

GoogleCodeExporter commented 8 years ago
OK, I posted a bug fix for you. You can download nctoolbox-20130211 from 
https://github.com/nctoolbox/nctoolbox/tags

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 5:07

GoogleCodeExporter commented 8 years ago
fixed

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 5:10

GoogleCodeExporter commented 8 years ago
Code fix can be viewed at 
https://github.com/nctoolbox/nctoolbox/commit/003c68761e8bb0e085fd0b9d77ed41f2e6
9ff3d0

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 5:11

GoogleCodeExporter commented 8 years ago
Thank you very much!

Original comment by barnett....@gmail.com on 11 Feb 2013 at 5:12

GoogleCodeExporter commented 8 years ago
You're welcome!

Original comment by bschlin...@gmail.com on 11 Feb 2013 at 5:14