RFM File Formats

Output Spectral File Format

14JUL17

Description
Generic format of all RFM spectral output files.
RFM v4.35 onwards: also irregular grids
RFM v5.0: simplified format for regular binary files

Structure
ASCII files, regular grid
!HEADER1
!HEADER2
!HEADER3
NPNT WNO1 WNOD WNO2 LABSPC
SPC(1) SPC(2)
... SPC(NPNT)
[eof]
ASCII files, irregular grid
!HEADER1
!HEADER2
!HEADER3
NPNT WNO1 WNOD WNO2 LABSPC
WNO(1) SPC(1)
WNO(2) SPC(2)
...
WNO(NPNT) SPC(NPNT)
[eof]
Binary files (BIN Flag), regular grid, RFM v4
!HEADER1
!HEADER2
!HEADER3
NPNT WNO1 WNOD WNO2 LABSPC
NPTREC(1) SPC(1) ... SPC(NPTREC(1))
NPTREC(2) SPC(NPTREC(1)+1) ... SPC(NPTREC(1)+NPTREC(2))
...
NPTREC(n) SPC(NPTSPC-NPTREC(n)+1) ... SPC(NPNT)
[eof]
Binary files, irregular grid
!HEADER1
!HEADER2
!HEADER3
NPNT WNO1 WNOD WNO2 LABSPC
WNO(1) SPC(1)
WNO(2) SPC(2)
...
WNO(NPNT) SPC(NPNT)
[eof]
Binary files (BIN Flag), regular grid, RFM v5
!HEADER1
!HEADER2
!HEADER3
NPNT WNO1 WNOD WNO2 LABSPC
SPC(1) ... SPC(NPNT)
[eof]

Fields
FieldTypeDescriptionVariations
!HEADER1 C*80 Spectrum type, ray-path and RFM version ID
!HEADER2 C*80 Text read from *HDR section of Driver Table
!HEADER3 C*80 Captions for next record JAC Flag: Jacobian info
NPNT I No. spectral points in file
RFM v4.35 onwards: -ve if GHz spectrum
WNO1 R*8 Lower limit [cm-1] of spectrum GHZ Flag: [GHz]
WNOD R*8 Resolution [cm-1] of spectrum GHZ Flag: [GHz]
WNO2 R*8 Upper limit [cm-1] of spectrum GHZ Flag: [GHz]
LABSPC C*(*) Spectral Label or (if no label) Type
NPTREC I No.spectral points in record BIN Flag only
SPC R*4 Spectral Data DBL Flag: R*8
Notes
  1. RFM v4.35 onwards: Reg/Irreg file headers are the same, the regular grid has WNOD > 0 while the irregular grid as WNOD=0
  2. RFM v4.35 onwards: since spectral files can also be RFM input data, it is necessary to distinguish whether the spectral axis is [cm-1] or [GHz], hence -ve NPNT for [GHz] (same convention as for other spectral input files)
  3. If no spectral range label is supplied in the *SPC section, then the type of spectrum is inserted in LABSPC (eg 'Absorption')
  4. The RFM works in units of 1cm-1 at a time, a new output record is written after each. Most of these records will contain a fixed number of points determined by WNOD, however the first and last intervals may contain fewer (determined by WNO1,WNO2 in relation to wavenumber boundaries).
  5. Since the number of data points within a record isn't fixed, this can create problems when reading the binary output. For this reason, the first field in each binary record is NPTREC: the number of spectral points that follow in the record.
  6. RFM v5 outputs the complete spectrum in one WRITE statement. For binary files this will be a single record of NPNT values, hence it is no longer necessary to have the complication of specifying the number of points in each record. To restore the old RFM v4 format, change the variable OLDFMT in module wrtspc_sub.f90 to .TRUE. — this will just write NPNT again at the start of the record of spectral data values.
  7. An simple IDL procedure rfmrd.pro is available for reading ASCII regular grid output, and a more complicated version rfmrd2.pro for handling all ASCII/binary/regular/irregular files.
    rfmrd_f90.pro for handling all ASCII/binary/regular/irregular files written by RFM v5.
  8. See below for FORTRAN code for reading RFM v4 regular binary files

Example
Below is an example of a spectral file used to establish the irregular grid, either for RFM output (*SPC section) or for internal calculation (*GRD section). In this case, only the wavenumber points are read so it is not necessary to specify any 'data' values. The header has to contain the number of points (326 in this example), the lowest (1st) point (1400.0), the increment (set to 0.0 for irregular grid) and the highest (326th) point (1410.0), followed by the spectral points themselves, one value per record.
! Basic irregular grid
! Npts, WNO1, WNOD, WNO2
326 1400.0000 0.0000 1410.0000
1400.0000
1400.0810
...
1410.0000

Suggested FORTRAN code for reading RFM v4 regular binary files
      INTEGER          I, J, N, NPTS
      REAL             X(MAXARR)         ! Or DOUBLE PRECISION for DBL flag
      DOUBLE PRECISION WNO1, WNOD
      CHARACTER*80     RECORD
C
      OPEN ( UNIT=LUN, FILE=FILNAM, STATUS='OLD', FORM='UNFORMATTED' )
C
      READ ( LUN ) RECORD                ! Skip 3 header records
      READ ( LUN ) RECORD
      READ ( LUN ) RECORD
C
      READ ( LUN ) NPTS, WNO1, WNOD      ! No.pts, 1st Wno, Wno increment
C
      J = 0                              ! J=number of points read so far
      DO WHILE ( J .LT. NPTS )
        READ ( LUN ) N, ( X(I), I = J+1, J+N )   
        J = J + N
      END DO
C
For RFM v5 regular binary files the loop is not required, and can be replaced by
READ ( LUN ) ( X(I), I = 1, NPTS )