NAME: agcazencdifavg - average azimuth enc difference to 1 deg bins SYNTAX: agcazencdifavg,b,dI,azLoc=azLoc ARGS: b[n] : {} input from agcinpday. will average using this data RETURNS: dI : {} holds the enc average difference info azLoc[360]. fltarr return the azimuth values used for the 360 bins DESCRIPTION: Using the data passed in via b[], compute the azimuth encoder difference for each 1deg in azimuth. Return the info in the structure dI. help,dI,/st ** Structure, 5 tags, length=4328, data length=4328, refs=1: YYMMDD LONG 191106 start date in b NTOT LONG 0 number of total points we used CNTAR LONG Array[360] number of pnts for each 1 deg bin AZDAVG FLOAT Array[360] average each 1 deg bin AZDMED FLOAT Array[360] median of each 1 deg bin. The routine only uses azmimuth samples where the azimuth is moving (abs(encoder velocity) > .0005 deg/sec).
(See /pkg/rsi/local/libao/phil/agc/agcazencdifavg.pro)
NAME: agcazencdifinpavg - average azimuth enc difference to 1 deg bins SYNTAX: ndays=agcazencdifinpavg(yymmdd,dIAr,ndays=ndays,azLoc=azLoc,range=range.verb=verb) ARGS: yymmdd: long start date to input KEYWORDS: ndays : long number of days to process. def=1 if ndays < 0 then start ndays-1 before yymmdd. (-1,1 is always current day verb : if set the list days as they are input RETURNS: ndays: long number of days we actually found with data dIAr[ndays] : {} holds the enc average difference info for each day azLoc[360]; fltarr return the azimuth values used for the 360 bins range[] : long return the first,last yymmdd used for the plots. if only one day, the range[1]. if multiple days then range[2] DESCRIPTION: Input ndays of agc data starting at yymmdd. If ndays is supplied then input abs(ndays). If ndays >0 start at yymmdd. If ndays is < 0 then start at yymmdd - (abs(nday)-1). After inputting the data, compute the avgerage encoder differencefor each deg 0 to 360. The bins are at .5,1.5,.. to 359.5 deg azimuth The averaged data for each day is returned in dIAr[ndays] help,dIAr,/st ** Structure, 5 tags, length=4328, data length=4328, refs=1: YYMMDD LONG 191106 start date in b NTOT LONG 0 number of total points we used for this day CNTAR LONG Array[360] number of pnts for each 1 deg bin AZDAVG FLOAT Array[360] average each 1 deg bin AZDMED FLOAT Array[360] median of each 1 deg bin. The routine only uses azmimuth samples where the azimuth is moving (abs(encoder velocity) > .0005 deg/sec). azloc contains the azimuth value for each of the 360 bins.
(See /pkg/rsi/local/libao/phil/agc/agcazencdifinpavg.pro)
NAME: agcazencdifplot - plot azimuth encoder difference averaged to 1 deg bins. SYNTAX: agcazencdifplot,dIAr,tit0=tit0,stddif=stddif,verD=verD ARGS: dIAr[ndays]: {} averaged az enc dif data (see agcazencdifinpavg) KEYWORDS: tit0 : string add to title of top frame stddif[360]: float input the standard difference (in degs). This is used to plot limit lines around the averaged data. The limit lines are +/- .01 degrees about this line When an encoder jumps 1 tooth, the encDif jumps about .02 degrees. verD[2]: float vertical range for the degree plot, def: [-.06,.06] azLoc[360]: float azimuth values for each averaged bin. The def is .5,1.5,2.5...359.5 DESCRIPION: Plot the azimuth encoder difference for each day in dIAr[ndays]. The data is input and averaged by agcazencdifinpavg; The plot has two frames: top Frame: az encoder dif in degrees bottom frame: az encoder dif in encoder counts Limit lines are plotted around the averaged data. They are taken from stddif[360] (or the oct19 avg 14-31 day). The lines are +/- .01 degrees about stddif. When the encoder jumps by 1 tooth, this is about .02 degrees. The keyword verD[2] can be used to set the vertical scale for the degree avg (the default is [-.06,.06] degrees (with the encoder plot scaled to these values). Examples: plot the data for oct19 yymmdd=191001 ndays=agcazencdifinpavg(yymmdd,dIAr,ndays=31,azloc=azloc) agcazencdifplot,dIAr,tit0='191001 - 191031',verD=[-.1,.06],azLoc=azLoc
(See /pkg/rsi/local/libao/phil/agc/agcazencdifplot.pro)
NAME: agcinp - input agc records from a log file. SYNTAX: pnts=agcinp(lun,b,nptsreq,cb=cb,fb=fb,onekind=onekind) ARGS: lun: long lun for file to read from nptsreq: long number of recs to read in. if <=0 or not supplied then read to end of file. b[] : {cbfb} return cblock,fblock info here, if cb or fb set then structure will only be cb or fb pnts : long return the number of points input. KEYWORDS: cb : if set, only input cblock fb : if set, only input fblock onekind: if set then the datafile only has the cb, or fb specified DESCRIPTION: agcinp is normally called from agcmoninp or agcinpday.
(See /pkg/rsi/local/libao/phil/agc/agcinp.pro)
NAME: agcinpday - input all the agc info for 1 day. SYNTAX: npts=agcinpday(date,b,cb=cb,fb=fb,onekind=onekind,raw=raw,dirL=dirL) ARGS: date: long yymmdd file to input b[] : {cbfb} return cblock,fblock info here, if cb or fb set then structure will only be cb or fb npts: long number of samples found KEYWORDS: cb : if set, only input cblock fb : if set, only input fblock raw : return raw struct as read from vertex. onekind: if set then the datafile only has the cb, or fb specified dirL[]: string list of extra directories to search for files RETURNS: npts: long number of samples found for this day. DESCRIPTION: agcinpday will input all of the agc data for the requested day. The array B[] will typically have 86400 entries (1 per second). The data structure is described in agcIntro above.
(See /pkg/rsi/local/libao/phil/agc/agcinpday.pro)
NAME: agcinpraw - input raw agc records from a log file. SYNTAX: pnts=agcinp(lun,b,nptsreq,cb=cb,fb=fb,onekind=onekind) ARGS: lun: long lun for file to read from nptsreq: long number of recs to read in. if <=0 or not supplied then read to end of file. b[] : {cbfb} return cblock,fblock info here, if cb or fb set then structure will only be cb or fb pnts : long return the number of points input. KEYWORDS: cb : if set, only input cblock fb : if set, only input fblock onekind: if set then the datafile only has the cb, or fb specified DESCRIPTION: agcinp is normally called from agcmoninp or agcinpday.
(See /pkg/rsi/local/libao/phil/agc/agcinpraw.pro)
NAME: agcintro - intro/examples for agc routines. The main telescope drive systems (Az,Gr,Ch or AGC) were designed and built by vertex antenna company. There are two status blocks:Critical and Full blocks that are logged to disc once a second. The files are kept by day with the filenames cbFbyymmdd.dat in the directory /share/obs1/pnt/log. The last 6 months of data is normally kept on disc (data before this is backed up to tape). The idl routine agcinpday allows you to input and manipulate this data. The data is returned as an array of idl structures eg: IDL> npts=agcinpday(020605,b) IDL> help,b B STRUCT = -> CBFB Array[86399] IDL> help,b,/st ** Structure CBFB, 2 tags, length=288: CB STRUCT -> CB Array[1] .. this is the critical block FB STRUCT -> FB Array[1] .. this is the full block The critical block contains: DL> help,b.cb,/st ** Structure CB, 8 tags, length=56: TIME DOUBLE .013 .. seconds from midnite TMOFFSETPT FLOAT 0.00000 .. time offset for program track FREEPTPOS UINT 127 .. free queue locations for prgmtrk GENSTAT UINT 64 .. generic status (bitmap) MODE UINT Array[3] .. axis mode bitmaps (az,gr,ch) STAT UINT Array[3] .. axis status bitmaps (az,gr,ch) VEL FLOAT Array[3] .. motor velocity deg/sec (az,gr,ch) POS FLOAT Array[3] .. encoder pos deg (az,gr,ch) The full block contains: IDL> help,b.fb,/st ** Structure FB, 19 tags, length=232: TIME DOUBLE 0.08400 .. seconds from midnite AX STRUCT -> FBAXISINFO Array[3].. axis info struct(az,gr,ch) AZENCDIF FLOAT -0.0295564 .. azEnc1-azEnc2 (deg) (dome-ch) TQAZ FLOAT Array[8] .. az torques in ftlbs. motor order:11,12,51,52,41,42,81,82 TQGR FLOAT Array[8] .. gregorian torques in ftlbs. motor order:11,12,21,22,31,32,41,42 TQCH FLOAT Array[2] .. carriage house torques in ftlbs. motor order:1,2 PLCINPSTAT BYTE Array[20] .. input status block from plc PLCOUTSTAT BYTE Array[24] .. output status block from plc POSSETPNT FLOAT Array[3] .. position set point az,gr,ch (deg) VELSETPNT FLOAT Array[3] .. velocity setpoint deg/sec (az,gr,ch) BENDINGCOMPAZ INT 21 .. bending compensation for az TORQUEBIASGR INT 31 .. torque bias for gr (ftlbs) GRAVITYCOMPGR INT -26 .. gravity compensation gr (ftlbs) TORQUEBIASCH INT 0 .. torque bias ch GRAVITYCOMPCH INT 0 .. gravity compensation ch (ftlbs) POSLIM FLOAT Array[2, 3].. poslim [upper,lower],[az,gr,ch] deg ENCCOR FLOAT Array[3] .. encoder correction [deg] (az,gr,ch) TMOUTNOHOSTSEC INT 20 .. timeout for vme system (secs) TMELAPSEDSEC LONG 24650888 .. elapsed time in seconds. Somethings to watch out for. 1. times: The cblock and fblock have slightly different time stamps since they are sampled serially. Occasionally the 1st time of a file is 86400.003 rather than .003. You need to fix this if it messes up plotting versus time. 2. positions/velocities: The positions cb.pos[] are the encoder values and are extremely accurate. The velocities cb.vel[] are derived from the amplifiers. Each amplifier has a voltage readback that is proportional to the speed. cb.vel[1] is the average of the eight dome amplifiers. If you want an exact velocity, use the difference of encoder positions divided by the time difference between readings. The position setpoint b.fb.setpoint[] is the last preset position requested. When running in program track mode (normal operation), this value does not reflect the current location of the dome. The velocity setpoint b.fb.velsetpnt is the velocity setpoint in degrees per second that is passed to the analog circuitry by the plc. The bias voltages (torque,gravity, delta velocity) are then added to this value to drive the PI loop. 3. torques. The ch and gr torques are calibrated via hagens torque wrench. We need to do this for the azimuth motors too. The bending compensation, torquebias, gravity compensation are from vertex and they need to be double checked. 4. The last 12 bytes of plcoutstat have been replaced in the lcu with the irig clock time monitor. EXAMPLES: 1. Input a days worth of data. npts=agcinpday(020611,b) 2. fixup the time to be hour of the day tm=b.cb.time/3600. tm[0]=tm[1] ; fix up the 86400. junk 3. plot dome position versus hour plot,tm,b.cb.pos[1] 4. grab the dome torques into a separate array and reorder from [8,86400] to [86400,8] to make it easier to plot then do a strip plot versus time with each tq a separate color. (see generic idl routines stripsxy) tqgr=transpose(b.fb.tqgr) stripsxy,tm,tqgr,0,0,/step 5. monitor the torques on the dome for the current day: agcmon,-1
(See /pkg/rsi/local/libao/phil/agc/agcintro.pro)
NAME: agclabmot - label the motor colors SYNTAX: agclabmot,axis,ln=ln,scl=scl,xpos1=xpos1,xpos2=xpos2,xposhb=xposhb, cs=cs,grp=grp,font=font ARGS: axis : string 'az','gr', or 'ch' KEYWORDS: ln: int line number to start 0..31, default=2 step: float line step. Default=1. xpos1: float xpos start of first col. 0..1 . def:.02 xpos2: float xpos start of 2nd col. 0..1 . def:xpos1 + .1 xposHB:float xpos for hydraulic brake labels (def:xpos + .1) cs: float charsize scaling. default=1. grp : int if 1 or 2 , then only label groups 1 or 2 font: int font to use . 0 normal, 1=truetype RETURNS: DESCRIPTION: Label the colors used for the various motors.
(See /pkg/rsi/local/libao/phil/agc/agclabmot.pro)
NAME: agcmon - monitor the drive motor torques. SYNTAX: agcmon,yymmdd,axis=axis,disp=disp,win=win,mlab=mlab,$ magpnts=magpnts,msmo=msmo,delay=delay,hshift=hshift,$ smo=smo,debug=debug,veldaily=veldaily,hortm=hortm,$ highres=highres ARGS: yymmdd: long date to display. -1 --> current day KEYWORDS: axis : string axis for torques. az,gr, ch. default is 'gr' disp : int 1 ->upper magnified display only 2 ->lower daily display only default both win: long window number to display in. This allows the user to setup the window dimensions and position before calling this routine. The default is 0. Window 4 is used for the pixwin, so do not use it as the display window number. mlab[6]: float specify motor label text position [0] - line 0..31 def 2.5 [1] - line step def .7 [2] - xpos 1st col def .02 [3] - xpos 2nd col def .12 [4] - xpos HB def .22 [5] - charsize def 1.3 highres: if set then stop after each magpnts display so use can inspect it.
(See /pkg/rsi/local/libao/phil/agc/agcmon.pro)
NAME: agcmoninp - input the monitor data. SYNTAX: newrecs=agcmoninp,yymmdd,b,curpos=curpos,daynum=daynum,year=year,$ append=append,inprecsize=inprecsize DESCRIPTION: This routine is called by agcmon to input the next set of monitor data.
(See /pkg/rsi/local/libao/phil/agc/agcmoninp.pro)
NAME: agcopen - open log file SYNTAX: lun=agcopen(yymmdd,dirL=dirL,dirUsed=dirUsed,fnameUsed=fnameUsed) ARGS: yymmdd: long data to open dirL[]: string list of directories to include in default search path RETURNS: lun : long lun for open file. -1 if open failed dirUsed: string directory used (with trailing /) fnameUsed: string basename used DESCRIPTION: agcinp is normally called from agcmoninp or agcinpday.
(See /pkg/rsi/local/libao/phil/agc/agcopen.pro)
NAME: agcplotsum - plot a summary of the agc data. SYNTAX: agcplotsum,b,az=az,gr=gr,ch=ch,title=title,loff=loff,$ vaz=vaz,vdaz=vdaz,vtq=vtq,tqinc=tqinc,tqsmo=tqsmo,$ win=win,/wait,page=page,fl=fl ARGS: b[] : {cbfb} data read via agcinp,or agcinpday to plot KEYWORDS: az : if set plot az info (def) gr : if set plot gr info ch : if set plot ch info title: string title for each plot (eg date..)' loff : float offset for labels on left side of page units are fraction of x scale. The default is .06 which is good for interactive viewing. For hardcopy use loff=.15 vaz[2]: float min max for az vs time vdaz[2]: float min max for az encoder difference vtq[2]: float min max for torque plots tqinc : float display offset between each motor tq plot. def=0 tqsmo : int number of seconds to smooth motor tqs. def=1 (no smoothing) win[]: window numbers to plot each page in.. wait : if set then wait for user to hit a key between each plot fl[]: float list of hours to flag page : int plot just one page of the info. default is all DESCRIPTION: Plot the agc data input via agcinp or agcinpday. If you want a range of the array, use where before calling this routine. The keywords select which axis to plot: az, gr or ch. By default the az data is plotted. If more than one keyword is set then the plot is determined by : az,gr,ch. To send the data to a ps file use: pscol,'junk.ps',/full agcplotsum,b hardcopy x NOTE: only azimuth plotting has been implemented.. When something in the gr breaks, i'll probably implement it too...
(See /pkg/rsi/local/libao/phil/agc/agcplotsum.pro)
NAME: agcplttqavg - avg then plot the torques SYNTAX: agcplttqavg,b,nbinsVel,axis=axis,minV=minV,maxV=maxV,velbin=velbin,$ cntbin=cntbin,tqavg=tqavg,vtq=vtq,usespd=usespd,fl=fl) ARGS: b[npnt]: {cbfb} struct returned from agcinpday nbinsVel: long number of velocity bins to use. KEYWORDS: minV : float min value for the histogram (default is find min) maxV : float max value for the histogram (default is find max) axis : int 1=az,2=gr,3=ch vtq[2] : float if specified, then the vertical scale for the torque usespd : if set use motor speed readout rather than encoder to compute the velocity. fl : [] flag these locations in plots RETURNS: tqavg[nbins,nmot]: float averaged data velbin[nbin]: float array holding the velocity bins. cntbin[nbin]: float number of counts we had in each velocity bin DESCRIPTION: Compute the velocity from the encoder positions and then make a histogram of the velocity. For each motor find all the points that fall in each velocity bin and average them. Return a binned avg of the torques for each motor. plot the data and return the results. EXAMPLE: ; average the azimuth torques. npnts=agcinpday(yymmmdd,b) agcplttqavg(b,51,minV=-.5,maxV=.5,axis=1,tqavg=tqavg,velbin=velbin,$ cntbin=cntbin)
(See /pkg/rsi/local/libao/phil/agc/agcplttqavg.pro)
NAME: agctqavg - avg the torques using vel histogram SYNTAX: tqavg=agctqavg(b,nbinsVel,axis=axis,minV=minV,maxV=maxV,velbin=velbin,$ cntbin=cntbin) ARGS: b[npnt]: {cbfb} struct returned from agcinpday nbinsVel: long number of velocity bins to use. KEYWORDS: minV : float min value for the histogram (default is find min) maxV : float max value for the histogram (default is find max) axis : int 1=az,2=gr,3=ch RETURNS: tqavg[nbins,nmot]: float averaged data velbin[nbin]: float array holding the velocity bins. cntbin[nbin]: float number of counts we had in each velocity bin DESCRIPTION: Compute the velocity from the encoder positions and then make a histogram of the velocity. For each motor find all the points that fall in each velocity bin and average them. Return a binned avg of the torques for each motor. EXAMPLE: ; average the azimuth torques. npnts=agcinpday(yymmmdd,b) tqAvg=agctqavg(b,51,minV=-.5,maxV=.5,axis=1) history: 01feb08 - switched axis 1,2,4 to 1,2,3 11feb08 - added usespd option computed velenc correctly (needed to add days so interp worked) switch mean to median for histbin averaging to get rid of outliers.
(See /pkg/rsi/local/libao/phil/agc/agctqavg.pro)