patriot 12meter idl routines

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


List of Routines


Routine Descriptions

P12MDCDPRSTWD - DECODE THE PROGRAM STATUS WORD

[Next Routine] [List of Routines]
NAME:
p12mdcdprstwd - decode the program status word
SYNTAX:prStateD= p12mdcdprstwd(prStateU)
ARGS: 
 prStateU[n]:long undecoded program state word 
RETURNS:
prStateD[n]: {p12mprstwd}  decoded bit field
DESCRIPTION:
	The p12mProg statwd is a bit field. This routine
decodes each 32 bitfield into a struct holding the various
fields

(See /pkg/rsi/local/libao/phil/p12m/p12mdcdprstwd.pro)


P12MDCDSTAT - DECODE THE DEVICE STATUS

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mdcdstat - decode the device status
SYNTAX:stDcd= p12mdcdstat(stU)
ARGS: 
 stU[n]   : {p12mdevStWdsU} undecoded device status words
RETURNS:
st[n]     : {p12mdevstWds} structs after decoding
                      decoded
DESCRIPTION:
 	decode the 4 device status biffields. Passed in as
array of stucts holding the 4 32bit numbers
   Returns an array of decode structs

(See /pkg/rsi/local/libao/phil/p12m/p12mdcdstat.pro)


P12MFITMOD - FIT MODEL TO AZ,EL POSITIONS AND POINTING ERRORS

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mfitmod - fit model to az,el positions and pointing errors
SYNTAX: p12mfitmod,az,el,azErr,elErr,modFitI,resAz,resEl
ARGS:
       azReq[npts]: flt/dbl  requested azimuth positions degrees

       elReq[npts]: flt/dbl  requested el  angle positions degrees
    azErr[npts] : flt/dbl    azimuth errors (great circle) deg.(azPk - azUsed)gc
    elErr[npts] : flt/dbl el      angle errors deg.            (elPk - elUsed)
                              the refraction correction has not been removed
                           
RETURNS:
      modFitI : {modelFitInfo} return model fit results here
                               The model coef will output Asec values
   resAz[npts]: hold the azimuth residuals from the fits (asecs). (GC) 
                           azErr - modelCoraz
   resEl[npts]: hold the el residuals from the fits (asecs).  
                computed as: (elErr - Refraction) - modelCorel

Notes: - Lc=Little circle
 		- Gc= great circle
       - When making a new model, we normally fit to to raw azerr,elerr..
         so the old model and the refraction correcdtion has been added to the 2dfit errors.
       
DESCRIPTION:
   fit the 12meter model to the offsets measured by the 2d cross fits on sources.
Input: azReq,elReq            :requested position encoder values for 2d fits
       azerr                  :measured az error (great circle),
       elerr                  :measured el error. from 

the 2d cross fits compute the error (gc) as:
       FitPosPk= azReq + azErrGc .. where error is gc
  so you add the error to the requestedposition to get the correct (peak) position
Output:
       model,
       model residuals:  great circle
 -----------------------------------------------------------
   What is being measured and what is being computed.
 -----------------------------------------------------------
