Changes between Version 6 and Version 7 of HowTo_cdo_netcdf


Ignore:
Timestamp:
2014-11-21T11:57:46+01:00 (10 years ago)
Author:
zpoussi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowTo_cdo_netcdf

    v6 v7  
    1 == ncap2 == 
    2  
    3 The most powerful and quickly evolving tool from the nco set of functions 
    4  
    5 See the file of exemples : {{:reunions_orchidee:ncap2.pdf| ncap2 file}} or search what you are looking on this growing list of answers [[http://sourceforge.net/search/index.php?words=&sort=posted_date&sortdir=desc&offset=0&group_id=3331&type_of_search=forums|forum nco]] 
    6  
    7 A simple exemple showing different capacities (creation of a variable, use of a mask, call to an attribute, count the total and the size of the field (we can restrict this operation to a dimension as shown on the second line) 
    8  
    9 <code> 
    10  ncap2 -O -s 'missing_flag[$y,$x]=0;where(t2m_daily!=t2m_daily@missing_value) missing_flag=1;missing_count=float(missing_flag.total())/missing_flag.size();print(missing_count)' stomate_restart.nc  ~/foo.nc 
    11  ncap2 -O -s 'missing_flag[$y,$x]=0;where(t2m_daily!=t2m_daily@missing_value) missing_flag=1;missing_count=float(missing_flag.total($x))/missing_flag.size($x);print(missing_count)' stomate_restart.nc  ~/foo.nc 
    12 </code> 
    13  
    14  
    15 == cdo == 
    16  
    17 A command that handle many operations one would like to do when working on outputs of models of the Earth System : 
    18   * changing of time axis 
    19   * regridding (many grid are already implemented and it is an even more versatile tool) 
    20   * complex operations... 
    21  
    22 See the website of the project {{https://code.zmaw.de/projects/cdo/wiki}} or the doc : {{:reunions_orchidee:cdo-manual.pdf| CDO Manual}} and  the  {{:reunions_orchidee:cdo_refcard.pdf | quickref}} 
    23  
    24 <code>  
    25  
    26    cdo -v # print list of available operators [[BR]] 
    27    cdo -V # version (if very old, think of downloading the source and install a new version, as it is a tool that is evolving quickly [[BR]] 
    28    cdo -h remapcon # informations about a command [[BR]] 
    29    cdo remapcon,my_grid my_climatology.nc my_regridded_climatology.nc # conservative regridding to an other resolution [[BR]] 
    30  
    31 </code> 
    32  
    33 my_grid could be a file like : 
    34  
    35 <code>   
    36    gridtype  = lonlat 
    37    gridsize  = 220 
    38    xname     = longitude 
    39    xunits    = degrees_east 
    40    yname     = latitude 
    41    yunits    = degrees_north 
    42    xsize     = 20 
    43    ysize     = 11 
    44    xfirst    = -18.75 
    45    xinc      = 3.75 
    46    yfirst    = 20 
    47 </code> 
    48  
    49  
    50  
    51  
    52 <code> 
    53    cdo sinfov my_file.nc #most info on the file 
    54    cdo griddes my_file.nc #grid description (check that the type is not generic (which means unrecognised and thus not useable for mapping 
    55 </code> 
    56  
    57 Sometimes, one just need to add the attribute coordinates (linking to the variables defining the longitude and latitude positions) to enable the recognition of the grid that is used (see https://code.zmaw.de/boards/1/topics/55) 
    58 <code> 
    59    ncatted -a coordinates,my_var,o,c,"nav_lon nav_lat" sst_data.nc 
    60 </code> 
    61  
    62 or to correct a wrong spelling of an attribute 
    63  
    64 <code> 
    65    ncatted -a units,latitude,m,c,"degrees_north" force2002.nc 
    66 </code> 
    67  
    68 == Operator chaining == 
    69 It is one of the main features of CDO. Use it as often as possible. But Note: Operatos with a arbitrary list of input files cannot be combined with other operators 
    70  
    71 # Simple combination: 
    72 <code> 
    73    cdo sub -dayavg ifile2 -timavg ifile1 ofile 
    74 </code> 
    75  
    76  
    77 instead of : 
    78  
    79 <code> 
    80   cdo timavg ifile1 tmp1 
    81  
    82   cdo dayavg ifile2 tmp2 
    83  
    84   cdo sub tmp2 tmp1 ofile 
    85  
    86   rm tmp1 tmp2 
    87 </code> 
    88  
    89  
    90 == To install a newer version than the default one on asterix/obelix == 
    91  
    92 <code> 
    93    get files from https://code.zmaw.de/projects/cdo/files 
    94    ./configure --prefix=/home/users/your_ACCOUNT/ --with-netcdf=/usr 
    95  
    96    make clean 
    97    make 
    98    make install 
    99 </code> 
    100  
    101 If you installed proj and hdf5 libraries somewhere, their can also be support for these file formats : 
    102  
    103 <code> 
    104    ./configure --prefix=/home/users/your_ACCOUNT/ --with-netcdf=/usr --with-proj=/path/to/install --with-hdf5=/path/where/installed 
    105 </code> 
    106  
    107 ---- 
    108  
    109 [[reunions_orchidee:nco_netcdf|Description of the other tools of the nco suite]] 
    110  
    111 ---- 
    112