galfa idl routines

Last modified: Thu Mar 16 13:07:05 2023.


List of Routines


Routine Descriptions

CORMAPINP - INPUT A GALFA FILE AS CORRELATOR MAP.

[Next Routine] [List of Routines]
NAME:
cormapinp  - input a galfa file as correlator map.

SYNTAX:istat=cormapinp(desc, m,han=han,binp=binp,smo=smo)

ARGS:
  desc: {}  file descriptor from galopen() that points at the file
            to use. It will be rewound before inputing.
KEYWORDS:
     han:    if set then hanning smooth the data on input.
 binp[n]:{corget} If the data has already been read in, you can pass
             it into the routine via binp keyword. In this case no
             hanning smoothing is done
  smo   :    If the smooth keyword is set, then the frequency channels
             will be smoothed and then decimated by 7. The 7679 channels 
             will be reduced to 1097 channels. The header locations that
             specify the number of frequency channels will also be updated.
           
RETURNS:
   istat:    int  1: got all the strips
                  0: got part of requested map
                 -1: got no data.
m[2,pnts/strip,7]:{} array of structures holding the returned 
                       data and header. (see below for a description).
DESCRIPTION:
   Input a galfa file and load it into a map structure. If the binp=
keyword is used then you can pass in galfa data that has already been
read in via corgetm. Normally you would open the file with galopen()
and then pass in the descriptor. If the file is to be input, desc will
be rewound before the input.

   This routine differs from the interrim correlator cormapinp in 
 various ways:
  1. the old routine would read in an entire map. This routine reads in
     an entire file.
  2. The galfa files are not necessarily sychronized with the start
     of a mapping pattern on the telescope. A single strip on the telescope may
     take more than 1 galfa file or may start in the middle of a galfa file.
  3. You need to be careful with memory usage. Each file returned
     is about 300Mb. You need to keep an eye on the computer memory
     usage with top when processing. Don't make a whole lot of
     copies of the arrays..

   The map information is returned as an array m of structures. The 
dimensions of the array are:  

  m[pol,pntsperstrip,npixels].  pol=2

