DaniSb170 / nctoolbox

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

methods grid and grid_interop fail for geovariables in this WRF NetCDF output file #52

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
John Wilkin was getting
"No appropriate method, property, or field getAxisType for class
ucar.nc2.dataset.VariableDS." when he tried to access a geovariable from a WRF 
NetCDF file.

I copied one of John Wilkin's files to our THREDDS server to facilitate 
debugging at:
http://geoport.whoi.edu/thredds/catalog/usgs/data1/rsignell/test/catalog.html?da
taset=usgs/data1/rsignell/test/wrfout_d01_20120617_0000.nc

Yes, NCTOOLBOX does not appear to function correctly on this file
(either downloaded and opened directly, or via OPeNDAP), but
NetCDF-Java (the NetCDF Tools UI 4.3) works okay (see screen grab:
http://screencast.com/t/s07LDTro1W).

So it's not a problem with the dataset, it's a problem with how
NCTOOLBOX is using the NetCDF-java functionality.

Here is a test that fails:

url='http://geoport.whoi.edu/thredds/dodsC/usgs/data1/rsignell/test/wrfout_d01_2
0120617_0000.nc';
nc=ncgeodataset(url);
tvar=nc.geovariable('T2');
t=tvar.data(:);
g=tvar.grid_interop(:);
No appropriate method, property, or field getAxisType for class 
ucar.nc2.dataset.VariableDS.

Error in ncgeovariable/grid_interop (line 148)
                type = char(javaaxisvar.getAxisType());

Error in ncgeovariable/subsref (line 945)
                                    sref = obj.grid_interop(first, last, stride);

>> 

Original issue reported on code.google.com by rsignell on 17 Jun 2012 at 8:33

GoogleCodeExporter commented 8 years ago
*Summary of problem*

line 147 is:
    javaaxisvar  =   src.dataset.netcdf.findVariable(tempname);

findVariable is returning some subtype of uvar.nc2.Variable. However, line 148 
is calling the 'getAxisType()' method, which is only available on one specific 
subtype of Variable called CoordinateAxis. We have no guarantees that the  
getAxisType method is actually present. 

*Solution*

replace line 148 in nctoolbox/cdm/ncgeovariable.m:
    type = char(javaaxisvar.getAxisType());

with:
    try 
         type = char(javaaxisvar.getAxisType());
     catch me
         type = '';
     end

I've changed this in code an will check in the fix. It will be available in the 
next release of nctoolbox. In the meantime, if you need this fix just make the 
change described above.

Original comment by bschlin...@gmail.com on 19 Jun 2012 at 7:53

GoogleCodeExporter commented 8 years ago
This issue was closed by revision b0ceec5f5146.

Original comment by bschlin...@gmail.com on 19 Jun 2012 at 8:01

GoogleCodeExporter commented 8 years ago
No guarantees that the grids that are returned are inter-operable though, is 
that right? 

For some reason netcdf-java cdm isn't considering XLONG or XLAT as 
CoordinateAxis, thats a little odd and worth investigation.

Original comment by crosb...@gmail.com on 19 Jun 2012 at 8:17

GoogleCodeExporter commented 8 years ago
How come the NetCDF-Java ToolsUI 4.3 works fine on this dataset?
Is there a way to see what methods it's using (kind of like a firebug for java, 
or something?)

-Rich

Original comment by rsignell on 19 Jun 2012 at 9:18

GoogleCodeExporter commented 8 years ago
We're still using netcdf-4.2 with nctoolbox. I'm happy to bump up to 4.3 but 
one of y'all will have to go through and test your stuff with it.

Original comment by bschlin...@gmail.com on 19 Jun 2012 at 9:56

GoogleCodeExporter commented 8 years ago
p.s. @rsignell, yes, you can run the ToolsUI using a Java debugger to see the 
execution path. See:

http://www.jetbrains.com/idea/
http://www.eclipse.org/
http://netbeans.org/

Original comment by bschlin...@gmail.com on 19 Jun 2012 at 10:00

GoogleCodeExporter commented 8 years ago
I didn't mean to imply that we needed to go to netcdf-java 4.3 -- this data set 
opens fine in netcdf-java ToolsUI 4.2 as well.  I just meant that we should be 
doing it however ToolsUI is doing it!

Original comment by rsignell on 19 Jun 2012 at 10:43

GoogleCodeExporter commented 8 years ago
Brian,
I reopened this ticket because the grid_interop method is supposed to only 
return coordinate variable names from this list [time z lat lon] no matter what 
the original coordinate names are. 

The example below returns XLONG and XLAT instead of "lon" and "lat".  

I hope this is relatively easy to fix...

>> 
url='http://geoport.whoi.edu/thredds/dodsC/usgs/data1/rsignell/test/wrfout_d01_2
0120617_0000.nc';
nc=ncgeodataset(url);
tvar=nc.geovariable('T2');
t=tvar.data(:);
g=tvar.grid_interop(:);
>> g

g = 

    XLONG: [1x350x348 single]
     XLAT: [1x350x348 single]
     time: 7.3504e+05

>> 

Original comment by rsignell on 20 Jun 2012 at 2:21

GoogleCodeExporter commented 8 years ago
Ill take over. 

Grid_interop is doing as expected because XLONG and XLAT arn't recognized by 
the way we interact with the cdm as being CoordinateAxis. Grid_interop returns 
all coordinate variables and only renames the ones that the cdm identifies as 
being coordinate axes of certain types (depths/elevation/lat/lon/time/etc). We 
need to take a look at how toolsUI is doing it, its a tricky dataset.

Original comment by crosb...@gmail.com on 20 Jun 2012 at 3:17

GoogleCodeExporter commented 8 years ago
I can't quite seem to figure out how to do this. Is there a good resource I 
could use to figure it out, my standard google techniques are failing me.

>p.s. @rsignell, yes, you can run the ToolsUI using a Java debugger to see the 
>execution path. See:
>
>http://www.jetbrains.com/idea/
>http://www.eclipse.org/
>http://netbeans.org/

Original comment by crosb...@gmail.com on 21 Jun 2012 at 6:26

GoogleCodeExporter commented 8 years ago
Do you mean you couldn't figure out how to use one of the tools Brian listed to 
diagnose what routines ToolsUI is using?

Original comment by rsignell on 21 Jun 2012 at 6:58

GoogleCodeExporter commented 8 years ago
Yes, i have eclipse and netbeans, but I have no idea how to attach a jar to it. 
If i had the source i could create a project and run the main method, but i 
feel like thats not what Brian meant.

Original comment by crosb...@gmail.com on 21 Jun 2012 at 7:01

GoogleCodeExporter commented 8 years ago
Are we stuck here?  Brian, can you help Alex figure out how to attach a jar to 
either eclipse or netbeans so he can figure out what ToolsUI is doing to handle 
this dataset?

Original comment by rsignell on 3 Jul 2012 at 1:40

GoogleCodeExporter commented 8 years ago
Yes stuck

Original comment by crosb...@gmail.com on 3 Jul 2012 at 1:42

GoogleCodeExporter commented 8 years ago
Hey Guys, I can help out on next Monday. I'm on vacation this week.

But yes, Alex, it's probably easiest to just check out the Thredds/NetCDF 
source and run the ToolsUI in a debugger. With the source code you can set some 
break-points and step through code to figure out what's going on.

Original comment by bschlin...@gmail.com on 3 Jul 2012 at 2:51

GoogleCodeExporter commented 8 years ago
Going to try and find time to sort this out this month.

Original comment by crosb...@gmail.com on 7 Jan 2013 at 3:03