Changes between Version 14 and Version 15 of Documentation/UserGuide/StudyNetCDF
- Timestamp:
- 2020-05-11T16:18:36+02:00 (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Documentation/UserGuide/StudyNetCDF
v14 v15 3 3 4 4 Author: S. Luyssaert and J. Ryder [[BR]] 5 Last revision: 2020/02/28, B. Guenet [[BR]] 5 Last revision: 2020/02/28, B. Guenet; 2020/05/11, A. Ducharne [[BR]] 6 7 == **ncview: a quick tool for vizualization** == 8 The quickest way of all to look at NetCDF files and to quickly plot some outputs is to use ncview: 9 10 {{{ 11 ncview myJob_20060101_20061231_1M_sechiba_history.nc 12 }}} 13 14 Unfortunately the ncview application can be sometimes a little unstable. 6 15 7 16 == **nco** == 8 9 17 10 18 nco is a very powerful tool to print data, modify variable names, concatenate, etc on netcdf file. A detailled documentation can be found here http://nco.sourceforge.net/ … … 15 23 This command print all the informations stored in your netcdf file. Some prefix can extract only the information you need. 16 24 17 *To look at header information:25 To look at header information: 18 26 19 27 {{{ … … 21 29 }}} 22 30 23 *To extract one variable (here for 'fluxlat', the latent heat flux)31 To extract one variable (here for 'fluxlat', the latent heat flux) 24 32 25 33 {{{ … … 27 35 }}} 28 36 29 *To extract one variable and show them in a tabulated way (here for 'fluxlat', the latent heat flux)37 To extract one variable and show them in a tabulated way (here for 'fluxlat', the latent heat flux) 30 38 31 39 {{{ … … 37 45 This command change the name of a given variable/dimension depending on the prefix you are using 38 46 39 *To rename a variable within the file (here for 'fluxlat', the latent heat flux)47 To rename a variable within the file (here for 'fluxlat', the latent heat flux) 40 48 {{{ 41 49 ncrename -v fluxlat,latent_heat_flux myJob_20060101_20061231_1M_sechiba_history.nc 42 50 }}} 43 51 44 *To rename a variable and create a new file (here for 'fluxlat', the latent heat flux)52 To rename a variable and create a new file (here for 'fluxlat', the latent heat flux) 45 53 {{{ 46 54 ncrename -v fluxlat,latent_heat_flux myJob_20060101_20061231_1M_sechiba_history.nc mynewfile.nc 47 55 }}} 48 56 49 *To rename a dimension within the file (here for 'lon', the longitude)57 To rename a dimension within the file (here for 'lon', the longitude) 50 58 {{{ 51 59 ncrename -d lon,longitude myJob_20060101_20061231_1M_sechiba_history.nc 52 60 }}} 53 61 54 *To rename a variable and create a new file (here for 'lon', the longitude)62 To rename a variable and create a new file (here for 'lon', the longitude) 55 63 {{{ 56 64 ncrename -d lon,longitude myJob_20060101_20061231_1M_sechiba_history.nc mynewfile.nc … … 97 105 [https://linux.die.net/man/1/ncra ncra] does the same with a time average, to get climatologies. 98 106 107 === ncatted 108 109 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. In that cases the ncatted command might be useful 110 111 112 {{{ 113 ncatted -a coordinates,my_var,o,c,"nav_lon nav_lat" sst_data.nc 114 }}} 115 116 or to correct a wrong spelling of an attribute 117 118 {{{ 119 ncatted -a units,latitude,m,c,"degrees_north" force2002.nc 120 }}} 121 99 122 === ncap2 100 123 101 124 The most powerful and quickly evolving tool from the nco set of functions 102 125 103 search what you are looking on this growing list of answers [[https://sourceforge.net/p/nco/discussion/|forum nco]]126 Search what you are looking on this growing list of answers [[https://sourceforge.net/p/nco/discussion/|forum nco]] 104 127 105 128 A simple example 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) … … 110 133 }}} 111 134 112 === ncatted 113 114 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. In that cases the ncatted command might be useful 115 116 117 {{{ 118 ncatted -a coordinates,my_var,o,c,"nav_lon nav_lat" sst_data.nc 119 }}} 120 121 or to correct a wrong spelling of an attribute 122 123 {{{ 124 ncatted -a units,latitude,m,c,"degrees_north" force2002.nc 125 }}} 126 127 128 == cdo == 135 == **cdo** == 129 136 130 137 An alternative to nco is cdo. They are basically doing similar things but dependending on what you want to do the command line might be easier with one or another. Details on cdo are here https://code.mpimet.mpg.de/projects/cdo cdo is useful for : … … 133 140 * complex operations... 134 141 135 Below a list of classical command: 142 == List of classical cdo command (non exhaustive) 136 143 137 144 … … 183 190 }}} 184 191 185 186 == Operator chaining == 187 It is one of the main features of CDO. Use it as But operators with a arbitrary list of input files cannot be combined with other operators 188 189 Simple combination: 192 == Operator chaining 193 It is one of the main features of CDO. Beware, however, that operators with an arbitrary list of input files cannot be combined with other operators. 194 195 Simple combination example: 190 196 {{{ 191 197 cdo sub -dayavg ifile2 -timavg ifile1 ofile 192 198 }}} 193 194 195 instead of : 199 instead of: 196 200 {{{ 197 201 cdo timavg ifile1 tmp1 … … 204 208 }}} 205 209 206 CDO can also be used to regrid NetCDF files. It is very straight and fast. Contrary to Ferret I [SL] did not find how to increase the memory allocation for CDO. Thus for very large files Ferret seems to be the software of your choice. 207 208 The call has the following structure:210 == Regridding 211 212 CDO can also be used to regrid NetCDF files. It is very straight and fast. The call has the following structure: 209 213 {{{ 210 214 cdo -f nc -regriddingMethod,gridTemplate.nc input.nc output.nc 211 215 }}} 216 217 Note that Sebastiaan Luyssaert did not find how to increase the memory allocation for CDO, contrary to Ferret. Thus, to regrid very large files, Ferret seems to be the software of your choice. 212 218 213 219 There are three regridding methods: remapbil (bilinear interpolation), remapbic (bicubic interpolation), remapnn (nearest neighbour), remapcon (conservative regridding). Use remapnn and remapcon to avoid weird values if your variable is heterogeneous. … … 221 227 }}} 222 228 223 == ncview: a quick alternative ==224 The quickest way of all to look at NetCDF files and to quickly plot some outputs is to use ncview:225 226 {{{227 ncview myJob_20060101_20061231_1M_sechiba_history.nc228 }}}229 230 Unfortunately the ncview application can be sometimes a little unstable.