Norwegian Service Centre for Climate Modelling -> Format Conversion Tools -> nctofelt User Guide
 
 

 

     

NetCDF to FELT

This conversion is done with the nctofelt program developed at met.no.

Use of this program requires some knowledge of the FELT format (description in norwegian).

The nctofelt program takes information from three sources:

  • The NetCDF file to be converted
  • A text file describing various geographical projections used in FELT files. This file, usually named flt2flt.def, defines a unique identification number for each geographical projection described. An example file can be found here. This file is the same flt2flt.def file as found in the aux/nctofelt directory described below. If a suitable definition is found in this file, you can use this version of the file. Othervise you have to make your own version, and add a definition of the geographical projection you want.
  • A specification on how to convert from the netcdf file to the FELT file. This specification is read from standard input. The format of the specification is described in the nctofelt man pages. For a conversion involving a large number of 2D fields, it is recommended to generate the specification using a script (as in the example below).

Example

The directory /noserc2/extdata/felles/aux/nctofelt contains a version of the flt2flt.def file, a netcdf file containing some 2m temperature data from may 1980 (t2m_may1980.nc) and a script (see below) to convert this file to FELT format (convert.sh).

This script is constructed using information in the t2m_may1980.cdl file (created from t2m_may1980.nc using ncdump -c). The file tells us that the temperature data is found in the p2t array, which contains 16 bit integers which has to be scaled by multiplication with one constant and adding another, in order to recreate the original temperature values:

#!/bin/sh
cat >specfile <<EOF
31 998 98 1980 501 1200 31 1 3 1
EOF
day=1
time=704172
while [ $day -le 31 ]
do
   if [ $day -le 9 ]; then
      aday='0'$day
   else
      aday=$day
   fi
   cat >>specfile <<EOF
FELT(1980-05-${aday}:1200,104,1,0,1000,0,2,31) = p2t(${time},#2,#1) *0.00188 +258.893
EOF
   day=`expr $day + 1`
   time=`expr $time + 24`
done
nctofelt -d /noserc2/extdata/felles/aux/nctofelt/flt2flt.def \
          /noserc2/extdata/felles/aux/nctofelt/t2m_may1980.nc \
          t2m_may1980.felt \
          <specfile
rm specfile

 

Send comments to webmaster