Re: [netcdf-java] Help Calling Java from Matlab

Hi All -

It seems that various people are now using a Matlab interface to the Java
library to create NetCDF files. Is there updated documentation on how to
do this, or is this 2007 email thread the last word on the subject?

The Unidata documentation still implies that Matlab->Java-NetCDF is
read-only, unless I'm looking in the wrong part of the site.

This may be a moot point soon, with the new version of Matlab supporting
NetCDF, but we seem to be a long way from acquiring a site license for
that here at WHOI.

Thanks -
Nan

Steve Loch wrote:
At BODC we use Matlab and Java in combination although we tend to use the 
former for data processing and the latter for visualisation.

1) It may be worth mentioning that there is a NetCDF toolbox which uses MEX 
files. So this is the non-Java way to write NetCDF from Matlab. See the Unidata 
web site.

Sticking with the Java approach.
2) Minor point but rather than tweaking the classpath use the dynamic javaaddpath. 3) The manual looks to be out of date because I remember converting ArrayAbstract to Array very recently. The code we use to write variables in Java looks like this.

          String chanam  =  ch.getChannelName(true);  // variable name

           switch(ch.getType()){
           case 'I':
             aa  =  Array.factory(int.class, ch.getShape(),     // getShape is 
the array of Dimensions
                     ch.getDataInt());                                        
// The data array
             break;
           case 'D':
             aa  =  Array.factory(double.class, ch.getShape(),
                      ch.getDataDouble(false));
             break;
           case 'F':
             aa  =  Array.factory(float.class, ch.getShape(),
                     ch.getDataFloat(false));
             break;
           default: throw new RuntimeException("Unrecognised type");
           }
        qxffile.write(chanam,aa); //qxffile will be the NetcdfFileWriteable

This can be carried over to Matlab very easily.

Steve Loch.
BODC

"Rich Signell" <rsignell@xxxxxxxx> 09/07/2007 15:50 >>>
Roger,

I haven't tried to write files from Matlab using NetCDF Java, but here
is an example of a Matlab using some of the higher level functionality
within NetCDF-Java to access and plot an isosurface from a 3D
dimensionless vertical coordinate ocean model:

http://stellwagen.er.usgs.gov/rps/share/java_isosurface_demo2.m
If you follow the instructions carefully at the top of the m-file to
download the .jar file and edit the classpath, it should just work for
you, as it accesses the model data via OpenDAP, which is supported by
NetCDF-Java.

Let me know if it doesn't work.

-Rich

On 7/9/07, Roger GALLOU (AGO) <roger.gallou@xxxxxx> wrote:
Hello,

I hope I'm on the good users list.
I'm working  with Matlab R2006b on Windows. I 'm intesresting by the
NetCDF Java package to access to data files for read and write.
I've found some examples, I try on Matlab, in the document : NetCDF Java
Users' Manuel (page 33-34).

I need some help to call some classes of the librairy nc2.2.jar,
particulary for writing files :
all the classes type ArrayInt (Double, ...) for dimensions D1, D2, D3 ...

I success to manage dimension, attribut, but I don't manage to create a
array of data for any dimension I know.
In Matlab, the instruction :
ucar.ma2.ArrayInt.D3(2, latDim.getLength(), lonDim.getLength()) answers
that the method D3 doesn't exist.
I can't call with the "$" character as it is declared in the package
ucar.ma2.
(ex : ArrayInt$D1).

Is there anybody who have encounter this king of problem ? If yes, could
he/she bring me some help ?
In extension, if anybody has some informations for writing NetCDF files
with Java librairies in Matlab, I'm interesting.

Thanks by advance.

Roger GALLOU
roger.gallou@xxxxxx 02 98 05 43 21 (FRANCE)



===============================================================================
To unsubscribe netcdf-java, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html ===============================================================================





--
*******************************************************
* Nan Galbraith                        (508) 289-2444 *
* Upper Ocean Processes Group            Mail Stop 29 *
* Woods Hole Oceanographic Institution                *
* Woods Hole, MA 02543                                *
*******************************************************





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