SMA OBSERVER CENTER


Welcome jzhao

SMA Wiki

 
Proposed new SMA data file format
Taco
last updated: 2013-03-28 09:30:59

The files are listed here alphabetically, by file name. Only the files which will be changed when we convert to the new format are listed. For a description of these unchanged files, see this page

CHANGED: We will be writing all integers and floats in the x86, Little Endian
byte order.

bl_read
This file contains the baseline information.   There is one fixed-length
record written per receiver per sideband per baseline per scan.

The order of the loops writing out these records is:
receiver
    sideband
        polarization
            baseline

so baseline ID is the most rapidly varying index.   For most tracks
receiver and polarization only have a single value, and the loops
collapse to:
sideband
    baseline

Each record contains:

typedef struct __attribute__((packed)) blhDef {
  int 	blhid     ; /*	proj. baseline id #       */
                    /* This is a unique identifier*/
                    /* for the baseline           */
  int 	inhid     ; /*	integration id #          */
  short	isb       ; /*	sideband int code         */
  short	ipol      ; /*	polarization int code     */
                    /*  0 = Unknown               */
                    /*  1 = RR                    */
                    /*  2 = RL                    */
                    /*  3 = LR                    */
                    /*  4 = LL                    */
CHANGED: Dropped element pa - was not used 
  short	ant1rx      /*  This flag is meaningful   */ CHANGED: Used to be called iaq
                    /*  only in Dual Rx Polar     */
                    /*  mode, when it is used to  */
                    /*  specify the receiver on   */
                    /*  used on the lower number- */
                    /*  receiver on the baseline. */
                    /*  0 = 345 Rx                */
                    /*  1 = 400 Rx                */
                    /*  anything else is bad data.*/
  short	ant2rx      /*  In full polarization mode */ CHANGED: Used to be called ibq
                    /*  ibq encodes the high ant  */
                    /*  number Rx                 */
                    /*  0 = 345 Rx                */
                    /*  1 = 400 Rx                */
CHANGED: Dropped element icq - was not used 
  short	pointing  ; /*	pointing data int code    */ CHANGED: Used to be called ioq
                    /*  = 1 for no offsets        */
                    /*  = 0 otherwise             */
                    /* Used to indicate off       */
                    /* source ipoint scans.       */
  short	irec      ; /*	receiver int code         */
                    /*  0 = 230                   */
                    /*  1 = 345                   */
                    /*  2 = 400                   */
                    /*  3 = 600                   */
                    /* -1 = Rx unknown            */
CHANGED: Dropped element iifc - was not used 
  float	u         ; /*	u coord for bsl (klambda) */
  float	v         ; /*	v coord. for bsl          */
  float	w         ; /*	w coord. for bsl          */
  float	prbl      ; /*	projected baseline        */
CHANGED: Dropped element angres - was not used 
CHANGED: Dropped element vis - was not used 
  float	coh       ; /*	coherence estimate        */
CHANGED: Dropped element sigcoh - was not used 
CHANGED: Dropped element csnr - was not used 
CHANGED: Dropped element vflux - was not used 
CHANGED: Dropped element cnoise - was not used 
  double avedhrs  ; /*	hrs offset from ref-time  */
  float	ampave    ; /*	ave continuum amp         */
  float	phaave    ; /*	ave continuum phase       */
CHANGED: Dropped element tpvar - was not used 
  int 	blsid     ; /*	physical baseline id #    */
  short	iant1     ; /*	antenna 1 int code        */ RENAMED: was itel1
  short	iant2     ; /*	antenna 2 int code        */ RENAMED: was itel2
  int ant1TsysOff ; /* Byte offset to start of    */ CHANGED: Added for new format
                    /* Tsys information for ant 1 */
                    /* of this baseline and this  */
                    /* scan.                      */
  int ant2TsysOff ; /* Byte offset for ant 2 Tsys */ CHANGED: Added for new format
  short	iblcd     ; /*	baseline int code         */
  float	ble       ; /*	bsl east vector           */
  float	bln       ; /*	bsl north vector          */
  float	blu       ; /*	bsl up vector             */
CHANGED: Dropped element soid - was not used
  int spareint1   ; /* Spare Int. for future use  */ CHANGED: Added for new format
  int spareint2   ; /*                            */ CHANGED: Added for new format
  int spareint3   ; /*                            */ CHANGED: Added for new format
  int spareint4   ; /*                            */ CHANGED: Added for new format
  int spareint5   ; /*                            */ CHANGED: Added for new format
  int spareint6   ; /*                            */ CHANGED: Added for new format
  double sparedbl1; /* Spare Dbl. for future use  */ CHANGED: Added for new format
  double spatedbl2; /*                            */ CHANGED: Added for new format
  double sparedbl3; /*                            */ CHANGED: Added for new format
  double sparedbl4; /*                            */ CHANGED: Added for new format
  double sparedbl5; /*                            */ CHANGED: Added for new format
  double sparedbl6; /*                            */ CHANGED: Added for new format
} blhDef;
/* the size of blhDef is 158 bytes */ CHANGED: Used to be 118 bytes

