\documentclass[11pt]{article}
  
\usepackage{color}
  
\pagestyle{plain}
\baselineskip 0.8cm
\textheight 24.cm
\topmargin -1.5cm
\textwidth 16.cm
\oddsidemargin 0pt
\evensidemargin 0pt
\parindent 0pt
  
  
\title{PdBI NGRX Data Format}
\author{Vincent Pi\'etu, Fr\'ed\'eric Gueth}
\date{{18 December 2006 -- Draft v.4}}
  
\begin{document}
  
\maketitle

% {\em Notes:
% \begin{itemize}
% \item {\bf vitual units now in dedicated section}
% \item check/update/clarify all parameters definition
% \item additional parameters for polarization calibration? do we need 
% a dedicated polarization section?  -- DONE
% \item future wide-band correlator?
% \item time-switching mode for polar.\ observations?
% \item needs for reading ALMA data?
% {\bf\item axis order of parameters?} 
% \end{itemize}}

\section{Introduction}

The CLIC IPB data format derives from the CLASS format (see CLASS
manual, section 5). All basic concepts are similar. This memo
lists the modifications proposed to accomodate the New Generation
Receivers. Also included are a number of minor modifications/new
parameters that have been requested for other reasons.  \\

Please note:
\begin{itemize}
\item Modifications already done are in \color{blue}BLUE\color{black}
\item Planned modifications are in {\color{red}RED}\color{black}
\end{itemize}
{\bf When modifying data format (clic\_par.inc, clic\_dheader.inc), please
update this document.}

{\bf CAUTION: some parameters still to change (DH\_ATFAC ...)}

\section{Polarization}
{\bf CAUTION: this section is not up-to-date}

In the new system, the two polarizations channels are always
available, but are not necessarily observed simultaneously, or at the
same frequency. In fact, each correlator unit can be connected to one
or the other polarization channels, with full flexibility regarding
its central frequency and bandwidth. {\bf Therefore, the content of
the data in terms of polarization depends on the correlator setup and
may vary from unit to unit.} \\

The system allows to measure 1, 2, or 4 polarisation products:

\begin{enumerate}
\item (R\_LNPOL = 1). This is the case when each correlator unit is used
at a different frequency in the IF band, using one or the other
polarization (in which case all units are independant).
\item (R\_LNPOL = 2). This is obtained when two correlator units are
connected with the same setup to the two polarization channels and
thus used to measure H and V (or R and L).
\item (R\_LNPOL = 4). All four cross-products were measured. This is done
using at least 6 correlator units (same setup), but with different
polarization entries per antenna -- see example below.
\end{enumerate}

{\bf The cases (2) and (3) require that the data of two or more
correlator units are re-organized and grouped in a ``virtual''
correlator unit.} This operation can -at least in a first step- be
performed off-line. Therefore the data format must accomodate three
cases: 
\begin{itemize}
\item (R\_LPOLMODE=1). One polarization measured (case (1) above, this
is also the case of old data).
\item (R\_LPOLMODE=2). One unit with different polarization entries
per antenna, i.e.\ different polarization products per baseline; this
is the outcome of the observations, before data re-organization in
case (3).
\item (R\_LPOLMODE=3). Virtual correlator unit, build up from several
physical units, with two or four polarization products for all
baselines (case (2) and (3) above, after data reorganization).
\end{itemize}

The corresponding format modifications (and new parameters) are
introduced in Section $-34$, $-43$, and $-44$. \\

Note: This is a possible correlator configuration that allows to
measure all correlation cross-products (full polarimetry,
R\_LNPOL=4). 6 units are used (90 products) for 60 useful
measurements, giving a redondancy of 1.5.
\begin{center}
\begin{table}[h]
\begin{tabular}{l|cccccc}
Corr & Unit 1 & Unit 2 & Unit 3 & Unit 4 & Unit 5 & Unit 6 \\
\hline
A1 & H & V & V & V & H & H \\
A2 & H & V & H & V & H & V \\
A3 & H & H & V & H & V & V \\
A4 & V & H & H & V & V & H \\
A5 & V & H & V & H & H & V \\
A6 & V & V & H & H & H & V \\
\end{tabular}
\end{table}
\end{center}
With this configuration, 4 HH (respectively VV) are measured twice as
11 HV (resp. VH). For baselines 12, 35, 26 and 56 HH and VV are
measured twice. For all the other baselines HV and VH are measured
twice.

\newpage 

\section{Scan header (clic\_par.inc)}

\begin{verbatim}

* This is -*-fortran-*- code.
      INTEGER SPACE1,SPACE2
*
* Data Structures : Header r_
      INTEGER R_XNUM                     ! number in index (0:no obs, -1:not fro
      LOGICAL R_PRESEC(-MNSEC:0)         ! Present Sections
*
* Section -2 General Information
*
* NUM,VER,TELES,DOBS,DRED,TYPEC,KIND,SCAN written in index,
* are not repeated in General Section on disk.
      CHARACTER*12 R_TELES               ! Telescope name
      INTEGER R_NUM                      ! Scan number
      INTEGER R_VER                      ! Version number
      INTEGER R_DOBS                     ! Date of observation
      INTEGER R_DRED                     ! Date of last reduction
      INTEGER R_TYPEC                    ! Type of coordinates
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Add new value for this parameter
      INTEGER R_KIND                     ! Type of data 
                                         ! 0/1 = CLASS
                                         ! 3 = single-dish
                                         ! 4 = interferometer (current)
                                         ! 5 = interferometer (new) 
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      INTEGER R_QUAL                     ! Quality flag
      INTEGER R_SCAN                     ! Original scan number
      REAL*8  R_UT                       ! Universal time
      REAL*8  R_ST                       ! Sidereal time
      REAL*4  R_AZ                       ! Azimuth
      REAL*4  R_EL                       ! Elevation
      REAL*4  R_TAU                      ! Sky opacity
      REAL*4  R_TSYS                     ! System temperature
      REAL*4  R_TIME                     ! Integration time
      INTEGER R_TYPOF                    ! type of offsets
      INTEGER R_PROC                     ! observing procedure
      CHARACTER*4 R_PROJECT              ! observing project
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Needed for bookeeping / CDS headers ???
      CHARACTER*12 R_PROJPI              ! name of project PI
      CHARACTER*12 R_OBSERVER            ! name of observers/operators
      !! NEW !! Moved from section -26 for clarity
      INTEGER*4  R_NREC                  ! receiver number 
      !! NEW !! Add observatory coordinates
      REAL*8 R_OBS_LONLAT(2)             ! observatory longitute/latitude
      !! NEW !! Add time parameters (DUT1,...) ???
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*-- not in data ---
      CHARACTER*12 R_CDOBS               ! date observation
      CHARACTER*12 R_CDRED               ! date reduction
      CHARACTER*12 R_CPROC               ! procedure
      CHARACTER*12 R_CTOBS               ! UT
      CHARACTER*12 R_CQUAL               ! Quality
*
*C Section -3 Positions		
      CHARACTER*12 R_SOURC               ! Source name
      REAL*4  R_EPOCH                    ! Epoch of observation
      REAL*8  R_LAM                      ! Lambda of center position
      REAL*8  R_BET                      ! Delta  ----
      REAL*4  R_LAMOF                    ! Offset in Lambda
      REAL*4  R_BETOF                    ! Offset in Delta
      INTEGER R_PROJ                     ! Projection type
      REAL*4  R_FOCUS                    ! focus in mm
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Add Stokes parameters and spectral indexes
      REAL*4  R_FLUX(4)                  ! in Janskys, for calibrators
      REAL*4  R_INDEX(4)                 ! spectral indexes, for calibrators
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -21 Interferometer General Information
      INTEGER R_NANT                     ! Number of Antennas 
      INTEGER R_NBAS                     ! Number of baselines 
      INTEGER R_ITYPE                    ! Type of interf. obs.
      REAL*4  R_HOURA                    ! Start hour angle
      INTEGER R_KANT(MNANT)              ! Antenna Physical numbers
      INTEGER R_KENT(MNANT)              ! Correlator Entry numbers
      INTEGER R_ISTAT(MNANT)             ! Station numbers
      INTEGER R_IANT(MNBAS)              ! Start virtual antenna for baseline
      INTEGER R_JANT(MNBAS)              ! End virtual antenna for baseline
      REAL*8  R_BAS(3,MNBAS)             ! components of baseline (meters)
      REAL*8  R_ANT(3,MNANT)             ! coordinates of antenna (meters)
      INTEGER R_NTRI                     ! Number of triangles
      INTEGER R_ATRI(3,MNTRI)            ! triang.def. A1 A2 A3 (in r_ntri.ne.0)
      REAL*4  R_AXES(MNANT)              ! offset between azim. and elev. axes (
      REAL*4 R_PHLO1(MNANT)              ! LO1 phase offset
      REAL*4 R_PHLO3(MNANT)              ! LO3 phase offset
*-- not in data ---
      CHARACTER*20 R_CONFIG              ! extended configuration
*
* Section -22	RF Frequency Setup
      CHARACTER*12 R_LINE                ! Line name (12 chars)
      INTEGER R_ISB                      ! Side band (+1 upper, -1 Lower)
      INTEGER R_LOCK                     ! lock sign (+1 High, -1 Low)
      REAL*8  R_RESTF                    ! Rest Frequency (MHz)
      REAL*8  R_FLO1                     ! LO1 frequency (MHz)
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Was R_FLO2 previously
      REAL*8  R_FLO1_REF                 ! LO2 frequency (MHz)
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      REAL*8  R_FIF1                     ! IF1 frequency (MHz)
      REAL*4 R_VELOC                     ! Source velocity (km/s)
      INTEGER*4 R_TYPEV                  ! type of velocity (LSR / SUN)
      REAL*4 R_DOPPL                     ! doppler veloc. correction (frac. of c)
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! 
      INTEGER*4 R_NPOL_REC               ! Number of polar. available in Rx
      INTEGER*4 R_QUARTER(2)             ! Selected quarters (IF1, IF2)
      INTEGER*4   R_QWPLATE(MNANT)         ! Quarter-wave plate ON or OFF
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim} 
      INTEGER*4 R_ATTCOM(MPOL_REC,MNANT) ! Attenuation command (dB)        
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      INTEGER*4 ALIGF                    ! Alignement des REAL*8
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -23 Continuum setup
      INTEGER R_NSB                      ! Nb. of continuum sidebands (1-2)
      INTEGER R_NBAND                    ! Nb. of continuum sub-bands (ex: 10)
      INTEGER R_NCDAT                    ! Nb. of cmplx values per baseline 
      REAL*4  R_CRCH(2)                  ! Reference channel in each sideband
      REAL*4  R_CVOFF(2)                 ! Vel. in each sideband
      REAL*4  R_CVRES(2)                 ! Vel. resolution in each sideband
      REAL*8  R_CRFOFF(2)                ! Rest Freq in each sideband
      REAL*4  R_CRFRES(2)                ! Freq. resolution in RF(MHz), signed
      CHARACTER*12 R_CNAM(2)             ! line name
      REAL*8  R_CFCEN(MCCH)              ! Center freq (MHz), for each sub-band
      REAL*4  R_CFWID(MCCH)              ! Freq. width (MHz)
      INTEGER R_SBAND(2)                 ! present side bands (1:USB, 2:LSB, 3:D
*
* Section -24 Line setup
      INTEGER R_LBAND                    ! Number of sub-bands (per baseline)
      INTEGER R_LNTCH                    ! total number of channels (<mlch)
      LOGICAL R_LFOUR                    ! Fourier Transform done
      INTEGER R_LNCH(MRLBAND)            ! Number of channels in sub-band
      INTEGER R_LICH(MRLBAND)            ! Channel offset in corr. (Ch 0)

      REAL*8  R_LFCEN(MRLBAND)           ! center freq (MHz)
      REAL*4  R_LFRES(MRLBAND)           ! Freq. resolution in IF1(MHz), signed
      REAL*4  R_LRCH(2,MRLBAND)          ! Reference channel (in subband) (U,L)

      REAL*4  R_LVOFF(2,MRLBAND)         ! Vel. in RF (MHz)
      REAL*4  R_LVRES(2,MRLBAND)         ! Vel. resolution in RF(MHz)
      REAL*8  R_LRFOFF(2,MRLBAND)        ! Freq. offset in RF (MHz)
      REAL*4  R_LRFRES(2,MRLBAND)        ! Freq. resolution in RF(MHz), signed
      CHARACTER*12 R_LNAM(2,MRLBAND)     ! line name
      INTEGER R_LILEVU(MRLBAND,MNANT)    ! sampling levels (U part)
      INTEGER R_LNSB                     ! number of line sidebands
      INTEGER R_LSBAND(2)                ! line sidebands
      REAL*4  R_LCENCH(MRLBAND)          ! Channel number of R_LFCEN (NEW, 1/DEF
      REAL*4  R_LDELOFF(MNANT,MRLBAND)   ! delay offsets       (NEW, 0/def)
      INTEGER R_LMODE                    ! old sp.corr = 0, new = 1  (NEW, 0/def)
      INTEGER R_LILEVL(MRLBAND,MNANT)    ! sampling levels (L part)
      INTEGER R_IUNIT(MRLBAND)           ! Physical unit number
      INTEGER R_BAND4(MRLBAND)           ! 4th conv. band (0,1,2) = (USB,LSB,DSB)
      INTEGER R_PHSELECT(MNANT,MRLBAND)  ! origin of phase correction (1=1mm,2-22GHz)
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! 
      REAL*8  R_FLO2(MRLBAND)            ! LO2 frequency
      REAL*8  R_FLO2BIS(MRLBAND)         ! LO2bis frequency
      INTEGER R_BAND2BIS(MRLBAND)        ! 2nd bis conv. band (0,1) = (USB,LSB)
      REAL*8  R_FLO3(MRLBAND)            ! LO3 frequency
      REAL*8  R_FLO4(MRLBAND)            ! LO4 frequency
      INTEGER R_LPOLMODE(MRLBAND)        ! polar. mode (1/2)
      INTEGER R_LPOLENTRY(MNANT,MRLBAND) ! polarization entry for each antenna 
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim}
      !! TO BE REMOVED !!
      REAL*4  R_IFATTN(2,MNANT,MRLBAND)  ! Real IF attenuation (linear scale)

\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -25 Scanning Fonction
      INTEGER R_SCATY                    ! Scan type (1=focus, 2=lambda, 3=beta)
      LOGICAL R_MOBIL(MNANT)             ! .true. in antenna is scanning.
      REAL R_COLLAZ(MNANT)               ! Azimuth collimation
      REAL R_COLLEL(MNANT)               ! elevation collimation
      REAL R_CORFOC(MNANT)               ! focus correction(mm) 
      INTEGER R_NSWITCH                  ! number of switching states
      REAL R_WSWITCH(MSWITCH)            ! switching weights
      REAL R_PSWITCH(2,MSWITCH)          ! switching offsets
      INTEGER R_PMODEL                   ! pointing model type (1-Bure,2-Alma)
      INTEGER R_NPMODEL                  ! number of coefficients
      REAL R_CPMODEL(MPMODEL,MNANT)      ! coefficients
*
* Section -26 Atmospheric Parameters
      INTEGER R_MODE                     ! Cal mode (man, aut, water, trec, ...)
      INTEGER R_NREC                     ! number of stored receivers
      REAL*4  R_PAMB                     ! Ambient pressure
      REAL*4  R_TAMB                     ! Ambient temperature
      REAL*4  R_ALTI                     ! Site altitude (km)
      REAL*4  R_HUMID                    ! % humidity
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Following parameters have MPOL_REC dimension
      REAL*4  R_H2OMM(MPOL_REC,MNANT)    ! mm of precipitable water
      REAL*4  R_TATMS(MPOL_REC,MNANT)    ! Atmospheric temperature
      REAL*4  R_TATMI(MPOL_RECMNANT)     ! same for image side band
      REAL*4  R_TAUS(MPOL_REC,MNANT)     ! Opacity at Zeinth
      REAL*4  R_TAUI(MPOL_REC,MNANT)     ! same for image side band
      REAL*4  R_BEEF(MPOL_REC,MNANT)     ! beam efficiency
      REAL*4  R_FEFF(MPOL_REC,MNANT)     ! forward efficiency
      REAL*4  R_TCHOP(MPOL_REC,MNANT)    ! Temperature of Chopper
      REAL*4  R_TCOLD(MPOL_REC,MNANT)    ! Temperature of Cold Load
      REAL*4  R_TREC(MPOL_REC,MNANT)     ! Receiver DSB temperature
      REAL*4  R_GIM(MPOL_REC,MNANT)      ! relative gain (image/signal)
      REAL*4  R_CSKY(MPOL_REC,MNANT)     ! Counts on Sky
      REAL*4  R_CCHOP(MPOL_REC,MNANT)    ! Counts on Chopper
      REAL*4  R_CCOLD(MPOL_REC,MNANT)    ! Counts on Cold Load
      REAL*4  R_TSYSS(MPOL_REC,MNANT)    ! temp sys (sig side band)
      REAL*4  R_TSYSI(MPOL_REC,MNANT)    ! temp sys (image side band)
      REAL*4  R_CEFF(MPOL_REC,MNANT)     ! chopper efficiency
      INTEGER  R_CMODE(MPOL_REC,MNANT)   ! cal mode
      REAL*4  R_JYKEL(MPOL_REC,MNANT)    ! Jy to Kelvin factor
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      REAL*4  R_AVWIND                   ! Aver. Wind (km/s)
      REAL*4  R_AVWINDIR                 ! Aver. Wind Direction (deg.)
      REAL*4  R_TOPWIND                  ! Top Wind (km/s)
      REAL*4  R_TOPWINDIR                ! Top Wind Direction (deg.)
      REAL*4  R_TCABIN(MNANT)            ! Temperature of Cabin
      REAL*4  R_TDEWAR(3,MNANT)          ! Temperatures of Dewar
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      REAL*4  R_TOTSCALE(m_pol_rec,MNANT)! Digital to physical power scale
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -27 Atmospheric monitoring receiver
      INTEGER R_NREC_MON                 ! rec. number of monitoring receiver
      REAL*4  R_FRS_MON                  ! freq of monitoring receiver
      REAL*4  R_FRI_MON                  ! freq of monitoring receiver(Image)
      REAL*4  R_H2O_MON(MNANT)           ! mm of precipitable water
      REAL*4  R_TATMS_MON(MNANT)         ! Atmospheric temperature
      REAL*4  R_TATMI_MON(MNANT)         ! same for image side band
      REAL*4  R_TAUS_MON(MNANT)          ! Opacity at Zenith
      REAL*4  R_TAUI_MON(MNANT)          ! same for image side band
      REAL*4  R_FEFF_MON(MNANT)          ! forward efficiency
      REAL*4  R_TCHOP_MON(MNANT)         ! Temperature of Chopper
      REAL*4  R_TCOLD_MON(MNANT)         ! Temperature of Cold Load
      REAL*4  R_TREC_MON(MNANT)          ! Receiver DSB temperature
      REAL*4  R_GIM_MON(MNANT)           ! relative gain (image/signal)
      REAL*4  R_CSKY_MON(MNANT)          ! Counts on Sky
      REAL*4  R_CCHOP_MON(MNANT)         ! Counts on Chopper
      REAL*4  R_CCOLD_MON(MNANT)         ! Counts on Cold Load
      REAL*4  R_TSYS_MON(MNANT)          ! temp sys (double side band)
      INTEGER R_CMODE_MON(MNANT)         ! cal mode
      REAL*4  R_PATH_MON(MNANT)          ! mm of path due to H2O (nu_obs)
      REAL*4  R_TEM_MON(MNANT)           ! atmospheric brightness (nu_mon)
      REAL*4  R_DPATH_MON(MNANT)         ! mm of path per deg. of atm emiss (nu_
      REAL*4  R_MAGIC_MON(2)             ! Empirical scale factor on path.
      LOGICAL R_OK_MON(MNANT)            ! Validity of correction
*
* Section -28 Passband Calibration
      INTEGER R_BPC                      ! BPC has been stored (2=IF function)
      INTEGER R_BPCDEG                   ! Degree of interpolating polynomial
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Following parameters have MPOL_REC dimension      
      REAL*4  R_BPCCAMP(MNBCINPUT,2,MNBAS,MCCH)
      REAL*4  R_BPCCPHA(MNBCINPUT,2,MNBAS,MCCH)
      REAL*4  R_BPCLAMP(MNBCINPUT,2,MNBAS,MRLBAND,0:MBPCDEG)   ! polynomial coefficients
      REAL*4  R_BPCLPHA(MNBCINPUT,2,MNBAS,MRLBAND,0:MBPCDEG)   ! polynomial coefficients
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim}
      COMPLEX R_BPCSBA(MNBCINPUT,2,MNBAS)          !
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      COMPLEX R_BPCSBA(2,MNBAS)          !
      INTEGER R_BPFDEG                   ! Degree of interpolating polynomial
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      REAL*4  R_BPFLIM(MNBCINPUT,2)      ! IF frequency interval (min, max)
      !! NEW !! Following parameters have MNBCINPUT dimension      
      REAL*4  R_BPFAMP(MNBCINPUT,2,MNBAS,0:MBPCDEG)! polynomial coefficients
      REAL*4  R_BPFPHA(MNBCINPUT,2,MNBAS,0:MBPCDEG)! polynomial coefficients
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -29 Instrumental Calibration
      INTEGER R_IC                       ! IC has been stored
      INTEGER R_ICDEG                    ! Degree of interpolating polynomial
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Following parameters have MPOL_REC dimension      
      REAL*4 R_ICPHA(MPOL_REC,2,MNBAS,0:MICDEG)   ! polynomial coefficients
      REAL*4 R_ICAMP(MPOL_REC,2,MNBAS,0:MICDEG)   ! polynomial coefficients
      REAL*4 R_ICRMS(MPOL_REC,2,MNBAS,2)          ! amp-phase rms
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -30 Data Section Descriptor
      INTEGER R_NDUMP                    ! Number of records
      INTEGER R_LDPAR                    ! Length of data header (longwords)
      INTEGER R_LDATC                    ! length of continuum data (")
      INTEGER R_LDATL                    ! length of line data      (")
      INTEGER R_LDUMP                    ! length of record         (")
      INTEGER R_NDATL                    ! number of line datas (1,2)
*
* Section -31 Antenna-based Passband Calibration
      INTEGER R_ABPC                     ! ABPC has been stored (2=IF function)
      INTEGER R_ABPCDEG                  ! Degree of interpolating polynomial
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Following parameters have MNBCINPUT dimension      
      REAL*4  R_ABPCCAMP(MNBCINPUT,2,MNBAS,MCCH)
      REAL*4  R_ABPCCPHA(MNBCINPUT,2,MNBAS,MCCH)
      REAL*4  R_ABPCLAMP(MNBCINPUT,2,MNBAS,MRLBAND,0:MBPCDEG)  ! polynomial coefficients
      REAL*4  R_ABPCLPHA(MNBCINPUT,2,MNBAS,MRLBAND,0:MBPCDEG)  ! polynomial coefficients
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim}
      COMPLEX R_ABPCSBA(MPOL_REC,2,MNBAS)         !
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      INTEGER R_ABPFDEG                  ! Degree of interpolating polynomial
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      REAL*4  R_ABPFLIM(MNBCINPUT,2)     ! IF frequency interval (min, max)
      REAL*4  R_ABPFAMP(MNBCINPUT,2,MNBAS,0:MBPCDEG)     ! polynomial coefficients
      REAL*4  R_ABPFPHA(MNBCINPUT,2,MNBAS,0:MBPCDEG)     ! polynomial coefficients
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -32 Antenna-based Instrumental Calibration
      INTEGER R_AIC                      ! IC has been stored
      INTEGER R_AICDEG                   ! Degree of interpolating polynomial
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Following parameters have MPOL_REC dimension
      REAL*4 R_AICPHA(MPOL_REC,2,MNANT,0:MICDEG)  ! polynomial coefficients
      REAL*4 R_AICAMP(MPOL_REC,2,MNANT,0:MICDEG)  ! polynomial coefficients
      REAL*4 R_AICRMS(MPOL_REC,2,MNBAS,2)         ! amp-phase rms
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -33 Data File 
      INTEGER R_DXNUM                    ! Data File index number of data
      CHARACTER*32 R_DFILE               ! Data file name without extension
*
* Section -34 Data Modifier 
      INTEGER R_DMAFLAG(MNANT)           ! Antenna flags (user)
      INTEGER R_DMBFLAG(MNBAS)           ! Baseline flags (user)
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Following paramaters have MPOL_REC/DAT dimension
      REAL*4 R_DMATFAC(MPOL_REC,2,MNANT)          ! Applied atmosph. cal factor(U,L)
      REAL*4 R_DMDELAY(MPOL_DAT,MNANT)            ! Delay
      REAL*4 R_DMCAMP(MPOL_DAT,2,MNBAS,MCCH)      ! continuum amplitudes
      REAL*4 R_DMCPHA(MPOL_DAT,2,MNBAS,MCCH)      ! continuum phases
      REAL*4 R_DMLAMP(MPOL_DAT,2,MNBAS,MRLBAND)   ! line amplitudes
      REAL*4 R_DMLPHA(MPOL_DAT,2,MNBAS,MRLBAND)   ! line phases
      REAL*4 R_DMLDPH(MPOL_DAT,2,MNBAS,MRLBAND)   ! line phase slopes
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -35 Water Vapor Radiometer  
! data input
      INTEGER R_WVRNCH(MNANT)            ! number of channels (=3; 0 if antenna not equipped)
      REAL R_WVRFREQ(MWVRCH,MNANT)       ! central frequencies (MHz)
      REAL R_WVRBW(MWVRCH,MNANT)         ! bandwidths (MHz)
      REAL R_WVRTAMB(MNANT)              ! Temp ambient load (K)
      REAL R_WVRTPEL(MNANT)              ! Temp Peltier cooler (K)
      REAL R_WVRTCAL(MWVRCH,MNANT)       ! K/count channel gains
      REAL R_WVRREF(MWVRCH,MNANT)        ! average counts on reference observation
      REAL R_WVRAVER(MWVRCH,MNANT)       ! average counts on current observation
      REAL R_WVRAMB(MWVRCH,MNANT)        ! average counts on last ambient meas.
      REAL R_WVRTREC(MWVRCH,MNANT)       ! receiver temperatures (K)
      REAL R_WVRFEFF(MWVRCH,MNANT)       ! coupling factor to sky
      REAL R_WVRLABTCAL(MWVRCH,MNANT)    ! LAB K/COUNT CHANNEL GAINS
      REAL R_WVRLABTREC(MWVRCH,MNANT)    ! LAB TREC
      REAL R_WVRLABTDIO(MWVRCH,MNANT)    ! LAB DIODE TEMPERATURE
!
! model output
      INTEGER R_WVRMODE(MNANT)           ! calibration mode
      REAL R_WVRH2O(MNANT)               ! prec. h2o (mm)
      REAL R_WVRPATH(MNANT)              ! H2O vap. pathlength (mum)
      REAL R_WVRTSYS(MWVRCH,MNANT)       ! system temperature (K)
      REAL R_WVRDPATH(MWVRCH,MNANT)      ! Kelvin to H2O vap. pathlength (model, mum/K)
      REAL R_WVRFPATH(MWVRCH,MNANT)      ! Kelvin to H2O vap. pathlength (empirical, mum/K)
      REAL R_WVRLIQ(MWVRCH,MNANT)        ! Kelvin to H2O liquid emission (K/K)
      REAL R_WVRDCLOUD(MWVRCH,MNANT)     ! Kelvin to H2O liq. pathlength (mum/K)
      REAL R_WVRTATM(MNANT)              ! temperature of atmosphere (K)
      INTEGER R_WVRQUAL(MNANT)           ! quality code (usable or not)
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim} 
      !! NEW !!
      LOGICAL R_OK_WVR(MNANT)            ! validity of WVR correction
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*
* Section -36 Single-Dish Holography (ALMA)
*
      REAL R_TRANDIST                    ! transmitter distance (m)
      REAL R_TRANFOCU                    ! transmitter refocus  (mm)
*
      INTEGER R_LASTONE, R_ALIGN3, R_ALIGN4, R_ALIGN5, r_align6

      
\end{verbatim}

\color{red} \vspace{-7mm} \begin{verbatim} 
      !! NEW !!
*
* Section -37 Antenna-based polarization calibration
      INTEGER R_PAIC                       ! PIC has been stored
      INTEGER R_PAICDEG                    ! Degree of interpolating polynomial
      REAL*4 R_PAICPHA(MPOL_REC,2,MNANT,0:MICDEG)   ! polynomial coefficients
      REAL*4 R_PAICAMP(MPOL_REC,2,MNANT,0:MICDEG)   ! polynomial coefficients
      REAL*4 R_PAICRMS(MPOL_REC,2,MNANT,2)          ! amp-phase rms      
      COMPLEX R_ALEAKAGE(MPOL_REC,MNANT)   ! polarisation leakage
      REAL R_ADIFPHA                       ! (p-q) phase

*
* Section -38 Baseline-based polarization calibration
      INTEGER R_PIC                       ! IC has been stored
      INTEGER R_PICDEG                    ! Degree of interpolating polynomial
      REAL*4 R_PICPHA(MPOL_DAT,2,MNBAS,0:MICDEG)   ! polynomial coefficients
      REAL*4 R_PICAMP(MPOL_DAT,2,MNBAS,0:MICDEG)   ! polynomial coefficients
      REAL*4 R_PICRMS(MPOL_DAT,2,MNBAS,2)          ! amp-phase rms      
      REAL R_LEAKAGE(MPOL_BAS,,MNBAS)     ! polarisation leakage
      REAL R_DIFPHA                       ! (p-q) phase


*
* Section -43 Virtual continuum unit
      INTEGER R_VNBAND                    ! Nb of continuum virtual units
      INTEGER R_CPOLMODE(MPOLBAND)        ! polar. mode (1/2/3)
      INTEGER R_CNPOL(MPOLBAND)           ! number of available polarizations (1,2,4)
      INTEGER R_CPOL(MPOL_DAT,MPOLBAND)   ! polarizations (11=H,22=V,12=HV, etc) 
      INTEGER R_CNUNIT(MPOLBAND)          ! nb of physical unit used (>1 if virtual unit)
      INTEGER R_CIUNIT(MRLBAND,MPOLBAND)  ! physical correlator units

*
* Section -44 Virtual line unit
      INTEGER R_VLBAND                    ! Nb of line virtual units
      INTEGER R_LPOLMODE(MPOLBAND)        ! polar. mode (1/2/3)
      INTEGER R_LNPOL(MPOLBAND)           ! number of available polarizations (1,2,4)
      INTEGER R_LPOL(MPOL_DAT,MPOLBAND)   ! polarizations (11=H,22=V,12=HV, etc) 
      INTEGER R_LNUNIT(MPOLBAND)          ! nb of physical unit used (>1 if virtual unit)
      INTEGER R_LIUNIT(MRLBAND,MPOLBAND)  ! physical correlator units
\end{verbatim} \color{black}



\newpage
\section{Data header (clic\_dheader.inc)}

\vspace{-7mm} \begin{verbatim}
*
* Data structures : Data Header DNOISE
      INTEGER DH_VOID              ! Dummy alignment word
      INTEGER DH_DUMP              ! dump number
      INTEGER DH_OBS               ! MJ date
      REAL DH_INTEG                ! Integration time
      REAL*8 DH_UTC                ! UTC (sec.)
      REAL*8 DH_SVEC(3)            ! source direction (H-DELTA coords)
      REAL DH_TEST0(10)            ! test parameters (global)
*
      INTEGER DH_AFLAG(MNANT)      ! Antenna flags
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! Following parameters have MPOL_REC dimension
      REAL DH_TOTAL(MPOL_REC,MNANT)         ! Total power for each antenna
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim} 
      REAL DH_ATFAC(MPOL_REC,2,MNANT)       ! Applied atmosph. cal factor(U,L)
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      REAL DH_RMSPE(2,MNANT)       ! rms pointing error
      REAL DH_DELCON(MNANT)        ! delay used for continuum (ns)
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      REAL DH_DELLIN(MPOL_REC,MNANT)        ! delay used for line (ns)
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      REAL DH_DELAYC(MNANT)        ! delay computed (ns)
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      REAL DH_DELAY(MPOL_REC,MNANT)         ! delay offset (ns)
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      REAL DH_PHASEC(MNANT)        ! 1st LO phase, computed (radians)
      REAL DH_PHASE(MNANT)         ! 1st LO phase rotation offset (radians)
      REAL DH_RATEC(MNANT)         ! 1st LO rate, computed (radians/sec)
      REAL DH_CABLE(MNANT)         ! measured cable length (radians)
      INTEGER DH_GAMME(MNANT)      ! phasemeter gamme (by antenna)
      REAL DH_TEST1(5,MNANT)       ! test parameters (by antenna)
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      REAL DH_RMSAMP(MPOL_REC,2,MNBAS)      ! rms amplitude (0 if no aver)
      REAL DH_RMSPHA(MPOL_REC,2,MNBAS)      ! rms phase (rad, 0 if no aver)
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
      REAL DH_OFFFOC(MNANT)        ! focus offset (mm)
      REAL DH_OFFLAM(MNANT)        ! lambda offset (rad)
      REAL DH_OFFBET(MNANT)        ! beta offset (rad)
      INTEGER DH_BFLAG(MNBAS)      ! Baseline flags
      REAL DH_UVM(2,MNBAS)         ! Base line components (meters)
      COMPLEX DH_INFAC(MPOL_REC,2,MNBAS)    ! Applied instrum. cal factor(U,L)
                                            ! ** OBSOLETE **
* added 2001-06-11 RL RM
      REAL    DH_WVR(MWVRCH,MNANT) ! counts of each WVR channel
      INTEGER DH_WVRSTAT(MNANT)    ! status word
* 1 = noise tube on
* 2 = ambient load on (commanded)
* 4 = ambient load on (sensor)
* 8 = Peltier Alarm on
\end{verbatim} \color{blue} \vspace{-7mm} \begin{verbatim} 
      !! NEW !! New parameters added for Total Power measurements
      REAL DH_ACTP(MPOL_REC,MNANT,MRLBAND) ! measured by auto-correlation
      REAL DH_ANTTP(MPOL_REC,MNANT)        ! measured in each antenna (2 pol.)
\end{verbatim} \color{red} \vspace{-7mm} \begin{verbatim} 
      !! NEW Parallactic angle
      REAL DH_PARA                        ! Parallactic angle
\end{verbatim} \color{black} \vspace{-7mm} \begin{verbatim}
*--- not in data ---
      CHARACTER*12 DH_TIME
      CHARACTER*12 DH_DATE
      COMPLEX DH_AVERAG(2,MNBAS)   ! average visibility
      REAL ALIG

\end{verbatim}

\newpage
\section{Data section}

Current data storage: \\

\begin{center}
\begin{tabular}{cll}
Axis & Parameter       & Dimension \\
1 & complex visibility & 2 \\
2 & frequency          & Nchannels(unit) \\
3 & correlator unit    & Nunit \\
4 & sideband           & 2 \\
5 & baseline           & Nbas \\
\end{tabular}
\end{center}

Proposed new data storage (new axis 3 and 7):\\

\begin{center}
\begin{tabular}{cll}
Axis & Parameter       & Dimension \\
1 & complex visibility & 2 \\
2 & frequency          & Nchannels(unit) \\
\textcolor{red}{3} & \textcolor{red}{polarization} & \textcolor{red}{Nprod(unit)} \\
4 & correlator unit    & \textcolor{red}{Nunit} \\
5 & sideband           & 2 \\
6 & baseline           & Nbas \\
\textcolor{red}{7} & \textcolor{red}{auto/cross} & \textcolor{red}{1 or 2} \\
\end{tabular}
\end{center}

\textcolor{red}{The number of units is the sum of the physical and
virtual units.} \\

\textcolor{red}{New axis 3 is the polarization. Nprod = 1,2, or 4, and
depends on the unit.}  \\

\textcolor{red}{New axis 7 is to allow to add auto-correlation after
the cross-correlation.  This is to be able to read ALMA data, which
will have both auto- and cross-correlation measured simultaneously.}

\end{document}



