Re: [netcdf-java] How to convert NetCDF data to T,Z,Y,X data

A Java solution:

* When you get the actual data, it will be stored in a subclass of ucar.ma2.Array.

* The Array class offers lots of methods to rearrange the data (reduce(), reshape(), permute(), ...). Those may be sufficient to do all that you need.

* If that isn't sufficient, sometimes it is appropriate to
  * Use Array.flip to reverse the order of one dimension
    (when the new Array is accessed via an index).
  * Use Array.getIndex() to get a ucar.ma2.Index from the flipped Array.
  * Make another Array (a3) to hold the results.
  * Use the index to get data from the flipped Array,
    then write it to the new array (a3).

Good luck.

Daniele Romagnoli wrote:
Hi list,
first of all, sorry for cross-posting.

I have some NetCDF data containing 4D variables having dimensions ordered as Time, Lat, Lon, Level. I would like to "simply" re-arrange data to become having dimensions ordered as Time, Level, Lat, Lon, as recommended (although not required) by CF-Convention.
Is there an easy way to achieve this? (I'm using net-cdf java 2.2 APIs)

Basically I have a "test.nc <http://test.nc>" file with attributes/variables/dimensions/more... and I would like to get a "modified.nc <http://modified.nc>" file where the "only difference" is having variables with differently ordered dimensions (and data array respecting the new order).

Any suggestion or guidance line would be greatly appreciated.

Best Regards,
Daniele

--
-------------------------------------------------------
Eng. Daniele Romagnoli
Software Engineer

GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax:     +39 0584983027
mob:   +39 328 0559267


http://www.geo-solutions.it

-------------------------------------------------------


------------------------------------------------------------------------

_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/

--
Sincerely,

Bob Simons
Satellite Data Product Manager
Environmental Research Division
NOAA Southwest Fisheries Science Center
1352 Lighthouse Ave
Pacific Grove, CA 93950-2079
(831)658-3205
bob.simons@xxxxxxxx

The contents of this message are mine personally and
do not necessarily reflect any position of the
Government or the National Oceanic and Atmospheric
Administration.
<>< <>< <>< <>< <>< <>< <>< <>< <><


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