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

Re: 19990607: C++ and NetCDF

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.


  • Subject: Re: 19990607: C++ and NetCDF
  • Date: Mon, 07 Jun 1999 11:13:25 -0600

Mazurier,

> To: address@hidden
> From: mazurier <address@hidden>
> Subject: C++ and NetCDF
> Organization: Atlantide
> Keywords: 199906071555.JAA05878

In the above message, you wrote:

> I'am running NetCDF with C++. I would like to extract only a part of
> data from my NetCDF file. using the method  NcBool GET(...)
> 
> Exemple: my variable have 2 dimensions
> 
> 1 1
> 2 2
> 3 3
> 4 4
> 5 5
> 6 6
> 
> I would like to extract the data from the third line to the fith. My
> result
> would be
> 3 3
> 4 4
> 5 5
> 
> I think my question is obvious. Sorry I'am new in NetCDF.
> May be I have to use cursor ? I didn't find a method
> like GET(vals, from, to)?
> 
> Have a good day
> Alain Mazurier
> 
> PS: Sorry for my english, I am a little frenchie

There are two reasonable ways to do this -- both involve using the
NcVar::set_cur() method:

    1.  Use NcVar::get() with explict edge lengths:
    
            var.set_cur(2, 0)
            var::get(vals, 3, 2)

    2.  use NcVar::get() with an edge-length array:

            long[2]     counts = {3, 2}
            var.set_cur(2, 0)
            NcVar::get(vals, counts)

(Some of the syntax in the above might be incorrect.)

Please let me know if this helps.

--------
Steve Emmerson   <http://www.unidata.ucar.edu>