CDO

Possible example uses of CDO are:

Select a time from a file

To extract a single (or multiple) year from a multi-step file, you can use selyear,year:

$ cdo sinfon pchem.species.CMIP-5.1870-2097.z_91x72.nc4
  File format: netCDF4
    -1 : Institut Source   Ttype    Levels Num  Gridsize Num Dtype : Parameter name
     1 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : OX         
     2 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : N2O        
     3 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : CFC11      
     4 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : CFC12      
     5 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : CH4        
     6 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : HCFC22     
     7 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : H2O        
   Grid coordinates :
    1 : lonlat       > size      : dim = 91  nx = 0  ny = 91
                       lat       : first = -1.57079637  last = 1.57079625  inc = 0.0349065065  radians
  Vertical coordinates :
    1 : generic            layer : 1.5 2.63499999 4.01500034 5.67999983 7.76499939 
                                   10.4499998 13.960001 18.5400009 24.4899979 32.1749992 
                                   42.0400009 54.6300011 70.5950012 90.7249985 115.995003 
                                   147.565002 186.790009 235.26001 294.829987 367.649994 
                                   456.169983 563.179993 691.830017 845.63501 1028.49011 
                                   1246.01501 1505.02502 1812.43494 2176.09985 2604.90991 
                                   3108.89014 3699.26978 4390.96533 5201.58984 6149.56494 
                                   7255.78467 8543.89941 10051.4355 11825 13911.501 
                                   16366.1504 19254.0977 22651.3496 26647.9004 31279.1504 
                                   35625 39375 43125 46875 50625 54375 58125 61875 
                                   65625 69375 73125.0156 76250 78750 81250.0156 83750.0156 
                                   85750.0156 87250.0078 88750 90249.9844 91749.9844 
                                   93250.0078 94750 96249.9766 97374.9766 98124.9922 
                                   98875 99625 
  Time coordinate :  2736 steps
    RefTime =  1870-01-15 12:00:00  Units = hours  Calendar = standard
 YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
 1870-01-15 12:00:00  1870-02-14 22:00:00  1870-03-17 08:00:00  1870-04-16 18:00:00
 1870-05-17 04:00:00  1870-06-16 14:00:00  1870-07-17 00:00:00  1870-08-16 10:00:00
 1870-09-15 20:00:00  1870-10-16 06:00:00  1870-11-15 16:00:00  1870-12-16 02:00:00
 1871-01-15 12:00:00  1871-02-14 22:00:00  1871-03-17 08:00:00  1871-04-16 18:00:00
...snip...
 2096-07-21 20:00:00  2096-08-21 06:00:00  2096-09-20 16:00:00  2096-10-21 02:00:00
 2096-11-20 12:00:00  2096-12-20 22:00:00  2097-01-20 08:00:00  2097-02-19 18:00:00
 2097-03-22 04:00:00  2097-04-21 14:00:00  2097-05-22 00:00:00  2097-06-21 10:00:00
 2097-07-21 20:00:00  2097-08-21 06:00:00  2097-09-20 16:00:00  2097-10-21 02:00:00
cdo sinfon: Processed 7 variables over 2736 timesteps ( 0.11s )

$ cdo selyear,1999,2000,2001 pchem.species.CMIP-5.1870-2097.z_91x72.nc4 ~/test.nc4
cdo selyear: Processed 1651104 values from 7 variables over 2736 timesteps ( 0.73s )

$ cdo sinfon ~/test.nc4
  File format: netCDF4
    -1 : Institut Source   Ttype    Levels Num  Gridsize Num Dtype : Parameter name
     1 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : OX         
     2 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : N2O        
     3 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : CFC11      
     4 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : CFC12      
     5 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : CH4        
     6 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : HCFC22     
     7 : unknown  http://geos5.org/wiki/index.php?title=GEOS-5_Configuration_for_AR5 instant      72   1        91   1  F32  : H2O        
   Grid coordinates :
    1 : lonlat       > size      : dim = 91  nx = 0  ny = 91
                       lat       : first = -1.57079637  last = 1.57079625  inc = 0.0349065065  radians
  Vertical coordinates :
    1 : generic            layer : 1.5 2.63499999 4.01500034 5.67999983 7.76499939 
                                   10.4499998 13.960001 18.5400009 24.4899979 32.1749992 
                                   42.0400009 54.6300011 70.5950012 90.7249985 115.995003 
                                   147.565002 186.790009 235.26001 294.829987 367.649994 
                                   456.169983 563.179993 691.830017 845.63501 1028.49011 
                                   1246.01501 1505.02502 1812.43494 2176.09985 2604.90991 
                                   3108.89014 3699.26978 4390.96533 5201.58984 6149.56494 
                                   7255.78467 8543.89941 10051.4355 11825 13911.501 
                                   16366.1504 19254.0977 22651.3496 26647.9004 31279.1504 
                                   35625 39375 43125 46875 50625 54375 58125 61875 
                                   65625 69375 73125.0156 76250 78750 81250.0156 83750.0156 
                                   85750.0156 87250.0078 88750 90249.9844 91749.9844 
                                   93250.0078 94750 96249.9766 97374.9766 98124.9922 
                                   98875 99625 
  Time coordinate :  36 steps
    RefTime =  1870-01-15 12:00:00  Units = hours  Calendar = standard
 YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
 1999-01-14 22:00:00  1999-02-14 08:00:00  1999-03-16 18:00:00  1999-04-16 04:00:00
 1999-05-16 14:00:00  1999-06-16 00:00:00  1999-07-16 10:00:00  1999-08-15 20:00:00
 1999-09-15 06:00:00  1999-10-15 16:00:00  1999-11-15 02:00:00  1999-12-15 12:00:00
 2000-01-14 22:00:00  2000-02-14 08:00:00  2000-03-15 18:00:00  2000-04-15 04:00:00
 2000-05-15 14:00:00  2000-06-15 00:00:00  2000-07-15 10:00:00  2000-08-14 20:00:00
 2000-09-14 06:00:00  2000-10-14 16:00:00  2000-11-14 02:00:00  2000-12-14 12:00:00
 2001-01-13 22:00:00  2001-02-13 08:00:00  2001-03-15 18:00:00  2001-04-15 04:00:00
 2001-05-15 14:00:00  2001-06-15 00:00:00  2001-07-15 10:00:00  2001-08-14 20:00:00
 2001-09-14 06:00:00  2001-10-14 16:00:00  2001-11-14 02:00:00  2001-12-14 12:00:00
cdo sinfon: Processed 7 variables over 36 timesteps ( 0.00s )

tkcvs

ack