[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 980626: NetCDF for Java



>     Thank you very much for making the newer version of the
> NetCDF package available.  The RemoteNetCDF class alone will save me much
> time and effort.

You are welcome.

>         I was wondering if I could ask you a question.  I'm
> eventually trying to write an applet that will read and plot data from a
> NetCDF file, but at the moment I'm not not having any success figuring
> out how to grab data from the NetCDF file. Here is one of the variables
> called Power:
>
> dimensions:
>         Time = UNLIMITED ; // (1486 currently)
>         Channels = 2 ;
>         Heights = 192 ;
> variables:
>         float Power(Time, Heights, Channels) ;
>                 Power:TITLE = "Power" ;
>
> How would I go about fetching pieces of data, say Power(23, 14, 1)

        Netcdf nc = new NetcdfFile(Myfile, true);
        Variable p = nc.get("Power");
        int [] index = {23, 14, 1}
        float value = p.getFloat(index);

> and
> also how could I retrieve the Power data for each instant of time for a
> fixed Height and Channel?

There are several ways to do this. The way that would probably be most
familiar to netcdf C or FORTRAN users looks like this ('p' is the Power
variable as above.)

        int nheights = 192; // should be discovered dynamically
        int nchannels = 2;  // should be discovered dynamically
        int [] origin = {time_index, 0, 0};
        int [] shape =  {1, nheights, nchannels};
        MultiArray aSlice = p.copyout(origin, shape);