RPN standard files
For the end-user, the appearance of the FST is
that of a flat-file database
structure. A single file contains numerous records which hold fields on 1, 2 or
3D data grids
and self-describing information about the fields (header).
A
thorough set of FST-related
routines are contained in the
RPN Library (armnlib). These routines
provide easy access to the file
contents. They can be called from FORTRAN or C routines.
A
complete description of the FST file
format and the utilities which can be used to manipulate
and view their contents is available
online at www.cmc.ec.gc.ca/rpn/utilities.
Sometimes the files are archived in an cmc-archive file. If this
is the case they need to be unarchived first.
How to look at FST files
voir is the most simple way to see the content of an FST file (also xvoir)
It prints the headers for all of the records of the
given RPN standard file:
voir -iment fst-file [-style]
The -style option decodes the level and date information.
r.fstliste is available if you need a bit more information than what is provided by voir.
It can be used in batch mode to extract specific or all of the record
parameters of a RPN standard file record(s) based on a criteria given
through the selection keys:
r.fstliste -izfst fst-file [-datev -vdatev -ip1
-typvar -nomvar -col ...]
xrec
is a X-window visualization program used to display 2D (horizontal or vertical)
meteorological fields stored in FST files. Usage:
xrec
or
xrec -imflds list_of_FST_files
How to modify FST files
The two main tools to modify FST
files are called editfst and r.diag. And of course, you can also write your own C or Fortran programs.
editfst
(also called editfst2000)
is a utility used for editing and copying records from RPN standard
files into a new or existing RPN standard file. It can do a straight (complete)
copy of the input file or it can copy records selectively as indicated
from the
standard input or from a file of directives named in the "-i" key. One
can select (via desire), exclude (via exclure) or zap records by their:
TYPVAR: type of variable; 'A'(analysis),'P'(forecast),'X'
NOMVAR: 4 caracter variable name
ETIKET: 12 caracter label recorded from the original model run
DATE: CMC date timestamp
IP1: the level of the field (in pressure,eta,meters,other)
IP2: the hour of the forecast (rounded off if not exact)
IP3: value of 0 unless otherwise modified
Example:
You could use it to select i.e. temperature (TT) and winds (UU,VV) at
500 hPa:
echo "desire
(-1,['UU','VV'], -1 ,-1 ,[500.,MBAR])" | editfst -s input_file
-d output_file
Note:
editfst appends to its
output file. This means that if editfst is used more than once writing into
the same output file, the output of the second set of commands will be appended
to the output of the first set.
r.diag
(also called r.diag2000) is a toolkit used to
manipulate FST or CCCma files. As editfst, it can be used to select or
exclude specific records but in addition to this it also contains a
large set of functions which can be used to manipulate the files.
'r.diag' is always used in the way:
r.diag function
input_file(s) [ output_file(s) key(s) ]
To get information about a specific function simply type:
r.diag function
Example:
Selecting temperature (TT) and winds (UU,VV) at 500 hPa as above:
r.diag select input_file output_file_tt output_file_uu output_file_vv -name TT UU VV -lv1 500
Notes:
-
r.diag generally overwrites
its output files. There are a few functions, eg. select, which
have an option to append to the output file instead of overwriting
it.
-
If there is no path written in front of the output file name and if the
output file does not yet exist in the local directory, it will be
written in one of the ${BIG_TMPDIR} or ${TMPDIR} directories. Also, if the input file is not in the local
directory, r.diag will look for it in the ${BIG_TMPDIR} and ${TMPDIR} directories.
Writing your own C and Fortran programs
There is a number of functions which can be called in a C or Fortran
program to read and write FST files, and they are documented in the RPN
Standard File Functions. These functions are part of the library 'librmn'.
There are functions to:
- open and close an FST file
- search for a record
- read a record
- read the field descriptor of a record
- write a record
Have a look here on how to compile.
Author: Katja Winger
Last update: June 2008