in_read
This file contains scan header information.   It consists of fixed-length
records.   There is one record written for each scan.   The format is

typedef struct __attribute__((packed)) inhDef {
CHANGED: Dropped element conid - was not used
CHANGED: Dropped element icocd - was not used
  int 	traid     ; /* track id #                */
                    /* Set to the Project ID     */
  int 	inhid     ; /* integration id #          */
  int 	ints      ; /* integration #             */
                    /* In reality, same as inhid */
CHANGED: Dropped element itq - was not used
  float	az        ; /* azimuth  (degrees)        */
  float	el        ; /* elevation (degrees)       */
  float	ha        ; /* hour angle (hours)        */
  short	iut       ; /* ut int code               */
  short	iref_time ; /* ref_time int code         */
  double dhrs     ; /* hrs from ref_time         */
  float	vc        ; /* vcorr for vctype          */
CHANGED: Dropped element ivctype - was not used
  double sx       ; /* x vec. for bsl.           */
  double sy       ; /* y vec. for bsl.           */
  double sz       ; /* z vec. for bsl.           */
  float	rinteg    ; /* actual int time           */
  int 	proid     ; /* project id #              */
  int 	souid     ; /* source id #               */
  short	isource   ; /* source int code           */
  short	ivrad     ; /* Id number for the radial  */ CHANGED: Used to be called ipos
                    /* velocity                  */
  float	offx      ; /* offset in x               */ CHANGED: Will now hold mosaic offset
                    /* used for RA offset        */
  float	offy      ; /* offset in y               */ CHANGED: Will now hold mosaic offset
                    /* used for Dec offset       */
CHANGED: Dropped element iofftype - was not used
  short	ira       ; /* ra int code               */
  short	idec      ; /* dec int code              */
  double rar      ; /* ra (radians)              */
  double decr     ; /* declination (radians)     */
  float	epoch     ; /* epoch for coord.          */
                    /* always set to 2000.0      */
CHANGED: Dropped element sflux - was not used
  float	size      ; /* source size (arcsec)      */
  int spareint1   ; /* Spare Int. for future use  */ CHANGED: Added for new format
  int spareint2   ; /*                            */ CHANGED: Added for new format
  int spareint3   ; /*                            */ CHANGED: Added for new format
  int spareint4   ; /*                            */ CHANGED: Added for new format
  int spareint5   ; /*                            */ CHANGED: Added for new format
  int spareint6   ; /*                            */ CHANGED: Added for new format
  double sparedbl1; /* Spare Dbl. for future use  */ CHANGED: Added for new format
  double spatedbl2; /*                            */ CHANGED: Added for new format
  double sparedbl3; /*                            */ CHANGED: Added for new format
  double sparedbl4; /*                            */ CHANGED: Added for new format
  double sparedbl5; /*                            */ CHANGED: Added for new format
  double sparedbl6; /*                            */ CHANGED: Added for new format
} inhDef;
/* The size of inhDef is 188 bytes */ CHANGED: Was 132 bytes