Each element of the array contains the information for a particular 
polarization,sample, and pixel. The following example is for 
 [0:polA,5:sample,6:beamnum]
 eg:

 m[0,5,6].h        the std header for pola, 
 m[0,5,6].hf       the fits header for pola, 
 m[0,5,6].d[7679]  the data   for pola
 m[0,5,6].p        the total power value for this sample (linear scale).
 m[0,5,6].az       the azimuth position in degrees at the endedncenter  of 
                   each sample.
 m[0,5,6].za       the zenith angle position in degrees at the end of
                   each sample.
 m[0,5,6].raHr     the RA in hours at the middle of each sample.
 m[0,5,6].decDeg   the declination in degrees at the middle of each sample.
 m[0,5,6].calscl   the cal scale factore (this value is currently not 
                   loaded.

m.h holds the older header information for this sample. It is mainly
blank. You should probably use the m.hf header for the info

The sample order is how it is found on disc. There is no reordering of
the data.

EXAMPLE:
 The standard file is 600 seconds long.
 idl
 @phil
 @galinit

 1. open file and input via cormapinp.

 file='/share/galfa/galf.20050623.a2055.0008.fits'
 istat=galopen(file,desc)
 istat=cormapinp(desc,m)

 the data would then have:
 m[0,4,3].d[*]      polA sample 4,beam 3
 m[1,4,3].d[*]      polB sample 4,beam 3

 the headers would be:
 m[0,4,3].hf        polA header sample 4,beam 3
 m[1,4,3].hf        polB header sample 4,beam 3

 2. open file, input it, and then pass the struct to cormapinp
 file='/share/galfa/galf.20050623.a2055.0008.fits'
 istat=galopen(file,desc)
 istat=corgetm(desc,600,b)
 istat=cormapinp(desc,m,b=b)


SEE ALSO:

NOTES: 
 Current status:
 * cormapsclk does not yet work since the cal info is not there.
 * i've tried cormapbc and it seems to work ok.

 ---------------------
modhistory
23jun05: stole from cormapinp interrim cor and updated for galfa.
10jul05: added /smo keyword
14jul05: fixed jdenc computation. was failing 8pm to 12 midnite.

(See /pkg/rsi/local/libao/phil/galfa/cormapinp.pro)


GALCLOSE - CLOSE A GAL FILE FOR I/O

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galclose - close a gal file for i/o

SYNTAX: galclose,desc 

ARGS:
   desc: {galdescr} - descriptor to close (returned by galopen)
KEYWORDS:
    all:              if set then close all open descriptors.

DESCRIPTION:
   Files opened with galopen() need to be closed with galclose() so that
the resources are freed up.

EXAMPLE:
   filename='/share/wapp11/wapp1.20040121.a1849.0004.fits'
   istat=galopen(filename,desc)
   .. process the data in the file
   galclose,desc   .. this closes the file when done with the processing.

(See /pkg/rsi/local/libao/phil/galfa/galclose.pro)


GALFNAMEPARS - PARSE A FITS FILENAME.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galfnamepars - parse a fits filename.

SYNTAX: istat=galfnamepars(filename,nmpars)

ARGS:
filename: string    fits filename

 RETURNS: 
   istat: int       1 - fits filename format is ok.
                    0 - filename is not a standard was fits filename
  nmpars: {}        return structure with filename parsed into 
                    variables. 

DESCRIPTION:
   Parse a spectral line was file into its component parts. The 
returned structure contains:
   
help,nmpars,/st
   DIR    STRING    '/share/galfa/',;dir with trailing '/'
                                       ;(or blank if no dir in filename)
   WAPP   STRING    'galfa'
   DATE   STRING    '20050709' 
   PROJID STRING    'a2004'
   SEQNUM   LONG    6
   FITS   STRING    'fits'

(See /pkg/rsi/local/libao/phil/galfa/galfnamepars.pro)


GALFTOCHDR - CONVERT FITS HDR TO COR HEADER

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galftochdr - convert fits hdr to cor header

SYNTAX: istat=galftochdr(desc,h,hf=hf,nrows=nrows,irec=irec)

ARGS: 
   desc:{galdesc} gal descriptor returned from galopen()

RETURNS:
   istat: int  1 ok, 0 eof, -1 error.
    h: {corhdr}  correlator header
    hf:{galhdr}  gal hdr extension..
 nrows:   long   number of rows to advance desc.curpos if you
                 want to update the position.
pol[2,nbrds]:  long   codes the pol type polA=1, polB=2 for each 
                 spectra on each board.
iscan :   long   index into desc.scanI[] for this scans data.

DESCRIPTION:
   Read in a fits header for the current group and convert it
to a correlator header. If the file is not positioned at
the start of a group, then move forward to the start of the
next group.

NOTE: this routine does not update the position in the file.
You are left pointing at the input position.
 This is a lowlevel routine that is not normally called via
corget().

 current data being loaded into b1.h from fits header:
 tointerimHdr      from fitsHdr
 --------------------
 STD
h.std.time          fits.crval5 convert to ast secs
h.std.date          yyyyddd
h.std.azttd         fits.ENC_AZIMUTH
h.std.grttd         fits.ENC_ELEVATIO
h.std.chttd         fits.ENC_ALTEL
h.std.posTmMs       fits.ENC_TIME
h.std.grpTotRecs    desc.scanI.nbrds 
h.std.grpNum        
 --------------------
 COR
h.cor.numbrdsused   desc.scanI.nbrds
h.cor.numSbcOut     desc.scanI.nsbc
h.cor.lagsbcout     desc.scanI.nlags
h.cor.boardId       desc.scanI.brdNum
 --------------------
 PROC
h.proc.srcname      fits.OBJECT
h.proc.procname     fits.OBSMODE with name translation new to old
 --------------------
 -
history
 25jun04 - if frontend = alfa, force rfnum to be 17
 13jul04 - check for eof by row.
 18jul04 - added if2.. mixer
 09aug04 - added rajcumrd decjcumrd
 12aug04 - for spider scans with alfa include the pixel number in iar[5]
           taken from the pattern name .
 14aug04 - for spider scans load iar[0] with a beamwidth.Use stripLen/6.
 20aug04 - added iscan keyword to return to user
 22oct04 - updated to new header version. wide band has 512 channels
           instead of just 256 V1 has the old 256 channel def.
 28oct04 - version 3 header
 18jul05 - added object, obs_name

(See /pkg/rsi/local/libao/phil/galfa/galftochdr.pro)


GALGERRDCD - DECODE THE GALFA G_ERR BITMAP CONVERT FITS HDR TO COR HEADER

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galgerrdcd - decode the galfa g_err bitmap convert fits hdr to cor header

SYNTAX: gdcd=galgerrdcd(g_err)

ARGS: 
   g_err[] :int  array of g_err values from header

RETURNS:
   gdcd[]: {g_errstr} array of structures with decoded values.

DESCRIPTION:
   The g_err status word holds overflow information for the galfa 
spectromenter. Pol A and B of the same beam always have the same
bits set. There are six flags in the status word. Each flag is decoded
 into a separate integer value. The structure field names, bits in the
 mask and description are:

S    wbUpShSat  B0-1   wide band upshift saturation
F    wbFftOvr   B2-3   wide band fft overflow
S   nbUpShSat  B4-5   narrow band upshift saturation
F    nbFftOvr   B6-7   narrow band fft overflow
L   nbLpSat    B8-99  narrow band low pass filter saturation
M   nbMixSat   B10-11 narrow band mixer saturation
    adcSat     B12-13 adc input saturation

 For each field it can take on the value 0 thru 3. These values are:

 0 - 0  to 15  errors in previous 1 sec
 1 - 16 to 255 errors in previous 1 sec
 2 - 256 to 4095  errors in previous 1 sec
 3 - > 4096  errors in previous 1 sec
 note that pola,b will always have the same errors for a given beam.

(See /pkg/rsi/local/libao/phil/galfa/galgerrdcd.pro)


GALGET - READ A GROUP OF GALFA DATA RECORDS.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galget - read a group  of galfa data records.

SYNTAX: istat=galget(desc,b,rec=rec,han=han)

ARGS: 
   desc:{galdesc} gal descriptor returned from galopen()

RETURNS:
   istat: int  1 ok, 0 eof, -1 error.
       b: {galget}  data structure holdin data.

DESCRIPTION:
   This is the lowlevel routine that reads the data from the fits file.
This routine in normally not called by users. The user interface to the
data in the file is via corget(). corget() will call this routine 
automatically when it is passed a galDescriptor rather than a
logical unit number(lun).

18jan04 - added h.dop. set it so that it is doppler update 
          each sbc even if it is not being done. We will load the
          correct frequency, velocity into the header so that this
          will be true.
19jan04 - force returned data to always be in increasing freq order.
          for now key off of flipped keyword (until cdelta1 is fixed).
02feb04 - switch to use galftochdr() to get/convert the header.
14jul04 - if pol data then acf's, do not flip data
20aug04 - added iscan call to galftochdr.
          use indar to return the data arrays independant of the order
          they are stored on disc.

(See /pkg/rsi/local/libao/phil/galfa/galget.pro)


GALIMGDISP - DISPLAY A SET OF CORRELATOR RECORDS AS AN IMAGE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galimgdisp - display a set of correlator records as an image
SYNTAX: img=galimgdisp(b,clip=clip,brdlist=brdlist,pol=pol,col=col,$
                   median=median,bpc=bpc,ravg=ravg,nobpc=nobpc,$
                   win=win,wxlen=wxlen,wylen=wylen,wxpos=wxpos,wypos=wypos,$
                   samewin=samewin,zx=zx,zy=zy,$
                   mytitle=mytitle,$
                   hlind=hlind,hlval=hlval,hldash=hldash,hlvlines=hlvlines,$
                   useind=useind,ln=ln,chn=chn)
ARGS:
   b[nrecs]: {corget} correlator data to make image of 
RETURNS:
   img[nchns,nrecs]: float image of last brd displayed (before clipping).

KEYWORDS:
                  
         wb:        if set then take the data from the wide band.
     clip[]: float  value to clip the normalized data to. Default is
                    .1 of Tsys (3 sigma for 1 sec integratio for nb).
                    If clip has 1 value then 
                    normalize to (img > (-clip)) < clip. If two value are
                    provided, then they will the [min,max].
    brdlist: long   A single number whose decimal digits specify the boards
                    to display. eg brds 1,2,3,4 would be: brdlist=1234
                    The boards are numbered 1 thru 8.
        pol: int 1,2, (3,4 if stokes)  polarization to plot. default is 1:polA
        win: int window number to plot in. default is 1.
      wxlen: int xlen of window. default 700
      wylen: int ylen of window. default 870
      wxpos: int xpos of lower left edge of window.default 445
      wypos: int ypos of lower left edge of window.default:35
    samewin:     if set then use the current dimension for the image win.
                 If you are calling galimgdisp in a loop then setting this
                 (after the first call) lets the user dynamically adjust the
                 window size,position.
         zx: int ..-3,-2,2,3,4 zoom factor x dimension. Negative numbers 
                   shrink the image positive numbers expand. Negative number 
                   must divide evenly into the number of channels.
         zy: int ..-3,-2,2,3,4 zoom factor y dimension (same format as zx)
     col[2]: int .. x columns to use to flatten the image in the time
                    direction. count 0..numberoflags-1. If multiple boards 
                    plotted then the same cols are used for all boards. The
                    default is no flattening in the time direction.
        chn:        if set then plot vs channel number rather than freq
        bpc:{corget} if supplied then this data will be used to do the
                    bandpass correction. The default is to average over
                    all of the nrecs.
      nobpc:        if set then no bandpass correction is done.
     median:        if set and bpc not provided, then bandpass correct using
                    the median of the nrecs rather than the average.
       ravg: long   bandpass correct with a running average of ravg spectra
     scan  : long   if provided,then routine will input scans data into
                    b[] before making image. In this case you must also
                    supply the lun keyword to tell the routine where to
                    read from.
       lun : int    if scan keyword provided, then you must also supply
                    this keyword. It should contain the lun for the 
                    corfile that you have previously opened.
       sl[]:{scanlist} This array can be used for direct access when the
                     scan keyword is used. The sl[] (scanlist) array is
                     returned from the sl=getsl(lun) routine. The routine
                     scans the entire file recording where the scans start.
       han:          if set and scan keyword set, then hanning smooth the
                     data on input.
   maxrecs: int      if lun used then the max records of a scan to input.
                     default:300
   mytitle:string    user supplied tittle instead of scan,srcname,az,za
                     az,za at top of the plot.
   hlind[]: ind      index into img array (2nd dimension) to draw
                     horizontal lines.
   hlval  : float    value to use for horizontal lines (in img units)
                     default is clip value.
   hldash : int      The dash lengths to used for the horizontal lines.
                     2*ldash must divide into x dimension.default is 4
   hlvlines:int      Number of engths to used for the horizontal lines.
                     default=1
   useind[2]:int     if provided then use these indices from data array
                     0 .. lengthsbc -1
                     default=1
   ln       :int     linenumber for title..0..33 def:3
   extra_=e          this allows you to input keywords that will be
                     passed to the plotting routine. eg title=title..
  
DESCRIPTION:
   galimgdisp will display a set of correlator records (usually a scans
worth) as an image. By default it will make a separate image for each
subcorrelator (board). The brdlist  keyword lets you choose just 1 brd to
 image. The data for the image is taken from polA  by default. 
Use the pol keyword to make the image from the other polarization. 
If you use the /wb keyword then the wide band data will be used.

   By default, the image is bandpass normalized by the average of all the
records (sbc/avg(sbc) - 1). If the median keyword is used then
 avg(sbc) is replaced by median(sbc). The bpc keyword allows you to input
a separate correlator record to use as the normalization.
   The col keyword lets you also flatten the image in the time (record)
dimension by specifying the first/last columns to average and then divide 
into all of the other columns (the columns are counted from 0). By default
this is not done.

   After bandpass correction and flattening in the record dimension, the
image is clipped (by default) to +/- .1 (tsys) and then scaled
from 0 to 256 for the image display. The clip  keyword lets you change the
clipping value.

   The zx,zy keywords let you scale the image in the x and y dimensions by
integral amounts. Negative numbers will shrink it by that amount (Note:
the negative numbers must divide evenly into the number of channels in
each brd). -1,0,1 do no scaling. This scaling is only applied for the single
brd displays. The multiple brd displays are always scaled to fit 
inside the window (700 by 870 pixels).

   After displaying the image, use xloadct to manipulate the color table.

   The routine returns the last image displayed (before clipping).

EXAMPLES:
   input a scans worth of data.
   print,corgetm(desc,600,b,/han)    .. input scan with hanning smoothing
1. display the image of all 7 brds.
   img=galimgdisp(b)
   img=galimgdisp(b,/wb) display the wide band data.
2. display only brd 2, scale y by 2, and x by -2
   img=galimgdisp(b,brdlist=1,zx=-2,zy=2)
3. display all 7, clip to .015 Tsys , display polB and median filter the
   bandpass correction:
   img=galimgdisp(b,pol=2,/median)
4. display all brds 1,2,3,4 , clip to .015 Tsys , 
   display polB and median filter the bandpass correction:

   img=galimgdisp(b,brdlist=1234,pol=2,/median)

This routine calls imgflat, and imgdisp for the image scaling and display.

NOTE:
   When displaying only 1 brd and using zx fopr shrinking the image,
 zx must divide into the number of channels. For the narrow only zx=-7
 works since 7679/7=1097 and 1097 is prime.

SEE ALSO:
   imgdisp,imgflat

(See /pkg/rsi/local/libao/phil/galfa/galimgdisp.pro)


GALMIX - COMPUTE GALFA LO MIXING FREQS

[Previous Routine] [Next Routine] [List of Routines]
NAME: 
galmix - compute galfa lo mixing freqs
SYNTAX: mixI=galmix(skyCfr,narBandCfr,rfiSky,use275=use275,lo1Low=lo1Low,$
                    print=print)
ARGS:
   skyCfr    : float  sky center frequency as set by first lo.
   narBandCfr: float  center freq we want for narrow band spectra
   rfiSky[n] : float  compute the IF locations for these sky frequencies
   
KEYWORDS:
   use275:     if set then use 275 Mhz for IF1 (the default is 250 Mhz).
   lo1Low:     if set then use a low side LO1. The default is a high side LO.
   print:      if set then print out the values (cals galmixpr())
RETURNS:
   mixI[n]: {} structure holding the computed information (see below).

DESCRIPTION: 
   The user specifies the rf sky center frequency (as set by the first
LO) and the center of the narrow band spectra. The routine will then 
compute the first and and 2nd lo's to use. You can select an IF1 of 
250 (default) or use 275Mhz (by setting /use275.). If lo1Low is set then
the first LO will be a low side LO (the default is high side).

   The array rfiSky contains a set of sky frequencies. The routine
will compute where in the if1, if2 bands these frequencies will fall.

   If the /print keyword is set then the data will be printed to stdout.
You can pass mixI to galmixpr to print out the info at a later time.

	The structure mixI[n] contains:

IDL> help,mixI,/st
   SKYF            FLOAT           1385.00  sky center freq (set by 1stLO)
   NBF             FLOAT           1420.41  narrow band cfr
   WBF             FLOAT           1439.16  wide band cfr
   IF1             FLOAT           250.000  if1 used (250 or 275)
   LO1             FLOAT           1635.00  first LO.
   LO1SB           INT             -1       -1--> 1stlo high side,1-->loside
   LO2             FLOAT           195.844  2nd lo frequency
   RFI_SKY         FLOAT           1330.00  rfi sky freq
   RFI_IF1         FLOAT           305.000  location in IF1 of rfi
   RFI_IF2         FLOAT           109.156  location in IF2 of rfi

EXAMPLE:
 1. Center the RF at 1385 and the narrow band at 1420.4058. Use the
    250Mhz IF for if1. Also look to see where the two faa radars (1330,1350)
    fall in the IF band. This setup could be used for a piggy back
    observering with the extra galactic crowd.

 skyCfr=1385.
 nbCfr =1420.4058
 rfiSky=[1330.,1350.]      ; look at where the 2 faa radars fall
 mixI=galmix(skyCfr,nbCfr,rfiSky,/print)

 the output is then :

sky     nbCen   wbCen   if1 rfiSky  RfiIf1  rfiIf2   lo1         lo2
1385.00 1420.41 1439.16 250 1330.00  305.00  109.16 1635.000000  195.844238
1385.00 1420.41 1439.16 250 1350.00  285.00   89.16 1635.000000  195.844238

 2. use the 275 Mhz IF1. Center the RF and the narrow band center at
    1420.4058. This is a typical galactic setup with no piggy backing.

 skyCfr=1385.
 nbCfr =1420.4058
 rfiSky=[1330.,1350.]      ; look at where the 2 faa radars fall
 mixI=galmix(skyCfr,nbCfr,rfiSky,/print)



SEE ALSO: galmixpr 

(See /pkg/rsi/local/libao/phil/galfa/galmix.pro)


GALMIXPR - FORMATTED PRINT OF GALMIX() DATA.

[Previous Routine] [Next Routine] [List of Routines]
NAME: 
galmixpr - formatted print of galmix() data.
SYNTAX: galmixpr,mixI,notitle=notitle
ARGS:
   mixI[n] : {}float  info returned by galmix()
KEYWORDS:
   notitle: if set then don't print the title. This is handy if you 
            are calling galmixpr multiple times and you only want
            one heading.
DESCRIPTION: 
   Print the info returned by galmix() to std out.

EXAMPLE:
 1. Center the RF at 1385 and the narrow band at 1420.4058. Use the
    250Mhz IF for if1. Also look to see where the two faa radars (1330,1350)
    fall in the IF band. This setup could be used for a piggy back
    observering with the extra galactic crowd.

 skyCfr=1385.
 nbCfr =1420.4058
 rfiSky=[1330.,1350.]      ; look at where the 2 faa radars fall
 mixI=galmix(skyCfr,nbCfr,rfiSky)

 galmixpr,mixI
 the output is then :

sky     nbCen   wbCen   if1 rfiSky  RfiIf1  rfiIf2   lo1         lo2
1385.00 1420.41 1439.16 250 1330.00  305.00  109.16 1635.000000  195.844238
1385.00 1420.41 1439.16 250 1350.00  285.00   89.16 1635.000000  195.844238

SEE ALSO: galmix

(See /pkg/rsi/local/libao/phil/galfa/galmixpr.pro)


GALOPEN - OPEN A GALFA FITS FILES FOR I/O

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galopen - open a galfa fits files for i/o

SYNTAX: istat=galopen(filename,desc,tmI=tmiI,scanI=scanI)

ARGS:
   filename: string  filename to open

KEYWORDS:

RETURNS:
  istat: int          0 couldn't open file
                      1 file opened successfully
   desc: {galdescr} - descriptor holding info for file i/o.

  scanI: {}           structure holding info about each record in
                      file. You can use this to sort out where
                      different patterns started (without having
                      to read the entire file).
 tmI[6]: {}           structure holding timing info:
                      tmI[i].nm  label of where the time was measured  
                      tmI[i].tm  time value (from call to systime(1)).
                      The units are seconds (with fraction). To get the
                      relative time, you should subtract tmI[0].tm from
                      all of the .tm values or (tmI.tm - shift(tmI.tm,1)
DESCRIPTION:
   Open a gal (galfa) spectral line fits file. Load
the descriptor with the info for the entire file. This
descriptor will be passed to the galxxx corxxx routines to do the 
file i/o. This descriptor replaces the standard lun that is 
used for the interim correlator data.
   The descriptor contains:
 
   help,desc,/st

   LUN       LONG     0        .. idl lun 
   FILENAME  STRING '/share/wapp11/a9999_wapp1_0027.fits' ..filename 
   TOTRECS   LONG     1        .. total recs (integ)  in file 
   TOTROWS   LONG  7216        .. total number of rows in bintable
   CURPOS    LONG     1        .. position for next read 0 based (row-1)
   tmStartFile LONG   0        .. secs since 1970 start of file
   rowStartRec lonarr(nrecs) 
   rowsinrec lonarr(nrecs)
  -------------------------------

 If the scanI keyword is returned, then the scanI[nrecs] structure array 
returned contains:
 
IDL> help,scanI
SCANI      0     STRUCT    = ->  Array[600]

IDL> help,scanI,/st
 SEQNUM    LONG    1203        ; seq number from fits file
 OBSMODE   STRING  'BASKET'    ; pattern used
 OBS_NAME  STRING  'BASKET'    ; step in pattern 
 OBJECT    STRING  'lwb_14_00' ; source name
 SEC       DOUBLE   1.1209410e+09 ;sec from 1970 start of rec. rounded to
                                 closest sec: round(g_time[0]+g_time[1]*1d-6)
 AZ        FLOAT    359.382    ; az position (deg)
 ZA        FLOAT    14.7502    ; za position (deg)
 RESTFREQ  DOUBLE   1420.2858  ; crval1:rest freq Mhz (narrow band)
 NUM       LONG     0          ; unused.. user can load 
 
 The az,za are taken from the file. They are not interpolated to the
center of the data sample.


EXAMPLE:
 1. open a file

   filenm='/share/wapp11/wapp1.20040118.a1849.0010.fits'
   istat=galopen(filenm,desc)

   gallist,desc            ; list scan summary
   istat=corget(desc,b)    ; read a record
   corplot,b               ; plot it
   istat=corinpscan(desc,b,scan=401864155,maxrecs=600) ; input a scan
   galclose,desc           ; when done.

 2. open file, return timing info and scanI
   istat=galopen(filenm,desc,scanI=scanI,tmI=tmI)
   print,tmI.tm - tmI[0].tm
;  look for pattern name of CAL
   ind=where(scanI.obsmode eq 'CAL',count)
   if count gt 0 then ...
      process cal records
   endif
   	

(See /pkg/rsi/local/libao/phil/galfa/galopen.pro)


GALPROJFILES - FIND THE FILES BELONGING TO A PROJECT ID

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galprojfiles - find the files belonging to a project id

 SYNTAX: istat=galprojfiles(proj,fileInfo,yymmdd1=yymmdd1,yymmdd2=yymmdd2,$
                            minsize=minsize,dir=dir)

 ARGS:
      proj:  string  proj name to search for
KEYWORDS:
 yymmdd1: long limit files to those starting on this date (yymmdd1 included)
 yymmdd2: long limit files to those starting on or before this date
               (yymmdd2 included)
 minsize: long minimum size in bytes for file to return. default is
               100000 bytes. file less than this usually have no 
               data (just a header). 
dir    : string directory to search thru. def: /share/galfa
 RETURNS: 
     istat:  number of files found 
fileinfo[istat]:   array of file info structures containing the name 
                   and size of the file

DESCRIPTION:
   Search through the galfa fits directories looking for files that
belong to a particular project. Return an array of stuctures containing
the filename and file size.

(See /pkg/rsi/local/libao/phil/galfa/galprojfiles.pro)


GALPWR - RETURN POWER INFORMATION FOR A NUMBER OF RECS

[Previous Routine] [Next Routine] [List of Routines]
NAME:
galpwr - return power information for a number of recs
SYNTAX: nrecs=galpwr(desc,reqrecs,pwra,lasthdr,b=b,useb=useb,wb=wb)
ARGS:
   desc     - descriptor opened via wasopen.
   reqrecs  - requested records to return

KEYWORDS:   
   wb       - if set then return power from wideband data
   useb     - if set then the user passes the data in via b= keyword.
              desc is ignored and no data is read from disc
   b[nrecs] - This can be an input and an output keyword. If /useb is
              set, then the user is passing in the spectral data in the
              b=b keyword (which means you need to have previously read
              it). If /useb is not set, but b=b is provided, then the
              spectral data read in will be returned in b.

RETURNS:
   pwra     - returns an array pwra[nrecs]  of {corpwr} struct
   nrecs    - number of recs found, 0 if at eof, -1 if hdr alignment/io error
   b[nrecs] - if keyword b= is supplied, then the input spectral data will
              be returned in this keyword.

DESCRIPTION:

   Return the total power information for the requested number of
records of a galfa file. The data is returned in the array pwra. 
Each element of thearray contains:

pwra[i].scan - scan number.. this is 0 for galfa:
pwra[i].rec  - record number in the file (count from 1)
pwra[i].time - seconds from midnight for this record
pwra[i].nbrds- number of boards in use
pwra[i].az   - az (deg) end of this record.
pwra[i].za   - za (deg) end of this record.
pwra[i].azErr- az (asecs great circle) . not available galfa
pwra[i].zaErr- za (asecs great circle) . not available galfa
pwra[i].pwr[2,8] - total power info. first index in pol1,pol2
                   2nd index are 8 pixelss (only the 1st 7 are used with
                   galfa.

There will only be valid data in the first pwra[i].nbrds entries of
pwra.

EXAMPLES:
;
; 1. get the pwr from the entire file
   rew,desc 
   nrecs=galpwr(desc,600,p)

; 2. same thing but also return the spectral records for later use 

   rew,desc 
   nrecs=galpwr(desc,600,p,b=b)

; 3. use the spectra data in b we read from 2. to now get the
;    wide band data. This is quicker since we don't have to re read
;     all the spectral data.
   nrecs=galpwr(desc,600,pwb,b=b,/useb)

; 4. read in the spectral data with corgetm and the compute the power.
    istat=corgetm(desc,600,b)
    nrecs=galpwr(desc,600,p,/useb,b=b)

(See /pkg/rsi/local/libao/phil/galfa/galpwr.pro)


GALRIPPLE - LOOK AT RIPPLE IN GALFA BANDPASS

[Previous Routine] [List of Routines]
NAME:
galripple - look at ripple in galfa bandpass
SYNTAX: galripple,b,hard=hard,bfit=bfit,win=win,mytitle=mytitle,$
				   spcar=spcar,deg=deg,fsin=fsin,nospc=nospc,tosmo=tosmo
ARGS:
	b: {corget}	bandpass to use. Normally you would input a file, average
				it, and then pass the averaged spectra in.
KEYWORDS:
   hard:  	if set then user wants hardcopy. This will not plot the
		    baseline fits.
   bfit:{corget} This is the fit from corblauto(). If it is passed in as 
				  a corget structure then it will be used rather than calling
			      corblauto(). This speed things up if you call the routine
				  multiple times with the same bandpass. 
	win : string  Window function to use when computing the transform of the
				  spectrum. Values are:
					  'cos4'  cos^4 window
				      'han'   hanning smoothing.
				  The default is no windowing.
  mytitle: string If supplied then it will be plotted at the top of the
				  page.
	deg   : int	  The deg for the polynomial portion of the fit done by
				  corblauto().
	fsin  : int	  The order of the harmonic fit done by corblauto()
  nospc  :       If set, then don't plot the smoothed bandpass corrected
				  spectra.
RETURNS:
	bfit: {corget} If supplied and the input is not a {corget} then the
				   corblauto() fit is returned here.
spcar[nchn,2,nbeams]: float	this is the transform of the bandpass. 

DESCRIPTION:
	galripple was used to look at the 174 Khz rippled caused by reflections
in the fiber optics cable. It  takes an galfa bandpass as input. 
It will then :

1. fit the bandpass with corblauto(). The default is a linear polynomial
	and a 7th order harmonic. This gets rid of ripples with a spacing up 
   to 1 Mhz. You can change the order using deg= and fsin=
2. Divide the bandpass by the fit in 1.
3. Smooth the spectra from 2 by tosmo. The default is 19 channels. 
4. if the keyword /nospc is not set then plot the bandpasses from 3. Pol
   A and polB are on separate pages.
5. compute the transform of the spectra in 4:
	spc=abs(fft(spc3))*2.
   The 174 Khz rippled should show up in channel 39 or 40.
   Then plot this spc for each pixel. Black in polA, red is polB

EXAMPLES:
	istat=corgetm(desc,600,b)
   bavg=coravg(b)
	galripple,bavg

(See /pkg/rsi/local/libao/phil/galfa/galripple.pro)