The input values from the 2d fits:
 let AzPk, elPk be the az,el that will cause you to point at the source

 azPk = azReq+azErrGc .. where azErr is great circle(div by cos(el)
 elPk = elReq +elErr 
 -----------------------------------------------------------
 what the model computes
  to point at the source you need to move to azPk,elPk
 Let elRefr be the elevation after the refraction correction has been made:
  elRefr = elReq + dElRefr 
 
 azPk= azReq   + azMod/cos(elPr)   .. to go great cird to little circ
 elPk= elPr              + elMod  .. since model fits el after refraction correction.
     = (ElReq + dElRefr) + elMod
     so add mod az, mod el + refrCor to azreq,elReq
 -----------------------------------------------------------
 mapping azErr, elErr to model values to fit
         model                      2d fits
 azPk=(azReq + azMod/cos(elPr)  = (azReq + azErrGc)
 -->            azmod           =  azErrGc
 elPk=(elReq + dElRefr) + elMod = (elReq + elErr)
 --            dElRefr  + elMod =  elErr
 -->           elMod            =  elErr - dElRefr .. so remove refraction correction.
 -----------------------------------------------------------
 model: (marks params P1..P9, indices I0..I8,  P6/I5 not used
The model is:
azM= P1        + P2*cos(elP) + P3*sin(elP) + P4*sin(elP)*cos(az) + P5*sin(elP)*sin(az)
elM=-P4*sin(az)+ P5*cos(az)  + P7          + P8*cos(elP)         + P9*cot(elP)

ind pNum  azCoef    
0   p1    offset  
1   p2    cosEl     
2   p3    sinEl
3   p4    sinEl*cosAz
4   p5    sinEl*sinA   

ind pNum  elCoef    
0   p4    sinAz 
1   p5    cosAz     
2   p7    offset
3   p8    cosEl
4   p9    cotEl
 ------------------------------------------------
The residuals are defined as:
  res=  errStart - errFit 
    so a positive residual --> the fits is too low.
    If you try to compute the correct position from the residual, You need to add
    the el residual to the elcorrected for refraction.
 ------------------------------------------------
We try fitting everything at once rather than azerr,elerr separately
 This ends up being a non linear fit. what we do
 1. do linear fit to azerrs
 2. to linear fit to el errs
 3. avge p4,p5 (the common params)
 4. use the above params as the starting value vor curvefit

   Model params are 0..8
     0..4 az  , 3,4,6,7,8 el
 to fit:
 0  = (azErr - modfit)  + (elErr 0 modfit)
    modFitI.
NOTES:
  25feb22 - switched to be p12mfitmod. now the version to use
            older version that fit az,el separately in p12mfitmod.pro.old

(See /pkg/rsi/local/libao/phil/p12m/p12mfitmod.pro)


P12MFITMODA - FIT MODEL TO AZ,EL POSITIONS AND POINTING ERRORS

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mfitmoda - fit model to az,el positions and pointing errors
SYNTAX: p12mfitmodN,az,el,azErr,elErr,modFitI,resAz,resEl
ARGS:
       azReq[npts]: flt/dbl  requested azimuth positions degrees

       elReq[npts]: flt/dbl  requested el  angle positions degrees
    azErr[npts] : flt/dbl    azimuth errors (great circle) deg.(azPk - azUsed)gc
    elErr[npts] : flt/dbl el      angle errors deg.            (elPk - elUsed)
                              the refraction correction has not been removed
                           
RETURNS:
      modFitI : {modelFitInfo} return model fit results here
                               The model coef will output Asec values
   resAz[npts]: hold the azimuth residuals from the fits (asecs). (GC) 
                           azErr - modelCoraz
   resEl[npts]: hold the el residuals from the fits (asecs).  
                computed as: (elErr - Refraction) - modelCorel

Notes: - Lc=Little circle
 		- Gc= great circle
       - When making a new model, we normally fit to to raw azerr,elerr..
         so the old model and the refraction correcdtion has been added to the 2dfit errors.
       
DESCRIPTION:
   fit the 12meter model to the offsets measured by the 2d cross fits on sources.
Input: azReq,elReq            :requested position encoder values for 2d fits
       azerr                  :measured az error (great circle),
       elerr                  :measured el error. from 

the 2d cross fits compute the error (gc) as:
       FitPosPk= azReq + azErrGc .. where error is gc
  so you add the error to the requestedposition to get the correct (peak) position
Output:
       model,
       model residuals:  great circle
 -----------------------------------------------------------
   What is being measured and what is being computed.
 -----------------------------------------------------------
The input values from the 2d fits:
 let AzPk, elPk be the az,el that will cause you to point at the source

 azPk = azReq+azErrGc .. where azErr is great circle(div by cos(el)
 elPk = elReq +elErr 
 -----------------------------------------------------------
 what the model computes
  to point at the source you need to move to azPk,elPk
 Let elRefr be the elevation after the refraction correction has been made:
  elRefr = elReq + dElRefr 
 
 azPk= azReq   + azMod/cos(elPr)   .. to go great cird to little circ
 elPk= elPr              + elMod  .. since model fits el after refraction correction.
     = (ElReq + dElRefr) + elMod
     so add mod az, mod el + refrCor to azreq,elReq
 -----------------------------------------------------------
 mapping azErr, elErr to model values to fit
         model                      2d fits
 azPk=(azReq + azMod/cos(elPr)  = (azReq + azErrGc)
 -->            azmod           =  azErrGc
 elPk=(elReq + dElRefr) + elMod = (elReq + elErr)
 --            dElRefr  + elMod =  elErr
 -->           elMod            =  elErr - dElRefr .. so remove refraction correction.
 -----------------------------------------------------------
 model: (marks params P1..P9, indices I0..I8,  P6/I5 not used
The model is:
azM= P1        + P2*cos(elP) + P3*sin(elP) + P4*sin(elP)*cos(az) + P5*sin(elP)*sin(az)
elM=-P4*sin(az)+ P5*cos(az)  + P7          + P8*cos(elP)         + P9*cot(elP)

ind pNum  azCoef    
0   p1    offset  
1   p2    cosEl     
2   p3    sinEl
3   p4    sinEl*cosAz
4   p5    sinEl*sinA   

ind pNum  elCoef    
0   p4    sinAz 
1   p5    cosAz     
2   p7    offset
3   p8    cosEl
4   p9    cotEl
 ------------------------------------------------
The residuals are defined as:
  res=  errStart - errFit 
    so a positive residual --> the fits is too low.
    If you try to compute the correct position from the residual, You need to add
    the el residual to the elcorrected for refraction.
 ------------------------------------------------
We try fitting everything at once rather than azerr,elerr separately
 This ends up being a non linear fit. what we do
 1. do linear fit to azerrs
 2. to linear fit to el errs
 3. avge p4,p5 (the common params)
 4. use the above params as the starting value vor curvefit

   Model params are 0..8
     0..4 az  , 3,4,6,7,8 el
 to fit:
 0  = (azErr - modfit)  + (elErr 0 modfit)
    modFitI.

(See /pkg/rsi/local/libao/phil/p12m/p12mfitmoda.pro)


P12MFITTSYS - FIT TO TSYS VS ELEVATION DATA

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mfittsys - fit to tsys vs elevation data
SYNTAX: istat=p12mfittsys(tsys,el,fitI,weights=weights,yfit=yfit,$
                          tol=tol,itmax=itmax,Tatm=Tatm
ARGS:
 tsys[n]: dbl/fltarr   tsys data to fit
 el[n]  : dbl/fltarr   elevation values for each tsys value
KEYWORDS:
weights[n]:  dblarr weights for each Tsys value passed to curvefit() routine.
                     def:1. 
tol       :  double  tolerance for fit convertion. def: .001
itmax     : integer  maximum interation value for fit. def:40
Tatm      : double   fixed Tatm value to use in fit. Def:270 K
RETURNS;
istat     : int      1 -ok
                    -1  fit error.
fitI      : {}      structure holding fitinfo .. see below
yfit[n]   : fltarr  fit evaluated at input points.
DESCRIPTION:
	Fit tsys data to elevation. The input Tsys should aleady be in deg K.
The routine fits:
 Tsys=A[0] + Tatm*(1. - exp(-A[1]*secza)) + Tcmb*exp(-A[1]*secza)
 coef to fit:
 A[0]:     Tsys constant value
 A[1]:     opacity

Constants used by the fit:
  Tatm: atm temp to use. default is 270K
  Tcmb: 2.725   cmb temp
 
 secza=1/cos(za) = 1/sin(el)
 
 the returned fitI struct contains:
 help,fiti,/st
** Structure <190aed8>, 8 tags, length=72, data length=66, refs=1:
 NPNTS     LONG   1375        ; number of points used to fit
 TCMB      FLOAT  2.72500     ; cmb temp used:
 TATM      DOUBLE 270.00000a  ; tatm value used
 COEF      DOUBLE Array[2]    ; coef from fit [Tconsta,tau] 
 SIGCOEF   DOUBLE Array[2]    ; sigmas for coef
 SIGFIT    DOUBLE 0.13066463  ; sigma for fit
 CHISQ     DOUBLE 0.017085681 ; chisq (not meaningful unless you supply valid weights
 ITER      INT    4           ; number of times the curvefit() routine interated 

(See /pkg/rsi/local/libao/phil/p12m/p12mfittsys.pro)


P12MGETLOG - READ P12M LOG DATA

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mgetlog - read p12m log data
SYNTAX: istat=p12mgetlog(lun,dat,nrecs=nrecs,posrec=posrec,dcd=dcd)
ARGS: 
     lun       : int   file to read. already opened
KEYWORDS:
   nrecs: long   number of records to read. def=1
   posrec:long   record to position to. def:next record
                 count from 1
   dcd   :       if set then return structs with the device, programs words
                 decoded

RETURNS:
istat: long	> 0 number of records returned
                 0 : hit eof
              <  0 : error
dat[istat]:{p12mLogI}   array of structs holding log info

		struct format is:
a={p12mstBlk,$
    double   mjd,   $ device systime at read
    ; 32bit status.  not decoded
    azMSt32:0ul,$
    azSSt32:0ul,$
    elSt32 :0ul,$
    cenSt32:0ul,$
    azPos_D:0d,$
    azErr_D:0d,$; deg
    azFdBackVel_DS:0d,$;deg/sec
    azMotCur_A:0d,$;
    azSlMotCur_A:0d,$;
    elPos_D:0d,$;
    elErr_D:0d,$;
    elFdBackVel_DS:0d,$;
    elMotCur_A:0d$;
 }
logI={
   cpuTmAtWaitTick: 0d,$// secs 1970 when wait for tick
    cpuTmAtTick: 0d,$    // secs 1970 at tick
    durRdDev: 0d,$       // number secs to rd device
    durWrLast: 0d,$     // number secs for previous write blk
    st:{p12mStBlk} $

(See /pkg/rsi/local/libao/phil/p12m/p12mgetlog.pro)


P12MGETTEMP - GET 12M PEDESTAL TEMP FOR A MONTH.

[Previous Routine] [Next Routine] [List of Routines]
NAME: 
p12mgettemp - get 12m pedestal temp for a month.
SYNTAX: n=p12mgettemp(yymm,tIped,tIctl=tictl,yymmdd=yymmdd)
ARGS:
yymm: long   month to get
KEYWORDS:
yymmdd  : long  if present then ignore yymm and just return this day's data
RETURNS;
  n:     > 0 number of entries found
        < 0  error reading file
tiPed[n] : {}    struct holding pedestal temp info
tICtl[n] : {}    struct holding motor cabinet temp

DESCRIPTION:
   input the temperatures measured in the 12meter pedestal.
 return ti[n] with tI struct holding
IDL> help,ti,/st
   YYMMDD          LONG          20210501   (ast)
   SECMID          LONG                 0   (ast)
   TEMP            FLOAT           79.5000  ; in deg F pedestal/hub
   HUMIDITY        FLOAT           79.5000  ; % humidity
   TEMPDEW         FLOAT           79.5000  ; temp dew point?
 notes:

 202202xx ow includes 12meter pedestal and
                      12meter controller (patriot box)

(See /pkg/rsi/local/libao/phil/p12m/p12mgettemp.pro)


P12MINPDAY - READ P12M LOG DATA FOR THE REQUESTED DAY

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12minpday - read p12m log data for the requested day
SYNTAX: nrecs=p12minpday(yymmdd,d,dcd=dcd)
ARGS: 
 yymmdd : long  data to input yymmdd or yyyymmdd
KEYWORDS:
   dcd   :       if set then return structs with the device, programs words
                 decoded (takes more time). if not supplied then the status words come
                 back as unsigned int32. 
RETURNS:
nrecs: long	> 0 number of records returned
                 0 : hit eof
              <  0 : error
                 -1  filename does not exist
                 -2  file exists but no data
d[nrecs]:{p12mLogI}   array of structs holding log info for each second of day

Terminology
 p12m  : patriot 12meter antenna system

DESCRIPTION:
	The p12mProg runs on a linux computer (currently galfas2). It has 3 components:
 - talk to the outside world taking requests and returning queries.
 - loop driving the p12m telescope. On each 1 second tick it will read the p12m state
 - log info to a disc file and broadcast on the net. This is mainly the 1 second tick data read 
   from the p12m as well as some p12mProg state info
	The log data is written in binary with filenames of /share/phildat/logdata_yyyymmdd.dat where the yyyymmdd
	date changes each day.
	This routine will read in the logfile for a particular data.
The data is returned to the caller as an array of structures. The structure contains data convering:
  - the program p12MProg that is talking to the 12meter amplifiers, status, what is is trying to do
  - data from the 12meter amplifier controllers. 
There are timestamps, locations, and a number of 32bit status words. By default the status words
are returned as 32Bit integers (which means you need to decode them yourself:). If you include the
/dcd keyword then each status word will be decoded into a structure holding name,values for the various bits
(this takes a little longer. If you only want the locations, times then you can skip it).
The routione p12mdcdstat() will decode the status words if you input the binary format.

	The returned structure (with the /dcd set) is:
Notes:
  tm : these are normally returned as unix seconds since 1970. They are normally doubles with 
       sub second resolution.
     : if you want to convert the secs from 1970 to human readable:
       - print,systime(0,d[10230].tickTmisec) will give (only 1 element at a time)
            Wed Jan 13 02:50:30 2021 
       - convert to hhmmss,yymmdd
         [hhmmss,yyyymmdd]=fromsecs1970(secs1970,utc=utc,daynoyr=daynoyr,str=str)
       - to convert an entire day to secMidnite:
          secMid=d.tickmtmisec - d[0].ticktmisec)
          then add on secmidnite for 1st entry
         [hhmmss0,yyyymmdd0]=fromsecs1970(secs1970,utc=utc,daynoyr=daynoyr,str=str)
          secMid0=hms1_secmid(hhmmss0)
 	       secMid+=secmid0	

** Structure P12MLOGI, 17 tags, length=400, data length=392:
   CPUTMATWAITTICK DOUBLE  1.6105104e+09  :When p12mProg start to wait for the tick before read:
                                           Normally 100ms before tick
   CPUTMATTICK     DOUBLE  1.6105104e+09  :Time when program started read (after tick)
   DURRDDEV        DOUBLE  0.021378517    : how long it took to read the device 
   DURWRLAST       DOUBLE  6.6757202e-06  ; how long the last write to device took
   ST              STRUCT  -> P12MSTBLK Array[1]: struct holding status read from p12m
                                            look here for the telescope position, stat,etc
   TICKTMISEC      LONG64  1610510400     : integer seconds from 1970 for this tick
   PRSTATE         STRUCT  -> P12MPRSTWD Array[1]; program status for p12mProg
   NUMIOTHRDS      LONG    1              : how many threads are talking to outside world (5 max)
   FRLISTFRBUFS    LONG    1024           : free list # of free buffers for p12mprog to use
   NDEVCONNECTOK   LONG    4              : # of times p12mProg has connected to p12m
                                            It only tries a reconnect when the i/o fails..typically
                                            someone turns off power when working on telescope.
   NDEVCONNECTFAIL LONG    1              : # of times p12mProg failed on a connection attempt
   TRARFREEPNTS    LONG    0              : # of free points in the track array
   PL              STRUCT  -> P12MPLDAT Array[1]: what p12mProg has requested p12m to do
   AZERRD          FLOAT   0.00000        : pointing error (radians) in azimuth (if tracking)(little circle?)
   ELERRD          FLOAT   0.00000        : pointing error (radians) in elevation ( if tracking)
   GCERRD          FLOAT   0.00000        : great circle pointing error (if tracking).
   FILL            FLOAT   0.00000        : filler

 The p12mStblk is :
DL> help,d.st,/st
** Structure P12MSTBLK, 11 tags, length=184, data length=180:
   MJD             DOUBLE 59227.167        :modified julian date for tick 
   STWDS           STRUCT -> P12MDEVSTWDS Array[1] :structs hold status words
   AZPOS_D         DOUBLE -179.99740       : az position degrees
   AZERR_D         DOUBLE -0.0025000000    : az error degrees
   AZFDBACKVEL_DS  DOUBLE 0.0000000        : az fdback velocit deg/sec
   AZMOTCUR_A      DOUBLE 0.0000000        : az master motor current (amps)
   AZSLMOTCUR_A    DOUBLE 0.0000000        : az slave motor current (amps)
   ELPOS_D         DOUBLE 20.002200        : elevation encoder degrees
   ELERR_D         DOUBLE -0.0023000000    : elevation error 
   ELFDBACKVEL_DS  DOUBLE  0.00030000000   : elevatin fdbackvel deg/sec
   ELMOTCUR_A      DOUBLE  0.0000000       : elevatio motor current
 -----------------------
There are 4 status words from the p12m: az master,az slave, elevation ,and central
 DL> help,d.st.stwds,/st
** Structure P12MDEVSTWDS, 4 tags, length=100, data length=100:
   AZM             STRUCT    -> P12MSTAZM Array[1]
  AZSL            STRUCT    -> P12MSTAZSL Array[1]
  EL              STRUCT    -> P12MSTEL Array[1]
  CEN             STRUCT    -> P12MSTCEN Array[1]
 -----------------------
 az master Status word:
IDL> help,d.st.stwds.azm,/st
** Structure P12MSTAZM, 25 tags, length=28, data length=28:
   STATUS32        ULONG    4194315 ; before decoding
   HIGHHARDLIM     BYTE     0
   LOWHARDLIM      BYTE     0
   HIGHSOFTLIM     BYTE     0
   LOWSOFTLIM      BYTE     0
   MOTSHAFTBRAKEON BYTE     1
   LOCAL           BYTE     0
   DRIVENOTENERGIZED BYTE   1
   DRIVENOTHEALTHY BYTE     1
   TURNCOUNTSERR   BYTE     0
   POSDEMANDLIMHIGH BYTE    0
   POSDEMANDLIMLOW BYTE     0
   NODIGLOCKVIRTAXIS BYTE   0
   OFFSETPROFNOTATSPEED BYTE 0
   OFFSETPROFNOTATPOS BYTE  0
   MAINPROFNOTATSPEED BYTE  0
   MAINPROFNOTATPOS BYTE    0
   FREE2_7         BYTE     0
   MOTBRAKEON      BYTE     1
   MOTBRAKEALARM   BYTE     0
   FREE2_4         BYTE     0
   VIRTAXISSPEEDDEMANDLIM BYTE 0
   FREE_2_2        BYTE     0
   RUNNOTPERMITTED BYTE     0
   DRIVENOTENABLED BYTE     0
 -----------------------
 az slave Status word:
IDL> help,d.st.stwds.azsl,/st
** Structure P12MSTAZSL, 9 tags, length=12, data length=12:
   STATUS32        ULONG 19 ; before decoding
   FREE0_7         BYTE   0
   FREE0_6         BYTE   0
   FREE0_5         BYTE   0
   MOTBRAKEON      BYTE   1
   MOTBRAKEALARM   BYTE   0
   DRIVENOTENABLED BYTE   0
   DRIVENOTENERGIZED BYTE 1
   DRIVENOTHEALTHY BYTE   1
 -----------------------
 elevation  Status word:
IDL> help,d.st.stwds.el,/st
** Structure P12MSTEL, 25 tags, length=28, data length=28:
   STATUS32        ULONG    4194315
   HIGHHARDLIM     BYTE     0
   LOWHARDLIM      BYTE     0
   HIGHSOFTLIM     BYTE     0
   LOWSOFTLIM      BYTE     0
   MOTSHAFTBRAKEON BYTE     1
   LOCAL           BYTE     0
   DRIVENOTENERGIZED BYTE   1
   DRIVENOTHEALTHY BYTE     1
   FREE1_7         BYTE     0
   POSDEMANDLIMHIGH BYTE    0
   POSDEMANDLIMLOW BYTE     0
   NODIGLOCKVIRTAXIS BYTE   0
   OFFSETPROFNOTATSPEED BYTE 0
   OFFSETPROFNOTATPOS BYTE  0
   MAINPROFNOTATSPEED BYTE  0
   MAINPROFNOTATPOS BYTE    0
   FREE2_7         BYTE     0
   MOTBRAKEON      BYTE     1
   MOTBRAKEALARM   BYTE     0
   MAINBRAKEALARM  BYTE     0
   VIRTAXISSPEEDDEMANDLIM BYTE 0
   MAINBRAKEON     BYTE     0
   RUNNOTPERMITTED BYTE     0
   DRIVENOTENABLED BYTE     0
 -----------------------
 central  Status word:
IDL> help,d.st.stwds.cen,/st
** Structure P12MSTCEN, 29 tags, length=32, data length=32:
   STATUS32        ULONG        808742917
   AUTOSTOWINPACTIVE BYTE    0
   TRKARRAYLESS10PNTS BYTE   0
   TMOUT30SEC      BYTE      0
   SNTPRESPONSESLOW BYTE     0
   SYSCLKNOTINITIALIZED BYTE 0
   SUMOPERATENOTREADY BYTE   1
   SUMNOTREMOTE    BYTE      0
   PWR3PHASEOFF    BYTE      1
   AZTRKSTARTOUTOFRANGE BYTE 0
   AZTRKSTARTTURN  BYTE      3
   TMOUT30SECDISABLED BYTE   1
   RADECTRKINGDATA BYTE      0
   TRKCOORDEQUAT   BYTE      0
   STOWINPROGRESS  BYTE      0
   CURRUNMODE      BYTE      0
   AZSLVONLINE     BYTE      1
   AZMASTERONLINE  BYTE      1
   FREE2_3         BYTE      0
   ELONLINE        BYTE      1
   FREE2_1         BYTE      0
   TRKARRREINIT    BYTE      0
   CONNECTFILTERON BYTE      0
   FREE3_6         BYTE      0
   CORRECTIONSDISA BYTE      3
   CURAZELOFFSETMODE BYTE    0
   CURRADECOFFSETMODE BYTE   0
   FREE3_1         BYTE      0
   CUROFFSETMODE   BYTE      0

(See /pkg/rsi/local/libao/phil/p12m/p12minpday.pro)


P12MLO1 - COMPUTE LO1 FROM REQUESTED RF FREQUENCY

[Previous Routine] [Next Routine] [List of Routines]
NAME: 
p12mlo1 - compute lo1 from requested RF frequency
SYNTAX: istat=p12lo1(rfFreq,lo1,if1cfr=if1cfr)
ARGS:
rfFreq: double rf freq in Mhz
KEYWORDS:
IF1CFR: double   if1 cfr in Mhz. def= 1500.
RETURNS:
istat:  int      1 computed ok
                -1  outside udc lo1 band
DESCRIPTION:
   The udc lo1 equation is:
 lo1=(22500 + (rfFreq - if1Cfr))/4.	
   The udc lo1 range is 5750 to 8250.

(See /pkg/rsi/local/libao/phil/p12m/p12mlo1.pro)


P12MMODEVAL - EVALUATE THE MODEL CORRECTION AT THE REQUESTED AZ,EL

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mmodeval - evaluate the model Correction at the requested az,el

SYNTAX : p12mmodeval,az,el,modelData,azCorAsec,elCorAsec,$
                     refCorD=refCorD

 ARGS    : 
   az[]  :     azimuth positions degrees.
   el[]  :     elevation angle positions degrees.
   modelData: {modelData} loaded by p12mmodinp. 
 Returns:
   azCorAsec:  [] return greate circle az correction in arc seconds.
   elCorAsec:  [] return  el correction in arc seconds.
                  This includes the refraction correction.
                  Add this value to elReq (not elRefracted) to get elToUse.
   refCorD:    [] elR -El in deg. This is already included in elErrAsec
                  i've included it here just for reference.

 DESCRIPTION:
   Evaluate the model at the specified az, el locations. 
 Use the model data in the structure modelData
 (this structure can be loaded via p12mmodinp).

 Return the model Corrections in great circle arc seconds evaluated at the
 az,el. The errors are defined such that:
 1. let azComp,elComp be the computed az, el to move the telescope to.
 2. compute azCor, elCor from the model.
 3. azTouse = azComp + AzCor*asecToRad
    ElTouse = ElComp + ElCor*asecToRad
 4. this includes the refraction correction to el. So you Add the el value
    to the elValue  without the refraction correction

(See /pkg/rsi/local/libao/phil/p12m/p12mmodeval.pro)


P12MMODINP - INPUT MODEL COEFFICEINTS

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mmodinp - input model coefficeints

SYNTAX :p12mmodinp,modelData,model=model,suf=suf,rcv=rcv

 ARGS  : 
modelData: {modelData} data returned here. Structure defined in
                       aodefdir()/idl/h/hdrPnt.h

 KEYWORDS:
    model:   model name: eg modelSB, modelCB.. filename should be in
             aodefdir()+"data/pnt" directory with a name modelXXX. You
             can override this with the rcvNmm keyword.
             default: modelSB
    suf  :   suffix for the model you want. suffixes are changed as
             new models are added. current suffix may00 is 11A.
             if not provided then use the current model.
    mfile:  string model filename (if not standard format).
   rcvNum:  int    if supplied then use model for this receiver. 
                   overrides model= keyword
   dirmod:  string  directory for model. override default directory
WARNING:
   If you are not at AO, then the model info was current when you downloaded
 the aoidl distribution. It may have been updated since then. Check
 the file aodefdir()+"data/pnt/lastUpdateTmStamp. It contains the date
 when your data was copied from the online archive.

(See /pkg/rsi/local/libao/phil/p12m/p12mmodinp.pro)


P12MREFRACT - COMPUTE REFRACTION CORRECTION;

[Previous Routine] [Next Routine] [List of Routines]
NAME: 
p12mrefract - compute refraction correction;
SYNTAX: elRD=p12mrefract(elD);
ARGS:
elD[n]: float/double elevation in degreed
RETURNS:
elDR[n]: double  refraction corrected elevation (in deg)

(See /pkg/rsi/local/libao/phil/p12m/p12mrefract.pro)


P12MTSYSEVAL - EVALUATE P12M TSYS FIT AT ELEVATIONS

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mtsyseval - evaluate p12m tsys fit at elevations
SYNTAX: tsys=p12mtsyseval(fitI,el)
ARGS:
fitI: {}    struct holding fit info (from p12mfittsys())
el[n]: float elevations for tsys evaluation.
RETURNS:
TSYS[n]: float tsys deg K 
DESCRIPTION:
	Evaluate tsys at the requested elevations. The caller passes in the
fit Info struct (from p12mfitsys) and the elevations to evaluate tsys at.
The routines the tsys values. This will return tsys for 1 pol
If you want Tsys for both pols then call the routine twice using
the fit for polA and then polB

(See /pkg/rsi/local/libao/phil/p12m/p12mtsyseval.pro)


P12MTSYSVSEL- RETURN TSYS VS EL FOR A GIVEN FREQUENCY

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12mtsysvsel- return tsys vs el for a given frequency
SYNTAX: istat=p12mtsyvsel(freq,el,tsys,freqused,yymmdd=yymmdd)
ARGS:
 freq: float   freq in Mhz to use
 el[n]: deg    elevations to compute tsys at
KEYWORDS:
yymmdd  :  long  if supplied then evaluate tsys for this date. The default is the
                 last fit parameters.
RETURNS:
 istat   : int    >0 number of values returned in tsys
                  < 0 error.
tsys[n,2]: float deg K tsys polA,polB at the requested elevation for this freq.
freqused : float Mhz  the frequency used for the evaluation. It will be the closest
                      fit freq.
DESCRIPTION:
	Fits were made to tsys vs elevation for 7 freq bands at xband. This routine
will return tsys evaluated at the fit values. You input a single freq and 1 or more elevations.

(See /pkg/rsi/local/libao/phil/p12m/p12mtsysvsel.pro)


P12M_MENUADR - GENERATE FILE HOLDING MENU NAMES AND ADRESSES.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
p12m_menuadr - generate file holding menu names and adresses.
SYNTAX:istat=p12m_menuadr(menuNum,sadr=sadr,maxParam=maxParam ,outDir=outDir)
ARGS:
menuNum: int   1..22 menu numbers
KEYWORDS:
sadr    : string a string specifying the parameters to include for this menu
                 this lets you specify random params: 
                 eg: '0 1 2 5 6 8 23'
                    or 'max nn' will generate from 0 to nn
maxParam: int    if specified then generate 0 to maxparam parameter numbers
outDir  : string  directory to output to. def is  ./
DESCRIPTION:
	Generate ascii file holding menu.param and address (one per line).
this file can be input to dump_adr to read the menu contents from the drive.

(See /pkg/rsi/local/libao/phil/p12m/p12m_menuadr.pro)


P12M_RADECJTOAZEL - CONVERT J2000 TO P12M AZ,EL.

[Previous Routine] [List of Routines]
NAME:
p12m_radecjtoazel - convert j2000 to p12m az,el.
SYNTAX: p12m_radecjtoazel,rcv,raHr,decDeg,julDat,az,el,nomodel=nomodel
ARGS:
       rcv: int    receiver number 1 - 2200, 2 - 8000.. ignored..
   raHr[n]: float/double   J2000 ra in hours
 decDeg[n]: float/double   J2000 dec in Deg
 julDat[n]: double julian date for each point (utc based). 
KEYWORDS:
   nomodel: if set then do not include model correction in az,za.
 julDat[n]: double julian date for each point (utc based). 

RETURNS:
     az[n]: float/double   azimuth in degrees
     el[n]: float/double el in degrees
DESCRIPTION:
   Convert from J2000 ra, dec to actual azimuth, elevation angle
 encoder values. These are the values that would be read off
of the encoder in actual operation (the model corrections 
have been included). The juliandate should be utc based.
 If you use julday() function remember to
added 4./24D if you use ast hour,min,seconds. The precession nutation
is computed for each julian day of the input data.

NOTE:
   Be sure and define the juldat as a double so you have enough
precision.


EXAMPLE:
   using the daynotojuldat routine.. you could also use juldat()
   convert from hhmmss, ddmmss to hr.h deg.d
   ra=205716.4D
   dec=025846.1D
   raH=hms1_rad(ra)*!radeg/360.D*24D
   decD=dms1_rad(dec)*!radeg

   convert date to dayno with fraction

   mon=11
   day=19
   year=2002
   astHHMMSS=174258L
   daynoF=dmtodayno(day,mon,year) + hms1_rad(asthhmss)/(2.D*!dpi)
   compute julianday 
   julday=daynotojul(daynoF,year) + 4./24.D
   
   you could also have done this with:

   julday=julday(11.D,19.D,2002.D,17.D,42.D,58.D) + 4./24.D
   rcv=5               ; lbw

   p12m_radecJtoazel,rcv,raH,decD,julday,az,el
   print,az,el

(See /pkg/rsi/local/libao/phil/p12m/p12m_radecjtoazel.pro)