0

I have a netcdf file that contains air quality data. There are 4 dimensions:

time : 24 hours (midnight to midnight) 
level : 1 to 8 (this is the height in meters (0, 50, 250, 500, 1000, 2000, 3000, 5000 m)) 
latitude : 1 to 400
longitude : 1 to 700

I want to make a new netcdf file retaining only level 1, deleting the other levels, as I only need the surface.

How can I do that ?

I tried to do this with nccopy command line but it reproduces the dataset. I don't know how can I delete the other levels.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
John
  • 4,711
  • 9
  • 51
  • 101

2 Answers2

2

You can hyperslab with NCO, e.g.,

ncks -d level,0 in.nc out.nc

If you don't have NCO yet, but you do have conda, install NCO with

conda install -c conda-forge nco
Charlie Zender
  • 5,929
  • 14
  • 19
  • Wow very simple ! This tool is awesome thank you so much it works perfectly. I used `sudo port install nco` to install it on my mac. Just for information can you explain to me what is -d ? I can't see it on the documentation. – John Apr 06 '17 at 09:45
0

You can do this in cdo using

cdo sellevel,lev in.nc out.nc

Selects all fields with levels as required in a user given list, or

cdo sellevidx,idx in.nc out.nc

allows you to select by level index instead. Further details here:

https://code.mpimet.mpg.de/projects/cdo/embedded/index.html#x1-1360002.3.3

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86