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

[netCDF #IPQ-870742]: Change order of dimensions from (lon, lat, time) to (time, lon,lat)



Hi Chris,

> I have 2 questions:
> 
> (1) I have a NetCDF file with 3 dimensions: [lon, lat, time].
> I need to change the order of the dimensions to: [time, lon, lat].
> Is this possible? And if yes, how can I do it?

Yes, the NCO (netCDF operators) program ncpdq ("permute dimensions quickly") is
intended for exactly that kind of problem.  See:

  http://nco.sourceforge.net

for the package, and in particular 

  http://nco.sourceforge.net/nco.html#ncpdq-netCDF-Permute-Dimensions-Quickly

for more information.  I think you must be able to read all the values of the
variable into memory at once to use ncpdq, but that restriction may have been
overcome.

There are other packages that may provide similar functionality, including
NCL and CDO:

  http://www.unidata.ucar.edu/software/netcdf/software.html#NCL
  http://www.unidata.ucar.edu/software/netcdf/software.html#CDO
  
> (2) My variable (temperature) is "double". Is it possible to change it to 
> "float"?

Yes, I think the NCO program ncap2 can do this, with something like:

  ncap2 -s 'var1=float(var1);var2=float(var2)' in.nc out.nc

for double-precision variables var1 and var2.  I'm not sure if it 
supports converting all double variables to float without mentioning 
each explicitly in the command.  You may want to check the documentation
or ask on the NCO users forum.

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: IPQ-870742
Department: Support netCDF
Priority: Normal
Status: Closed