sch_read
This is the file that actually contains the visibility data.   Unlike most
of the files containing binary data, the records in this file are of
wildly varying length, depending upon the resolution of the spectrometer
band.   There is one record written for each scan, and it contains
the packed visibility data for all chunks and the pseudocontinuum
channels.   Here's the format:

Each scan has one header containing:

One 32 bit integer containing the integration number
One 32 bit integer containing the number of bytes for this record

after that short header, one record of the following type is written
for every spectral band, including the pseudocontinuum channel:


typedef struct __attribute__((packed)) schDef {
  int inhid	 ;  /* integration id # */
CHANGED: Dropped element form[4] - was always "I2-C" 
  int nbyt	 ;  /* the number of bytes in one integration of data */
CHANGED: Dropped element nbyt_pack - was same as nbyt 
  short *packdata;  /* integer array containing the data in the format above	*/
} schDef;

The spectral bands are stored in packdata as follows: 

In double bandwidth mode, the nested loops are
sideband
    polarization
         baseline
             spectral band
in all other observing modes the nested loops are
receiver
    sideband
        polarization
            baseline
                spectral band
so spectral band is always the most rapidly varying index

The pseudocontinuum band is the first band stored,
followed by the spectral bands (usually 24 or 48 of them).

Note that the above definition, although correct (it is from the C source code
file for the program writing the data) is somewhat misleading.   "packdata" is
not a pointer at all.   Instead, packdata is the beginning of a varliable-length
array of short integers containing the visibilities.   Note that there is only one
header record containing inhid and nbyt for an entire scan.   After that scan there
there are packed arrays of short integers containing the visibilities for all the
spectral bands (and the pseudo-continuum) for all baselines, polarizations, receivers
and sidebands.

CHANGED for new format:
In the old format, each spectral band had the following format for its entries in
the packdata array:

byte offset        Description
0                  The integration time in 10ths of a second
2                  Always 0
4                  Always 100
6                  Always 0
8                  The exponent used to scale the visibilities
10                 Real value for channel 0
12                 Imaginary value for channel 0
14                 Real value for channel 1
16                 Imaginary value for channel 1
...

In the new format, the values above that are not needed have been dropped, so for each
band the packdata array now contains just the following:

byte offset        Description
0                  The exponent used to scale the visibilities (scaleExp)
2                  Real value for channel 0
4                  Imaginary value for channel 0
6                  Real value for channel 1
8                  Imaginary value for channel 1
...

Note that the visibility values should be multiplied by 2^scaleExp.

sp_read
This file contains the header information for each individual spectral band
of data.   A spectral band can be either a correlator chunk or the pseudo-continuum
channel.   So, for example, if your file contains 2814 scans, and you had two
receivers active and all 24 correlator chunks and all 28 baselines, the total
number of records in this file would be 2814 * 28 * (24+1) * 2 * 2 = 7879200.

The loop order for writing this file is
scan
    receiver
        sideband
            polarization
                baseline
                    band

Here's what each record contains:

