New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Users/SetupNewConfiguration/Data-utilities-with-netcdf (diff) – NEMO

Changes between Initial Version and Version 1 of Users/SetupNewConfiguration/Data-utilities-with-netcdf


Ignore:
Timestamp:
2017-03-06T15:28:30+01:00 (7 years ago)
Author:
cbricaud
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Users/SetupNewConfiguration/Data-utilities-with-netcdf

    v1 v1  
     1'''Data utilities with netcdf''' 
     2 
     3You can find here an example of bash script to manipulate netcdf files (in this example forcing core2 files). 
     4 
     5(In this example we extract coordinates and put them in grid_orca2.nc file and then we apply ncpdq to choosen variable). 
     6 
     7This is necessary because "npdq" command change all variables, but in this case we don't want to have glamt, gphit, time "short" type. 
     8 
     9 
     10{{{ 
     11# remove useless variable from file 
     12ncks -O -x -v V_10.15JUNE2009_orca2.nc v_10.15JUNE2009_orca2.nc  
     13 
     14}}} 
     15 
     16{{{ 
     17 
     18# exctracting coordinates variables from file, put in output file (grid_orca2.nc) 
     19ncks -v glamt,gphit,time v_10.15JUNE2009_orca2.nc grid_orca2.nc 
     20}}} 
     21 
     22 
     23 
     24{{{ 
     25# exctracting variables from file 
     26ncks -O -C -v V_10_MOD v_10.15JUNE2009_orca2.nc v_10.15JUNE2009_orca2.nc 
     27}}} 
     28 
     29 
     30 
     31{{{ 
     32# compress all variables of v_10.15JUNE2009_orca2.nc file, 
     33# now variables of v_10.15JUNE2009_orca2.nc are "short" type 
     34# (add offset and scale factor) 
     35ncpdq -O -C -P all_xst v_10.15JUNE2009_orca2.nc v_10.15JUNE2009_orca2.nc  
     36}}} 
     37  
     38 
     39 
     40{{{ 
     41# append grid_orca2.nc file to v_10.15JUNE2009_orca2.nc file to have initial file 
     42# with variable V_10_MOD "short" type and coordinates variables unchanged 
     43ncks -A grid_orca2.nc v_10.15JUNE2009_orca2.nc 
     44}}}