3

I am working on precipitation data. I need to rearrange dimensions in a NetCDF file. The dimensions in my file are in (time, lat, lon) order. I need them in (lat, lon, time) order.

I tried the following:

ncpdq -a lat,lon,time infile.nc outfile.nc   

now, I got order of dimension I wanted which is (lat, lon, time).

However, the lat dimension becomes UNLIMITED which is wrong. The time dimension should be the UNLIMITED dimension. This is what I got:

dimensions: 
   lon = 720 ;
   lat = UNLIMITED ; // (360 currently)
   time = 1404 ;

What should I do to reorder the dimensions from (time, lat, lon) to (lat, lon, time)?

Bart
  • 9,825
  • 5
  • 47
  • 73
Chane
  • 45
  • 7

1 Answers1

3

I did a check, and to me it seems the reorder works. I checked the file info with ncdump -h inputfile.nc and ncdump -h outputfile.nc and the comparison is like this: Comparison of file info before and after the re-order

As you see, the re-ordering has been made and the first dimension, which is the latc in my case, becomes unlimited.

Fortunately, you can do this to fix the latitude:

ncks --fix_rec_dmn lat output.nc -o outfixed.nc ; mv outfixed.nc outputfile.nc

and to unlimit time again:

ncks --mk_rec_dmn time outputfile.nc -o outunlim.nc ; mv outunlim.nc outputfile.nc

So now the outputfile, should be ok.

msi_gerva
  • 2,021
  • 3
  • 22
  • 28