Changes between Initial Version and Version 1 of Documentation/nco


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

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/nco

    v1 v1  
     1 
     2= Manual = 
     3Please have a look at if you want to make some operations on netcdf files : http://nco.sourceforge.net/#Definition 
     4 
     5The manual can be downloaded as a pdf : http://nco.sourceforge.net/nco.pdf 
     6 
     7You may have a look at one of the associated forum if you encounter some problems when using it. 
     8http://sourceforge.net/projects/nco/forums/forum/9830 
     9 
     10 
     11== Consulting netcdf files on a dods server == 
     12 
     13For netcdf files available on an OpenDAP/DODS server, one can see the format by adding .dds at the end of the file. 
     14Exemple : [[http://dods.ipsl.jussieu.fr/cgi-bin/nph-dods/database/climato/CRU_precipitation.nc.dds]] 
     15 
     16More explanation on [[http://docs.opendap.org/index.php/QuickStart]] and [[http://www.opendap.org/pub/dods/ps-docs/guide.pdf]] 
     17 
     18 
     19== Specific notes for the dods in Jussieu == 
     20 
     21To activate the dods fonctionnality, one should use the URL : [[http://dods.ipsl.jussieu.fr/cgi-bin/nph-dods/]] rather than [[http://dods.ipsl.jussieu.fr/]] 
     22 
     23For exemple, to see the characteristics of the CRU precipitation file : 
     24[[http://dods.ipsl.jussieu.fr/cgi-bin/nph-dods/database/climato/CRU_precipitation.nc.dds]] 
     25 
     26Or to get a subset of it : 
     27[[http://dods.ipsl.jussieu.fr/cgi-bin/nph-dods/database/climato/CRU_precipitation.nc.html]] 
     28 
     29 
     30More info on [[http://wiki.ipsl.jussieu.fr/wiki_ipsl/ServeurDODSintro]] 
     31 
     32 
     33== Example of use == 
     34 
     35 
     36=== commande NetCDF Arithmetic Processor ncap === 
     37 
     38<code> 
     39   ncap -s "C_tot=VEGET_MAX*(CARBON_PASSIVE+CARBON_ACTIVE+LITTER);C_tot@missing_value=CARBON_PASSIVE@missing_value" soilc_af2002.nc my_soilc_af2002.nc 
     40</code> 
     41 
     42 
     43=== commande ncrcat === 
     44 
     45concatenate the variables file_{23..32}.nc changing 2 digits on the number by step of 1 
     46 
     47<code> 
     48   ncrcat -n 10,2,1 file_23.nc file_global.nc 
     49</code> 
     50 
     51 
     52=== commande ncwa === 
     53 
     54Calculate the mean over various dimensions. 
     55 
     56 
     57=== commande ncatted === 
     58 
     59o, meaning Overwrite (other possible options : a c d m ) a global attribute entitled nbyear which is a double d (other possible options : f d l s c b) 
     60 
     61<code> 
     62   ncatted -O -a nbyear,global,o,d,$ny stomate_forcing_all.nc 
     63</code> 
     64 
     65 
     66Pour modifier rapidement l'année de départ (!attention aux calendriers grégoriens pour lesquels on n'a pas le droit de procéder de la sorte!!!), c'est time_counter:units qui est interprété par ferret et non time_counter:origin. Cf /home/orchidee01/pbrender/ORCHIDEE/MERGE_PP/AGOUFOU_SPINUP_PP/SPINUP_COMPLET_v3/change_date   
     67 
     68<code> 
     69   #!/bin/bash 
     70   ncrcat -O run_100?/stomate_history.nc MA_Ago_stomate_history.nc  
     71  
     72   n_or=$( ncdump -h MA_Ago_stomate_history.nc |grep time_origin| grep -m 1 -o -E \".*\"|sed "s/2005/$[2005-109]/"|sed 's/"//g')  
     73   n_unit=$( ncdump -h MA_Ago_stomate_history.nc |grep time_counter:units| grep -m 1 -o -E \".*\"|sed "s/2005/$[2005-109]/"|sed 's/"//g')  
     74  
     75   ncatted -O -a time_origin,time_counter,o,c,"${n_or}" MA_Ago_stomate_history.nc  
     76   ncatted -O -a units,time_counter,o,c,"${n_unit}" MA_Ago_stomate_history.nc  
     77</code> 
     78 
     79 
     80=== Sélection d'une partie d'un fichier netcdf === 
     81 
     82<code> 
     83   ncks -d tstep,0,17519 wankame_gapfilled.nc wankama_gapfilled_2005.nc 
     84</code> 
     85 
     86 
     87=== Conversion to ascii and reverse === 
     88 
     89Pour rapide examen de la structure 
     90 
     91<code>  
     92   ncdump -c 
     93</code> 
     94 
     95Pour l'extraction ascii d'une variable 
     96 
     97<code> 
     98   ncdump -v temp -f fortran -n name > output.cdl 
     99</code> 
     100 
     101Pour récupérer un fichier netcdf à partir de la fraction extraite 
     102 
     103<code> 
     104   ncgen -b -o my_new_name output.cdl 
     105</code> 
     106 
     107Utile aussi quand on rencontre un problème sur une commande par exemple ncatted. Ie pour faire des corrections à la main ! 
     108 
     109 
     110=== ncview === 
     111 
     112<code> 
     113   ncview 
     114</code> 
     115 
     116Installation : 
     117<code> 
     118   sudo apt-get install xorg-dev netcdfg-dev 
     119   ./configure --x-libraries=/usr/lib 
     120   make 
     121   sudo make install 
     122</code> 
     123 
     124Voir aussi cdat et vcdat comme utilitaires de visualisation rapide 
     125 
     126 
     127=== ncap2 === 
     128<code> 
     129   ncap2 -O -v -s 'gpp_moy=(GPP*VEGET_MAX).avg($PFT)' stomate_history.nc my_history.nc 
     130</code> 
     131 
     132Voir exemples de commandes sur : http://nco.sourceforge.net/ncap2.in 
     133 
     134 
     135=== ncpdq === 
     136 
     137ncpdq makes it possible to concatenate files along any dimension, not just the record dimension. First, use ncpdq to convert the dimension to be concatenated (i.e., extended with data from other files) into the record dimension. As a concrete example, say that files x_01.nc, x_02.nc, ... x_10.nc contain time-evolving datasets from spatially adjacent regions. The time and spatial coordinates are time and x, respectively. Initially the record dimension is time. Our goal is to create a single file that contains joins all the spatially adjacent regions into one single time-evolving dataset. 
     138 
     139<code> 
     140   for idx in 01 02 03 04 05 06 07 08 09 10; do # Bourne Shell 
     141   ncpdq -a x,time x_${idx}.nc foo_${idx}.nc # Make x record dimension 
     142   done 
     143   ncrcat foo_??.nc out.nc       # Concatenate along x 
     144   ncpdq -a time,x out.nc out.nc # Revert to time as record dimension 
     145</code> 
     146 
     147