typedef struct __attribute__((packed)) sphDef {
  int 	sphid     ; /*  spectrum id #             */
  int 	blhid     ; /*  proj. baseline id #       */
  int 	inhid     ; /*  integration id #          */
  short	igq       ; /*  gain qual int code        */
  short	ipq       ; /*  passband qual int code    */
  short	iband     ; /*  spectral band int code    */
  short	ipstate   ; /*  pol state int code        */
  float	tau0      ; /*  Tau at 225 GHz from the   */
                    /*  CSO tau-o-meter           */
  double vel      ; /*  velocity (vctype) (km/s)  */
  float	vres      ; /*  velocity res.             */
CHANGED: Dropped element ivtype - was not used
  double fsky     ; /*  center sky freq.          */
  float	fres      ; /*  frequency res. (MHz)      */
  double gunnLO   ; /*  gunn freq x multiplier    */ CHANGED: Added for new format
  double cabinLO  ; /*  Frequency of BDA LO       */ CHANGED: Added for new format
  double corrLO1  ; /*  Correlator Block LO       */ CHANGED: Added for new format
  double corrLO2  ; /*  Correlator Chunk LO       */ CHANGED: Added for new format
CHANGED: Dropped element tssb - will use tsys_read file instead
  float	integ     ; /*  integration time          */
  float	wt        ; /*  weight (sec/tssb**2)      */
                    /*  Set to -(sec/tssb**2) if  */
                    /*  the data is flagged bad.  */
  int flags       ; /*  Holds per-baseline flags  */ New item
CHANGED: Dropped element itaper - was not used
  float	vradcat   ; /*  The catalog rad. velocity */ CHANGED: Renamed - was snoise
  short	nch       ; /*  # channels in spectrum    */
  short	nrec      ; /*  # of records w/i inh#     */
                    /*  Always set to 1           */
  int 	dataoff   ; /*  byte offset for data      */
CHANGED: Dropped element linid - was not used
CHANGED: Dropped element itrans - was not used
  double rfreq    ; /*  rest frequency (GHz)      */
CHANGED: Dropped element pasid - was not used
  short	corrblock ; /*  Correlator block number   */ CHANGED: Renamed - was gaiidamp
                    /*  0 for c1 chunk            */ 
  short	corrchunk ; /*  Correlator chunk number   */ CHANGED: Renamed - was gaiidpha
                    /*  NOT the sxx chunk name -  */
                    /* this value is always 1->4, */
                    /* except for the c1 chunk    */
CHANGED: Dropped element flcid - was not used
CHANGED: Dropped element atmid - was not used
  int spareint1   ; /* Spare Int. for future use  */ CHANGED: Added for new format
  int spareint2   ; /*                            */ CHANGED: Added for new format
  int spareint3   ; /*                            */ CHANGED: Added for new format
  int spareint4   ; /*                            */ CHANGED: Added for new format
  int spareint5   ; /*                            */ CHANGED: Added for new format
  int spareint6   ; /*                            */ CHANGED: Added for new format
  double sparedbl1; /* Spare Dbl. for future use  */ CHANGED: Added for new format
  double spatedbl2; /*                            */ CHANGED: Added for new format
  double sparedbl3; /*                            */ CHANGED: Added for new format
  double sparedbl4; /*                            */ CHANGED: Added for new format
  double sparedbl5; /*                            */ CHANGED: Added for new format
  double sparedbl6; /*                            */ CHANGED: Added for new format
} sphDef;
/* the size of sphDef is 188 bytes */ CHANGED: Was 100 bytes

tsys_read CHANGED: This structure has been completely redefined

typedef struct __attribute__((packed)) tsysRecordDef {
  int nMeasurements; /* Number of Tsys measurements for this antenna     */
  float *data;       /* The Tsys measurements.   This will be a variable */
                     /* length array, consisting of nMeasurement sets of */
                     /* four single precision floating point values.     */
                     /* Each set of four values will contain the         */
                     /* following values, in this order:                 */
                     /* Lower IF frequency for the Tsys value (GHz)      */
                     /* Upper IF frequency for the Tsys value (GHz)      */
                     /* LSB Tsys (K)                                     */
                     /* USB Tsys (K)                                     */
} tsysRecordDef;     /* Size of one record: 4+nMeasurements*16 bytes     */

The tsys_read file will hole all the Tsys measurements we have for each antenna,
along with the IF frequency ranges overwhich those Tsys measurements were acquired.
Eventually we hope to have a separate Tsys measurement for each 1 GHz interval
throughout the IF.   Note that although the definition for *data above is
technically correct, there is no pointer stored in that location.   Instead,
there is an array of floats, in groups of 4.