12m Rcvr monitoring routines

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


List of Routines


Routine Descriptions

ARM12INTRO - USING THE 12M RCVMON12 ROUTINES:

[Next Routine] [List of Routines]
NAME:
arm12intro - Using the 12m rcvmon12  routines:
    
    The 12m has a dewar monitoring package that lets us monitor the
dewar temperatures, bias voltages and currents.
    The data is continuously sampled (def once every 3 seconds) and written
to an output file (in binary). The program to do this is
 /share/megs/phil/svn/p12m/wbrcvr/monctl/p12mrcvm.c . It will normally run on
galfas2, talk to the labjack in the wbrcvr and write the data to disc.

A new disc file is created each month using the filenaming
conventions:
    /share/phildat/rcvm12m/rcvm      .. the current month
    /share/phildat/rcvm12m/rcvm.yymm .. previous months eg rcvmN.2212 for dec22

Each of the monthly files contains about 55Mbytes of data (with 3 second sampling).
The data is stored sequentially in time as it is sampled.

    The routines in the rcvmon12 package let you access and plot this data. You
need to be a bit careful what you ask for (because you might get it..). 

    The main routines used by users are:
    
rm12inpday() - input one or more days of data.
rm12plot()   - plot the temperature data that was input.
 
rm12mon()    - input and plot the data for a day, or continually monitor
                the current values.

The other routines are support routines used by these 3.

The data structure used for each sample is:

IDL> help,d,/st
** Structure RCVMON12, 11 tags, length=64, data length=64:
 KEY        BYTE     Array[4]  ; "12m" start of rec id  
 YEAR       LONG     2022      ;  ast
 DAY        DOUBLE   341.00002 ; daynumber ast with fractional day
 PTORR      FLOAT    798.888   ; vacuum pressure in Torr
 TEMPCASE   FLOAT    32.9268   ; LabJack caseTemp degC
 TEMP1K     FLOAT    293.457   ; 16K stage degK
 TEMP2K     FLOAT    293.106   ; 70K state degK
 VGATE      FLOAT    Array[2]  ;  gate voltage polA,B  . V
 VDRAIN     FLOAT    Array[2]  ; drain voltage polA,B  . V
 IDRAIN     FLOAT    Array[2]  ; drain current polA,B  .milliAmps
 VDRAINLNA  FLOAT    Array[2]  ; drainVoltage acrosslna PolA,B
 
rm12inpday will input an array of these structures d[n]. You can then use rm12plot
to plot the data, or you can use the normal idl plot routines for plotting.

When plotting multiple pols, you ,may need to set the vertical scale first so that
 the plotting routines don't autoscale to the min,max of the first pol.

EXAMPLES:
;  start idl
    idl
    @phil
    @rcvmon12init

; input 01jan23 thru 06
 
    nrecs=rminpday(230101,d,lastday=230106) ;
;  plot the 16 k stage using  ascii dates
    ver,0,30
    rm12plot,d,/adate
;  plot the 70k stage
    ver,0,100
    rmplot,d,temp=2,/adate
;
    plot the 16k (black) and 70k (red) stage on same plot.   
    ver,0,120
    rm12plot,d,temp=1,/adate
    rm12plot,d,temp=2,/adate,/over,col=2

; plot the currents 
    ver,30,40
    rm12plot,d,/cur,/adate

; plot the vacuum pressure. log scale
    ver,5e-5,100
    rm12plot,d,/pressure,/adate,/log

(See /pkg/rsi/local/libao/phil/rcvmon12/arm12intro.pro)


RM12INPDAY - INPUT 1 OR MORE DAYS OF 12M RCVMON INFO

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rm12inpday - input 1 or more days of 12m rcvmon info
SYNTAX: nrecs=rm12inpday(yymmdd1,d,lastday=yymmdd2,ndays=ndays,$
                       smo=smo,curfile=curfile,dayno=dayno,year=year)
ARGS:
   long :   yymmdd1 day to input (unless dayno specified)
KEYWORDS:
   lastday:long return data from days yymmdd1 through yymmdd2
				 (unless keyword set dayno)
   ndays  :long return ndays starting at yymmdd1
   smo    :long smooth and decimate the data by this many sample points.
                the datapoints are normally spaces by 22 seconds.
   curfile:     if set, use current file, (used for maintenance purposes)
				 not normally needed even to access current data.
   dayno  :long if supplied, then set yymmdd1 to dayno,year

RETURNS:
   nrecs: number of entries in d
   d[nrecs]: {rcvmon12} the rcvmon data.

DESCRIPTION:
   Input the 12m receiver monitor data for the date yymmdd1. If the
keyword lastday is provided then input data from yymmdd1 through yymmdd2.
If the keyword ndays is provided then input ndays of data starting at
yymmdd1 (ndays overrides lastday). If no keywords are provided just input
the one day. 
   
   The dataset is typically sampled once every 3 seconds.
The data is returned as an array of structures d[nrecs]. Each 
entry contains:

         key        :   bytarr(4) ,$; '12m'
         year       :   0l        ,$; 4 digit year ast
         day        :   0.D      ,$; day of year with fraction of day ast.
         ptorr      :   0.       ,$; vaccuum pressure torr
         tempcase   :   0.       ,$; case temperature deg C
         temp1k     :   0.       ,$; hight temp K
        temp2k     :   0.       ,$;  low temp temp k
         vgate      : fltarr(2)  ,$; gate voltage (V) polA,B
         vdrain     : fltarr(2)  ,$; drain voltage (V) polA,B
         idrain     : fltarr(2)  ,$; drain current (Amps) polA,B
         vdrainlna  : fltarr(2)  } ; drain voltage at lna (remove drop on leads)

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12inpday.pro)


RM12INPRECS - INPUT 12METER RCVMONITOR RECORDS

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rm12inprecs - input 12meter rcvmonitor records 
SYNTAX: nrecs=rm12inprecs(lun,nrecsReq,d,smo=smo)
ARGS:
   lun :       int file containing data to read
   nrecsReq:  long requested number of records to read
KEYWORDS:
      smo: int smooth and decimate by this amount.  should be an odd number
               >= 3. The data will be smoothed and decimated by this amount.
RETURNS:
   nrecs : long    number of records input.
   d[nrecs]:{rcvmon12} data input from file
DESCRIPTION:
   This routine is normally called via rm12inpday or rm12moninp.

   rm12inprecs will try to read the requested number of records from the 
12meter receiver monitoring file that lun points to (you need to open the file
before calling this routine). The number of records actually read is
returned in nrecs. The routine will preallocate an array of nrecsReq
before reading.

EXAMPLE:
   openr,lun,'/share/phildat/rcvm12m/rcvm',/get_lun
   nrecs=rm12inprecs(lun,9999,d)

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12inprecs.pro)


RM12MON - MONITOR THE 12M RECEIVER TEMPERATURES.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rm12mon - monitor the 12m receiver temperatures.
SYNTAX: rm12mon,yymmdd,temp=temp,volt=volt,cur=cur,pressure=pressure,disp=disp,win=win,$
               tlab=tlab,ver=ver,$
               min=min,delay=delay,hshift=hshift,smo=smo,debug=debug,log=log
ARGS:
   yymmdd: long    date to display. -1 --> current day
 
KEYWORDS:
     temp :    int  temp to monitor 1:16K,2:70K,3=casetemp
     volt :    int  voltage to monitor: 1-gate,2-drain,3-lna drain
  pressure:    int  if set then monitor vacuum pressure
  cur     :    int  if set then monitor drain current
    ver[2]:    float vertical scale to use (min,max). If 1 number then
                     go 0 to ver.
     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.
  tlab[4]:   float  specify temp label text position
                    [0] - start line 0..31   def 3
                    [1] - line step          def 1
                    [2] - xpos left (0..1)   def  .02
                    [4] - charsize           def 1.3
   log   :          if set the make vertical display logarithmic.
 -->keywords for HI RESOLUTION upper display
      min :    long number of minutes for upper hi res display. default:
                    60.
     delay:    long The seconds to wait between each display of the magnified
                    display. The default is 20 seconds.
    hshift:    long The number of minutes to leave blank on the right 
                    side of the magnified display. The default is 1 minute
 -->keywords for DAILY lower display
       smo:    long the number of points to smooth,decimate the daily display.
                    The default is 5 or 15  seconds (with 3 sec updates). This is also the update
                    rate for the daily display.
     debug:    If set then output some debugging info about the the number
               of points we read at each i/o.
DESCRIPTION:
   rm12mon will monitor the 12m receiver data. The monitor data is 
being written to disc once every 3 seconds for each receiver. The user can
select temperature, voltage, current, or pressure.

   rm12mon can be used to display an entire days worth of data by setting
the parameter yymmdd to the data of interest. If yymmdd is set to -1 then
the monitoring will display the current day and then continue updating 
every DELAY seconds. The default delay is about 15  seconds. 

   There are two displays each showing data versus hour of
day: a high resolution plot and a plot of the entire day. The DISP keyword
can be used to limit the output to just one of these plots (the default
is both plots are output). By default the 16K temperautre stage of the amplifiers are
displayed. 

   The top plot is a high resolution display showing the last MIN minutes
of data. The dislay will be updated every DELAY seconds. The *'s at the 
right of the plot are the last data points. 
   
   The lower plot is the data versus hour of day for the entire day.
The data has been smoothed and decimated by SMO seconds. This plot will 
be updated every SMO sample points.

EXAMPLES:
   - Plot the temp  data for 02jan23
   rm12mon,230102
   - monitor the current day.
   rm12mon,-1
   - monitor the current day, smoothing the magnified plot to 9 secs (3 samples) 
     and displaying 3 hours of data. 
   rm12mon,-1,smo=3,min=180

NOTE:
   If you call rm12mon,-1... you will need to ctrl-c to get out of it.
After this you should do a retall to get back to the main idl procedure.

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12mon.pro)


RM12OPENFILE - OPEN THE REQUESTED FILE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rm12openfile - open the requested file
SYNTAX: lun=rm12openfile(filename,dirlist=dirlist)
ARGS:
filename: string   file (with or without  directory) to open
KEYWORDS:
dirlist[]: strarr  list of directories to search. If not 
                   present then use the default directories
                   (/share/phildat/rcvm12m/)

RETURNS:
   lun : int       open lun. -1 --> couldn't open
DESCRIPTION:
   Open the requested 12m rcvmon file. The routine will try openning 
filename. If not present, then it will search in the
default directory list: (/share/phildat/rcvm12m/)
It will open regular or compressed files (compressed files
end in .gz).
 the files are names:
 rcvm  - current month
 rcvm.yymm  previous months.

EXAMPLE:
   file='rcvm'
   lun=rm12openfile(file)

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12openfile.pro)


RM12PLOT - PLOT 12MDEWAR TEMPERATURES.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rm12plot - plot 12mdewar temperatures.
SYNTAX: rm12plot,d,temp=temp,cur=cur,volt=volt,pressure=pressure,over=over,$
               sym=sym,autoscale=autoscale,color=col,ln=ln,adate=adate,$
               drange=drange,mframe=mframe,cs=cs,log=log,labadate=labadate,$
               nolab=nolab,xtitle=xtitle,title=title,pol=pol,abpolcol=abpolcol,$
				font=font
ARGS:   
   d[]:{rcvmon} array of data input via rminpday.
KEYWORDS:
   temp    : int    temperature to plot:
                    1 16  deg stage (default) (degK) 
                    2 70  deg stage (degK) 
                    3  case temperature (degC)
   cur     : int    if set then plot the drain currents in milliAmps
   volt    : int    amplifier bias voltage to plot 1-vgate,2=vdrain,3=vdrainlna
  pressure : int   if set display vaccum pressure (in microTorr).
   over    : int   if set then overplot rather than start a new plot
   sym     : int   1,2,3 .. plot a symbol at each measured position.
                   1 +, 2 *, 3 . , Negative number -1,-2,-3 will plot 
                   the symbol and the connecting lines.
 autoscale : int   if set the autoscale the y axis to min,max + .03*(max-min)
  color    : int   if provided then plot the current data set in this color.
                   colors are: (1-white, 2-red, 3-green,4-blue,5-yellow...
  ln       : int   line number for rcvr name labels. values 3..33
  adate    : int   if set then plot using alphanumeric dates: ddMMMyy
  labadate : string if supplied, then this is the output format
                   for label_date call:
                   %M-monName,%N-monNun,%D-dayNo,%Z-yy,%H-hr,%I-min
  drange[3]: float Date range to plot. Use with /adate to limit the
                   dates plotted.  format:[year,daynum,Numdays]
                   keep numdays about year,daynum.
                   (numdays can be positive or negative)
                   note that numdays=0 or -1, or 1 keeps just the current day
  mframe   : int   if set then plot multiple frames on a page with (not yet implemented)
  cs       : float character size scaling if single plot. default=1
  log      :       if true then use log for vertical scale.. 
                   (warning.. don't set lower vertical scale to 0..)
  nolab    :       if set then don't print receiver names at the 
                   bottom.. handy if you supply title=
 xtitle    : string Use this for the xtitle. Handy if you want to specify
                    the dd:hh for labadate
 title     : string Use this for the reciever name
	 				(but not oplot)
 pol       :  1,2   if present then just plot pola(1) or polB 2
 abpolcol  :        if set  and single frame, then plot always plot polb in red.
	 				 normally used for 1 rcv/page pola=black,polb=red
 font      : int   1-truetype, 0 regular

DESCRIPTION:
   Plot the 12m dewar info data versus day of year. The data 
must be first input with rm12inpday. By default it will plot the 16 degree 
temperature stage. You can use the keywords to select the following data to
plot:
 temp: 1,2,3  : T1,T2, case  temperatures
 cur : 
 volt: 1,2,3  : vgate,vdrain,vdrainlna bias voltages

The data can be plotted versus daynumber of the year (default) or
versus an ascii date ddMonyy (using /adate). 

   The axis can be scaled using hor,min,max and ver,min,max (these are two
idl functions). Entering hor or ver without any arguements will autoscale to
the min,max.

   The adate keyword plots the x axis in a more human readable form
ddMonyy. To plot a subrange of the data with this format, hor,min,max
will not work (since the x data gets converted to julian date). Use the
drange[day1st,daylast] keyword to limit the day range in this case.

The /mframe keyword will plot all info on one page (temps,voltages, currents 
(not yet implemented)

   When using the adate keyword, the tickmark end up being spaced by
some reasonable number of days (5,10,20..etc).

   When plotting the voltage or currents, both polarizations will
be plotted (black polA, red polB).

   Making hardcopy requires that you set the destination of the output to
a postscript file before you call the routine.
   pscol,'filename.ps'
   rmplot,d
   hardcopy
   x
The data will then be in the postscript file filename.ps.

   If you used the /mframe keyword, then you don't need color postscript,
but you will probably want to use the entire page for plotting:
   ps,'filename.ps',/full
   rmplot,d,/mframe
   hardcopy
   x

EXAMPLES:
   To start idl:
   idl
   @phil
   @rcvmon12init
   To exit idl:
   exit
   ... 
nrecs=rm12inpday,230101,d,ndays=6         .. input jan 1 to 6
hor
ver,0,50                          .. vertical scale 0 to 50 K
rm12plot,d                        .. plot 16 deg stage
rm12plot,d,/adate .. plot  use, ascii dates
rm12plot,d,temp=2                   .. plot 70 k temps

; plot the gate voltage 
ver,0,5
rm12plot,d,volt=1

; overplot 16,70 k stages
  ver,0,120
  rm12plot,d,temp=1
  rmp12lot,d,temp=2,/over

NOTE:
    The datasets contain 70 Mbytes per month. You should run this on 
a computer with lots of memory;

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12plot.pro)


RM12POSDAY - POSITION TO START OF DAY

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rm12posday - position to start of day
SYNTAX: istat=rm12posday(lun,yymmdd)
ARGS:
   lun :       int file containing data to read
 yymmdd:  long requested number of records to read
RETURNS:
   istat : int  0 - positioned at start (yymmdd <= first rec)
                1 - positioned in file
                2 - positioned at end (yymmdd > last rec of file)
DESCRIPTION:
   rm12posday will position to the start of a day within the file.
This routine is normally called from rm12inpday().

EXAMPLE:
   openr,lun,'/share/phildat/rcvm/rcvm',/get_lun
   yymmdd=221202
   istat=rm12posday(lun,yymmdd)

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12posday.pro)


RM12SMODAT - SMOOTH THE DATA IN 12M RCVMON STRUCT

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rm12smodat - smooth the data in 12m rcvmon struct
SYNTAX: nrecs=rm12smodat(dinp,tosmo,dsmo)
ARGS:
   dinp[n] : {rcvmon12} data to smooth
   tosmo   : long  number of points to smooth
               >= 3. The data will be smoothed and decimated by this amount.
RETURNS:
   nrecs      : long    number of smoothed records returned
   dsmo[nrecs]:{rcvmon12} smoothed data
DESCRIPTION:
   This routine is normally called via rm12inpday or rm12plot

   Smooth the data fields in dinp by tosmo points using a boxcar smoothing.
Each point is normally sampled every 3 seconds. Fields that are not numeric:
.stat use the first element of the pnts to smooth.

EXAMPLE:

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12smodat.pro)


RM12SMOHR - SMOOTH TO ONE HOUR RESOLUTION

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rm12smohr - smooth to one hour resolution
SYNTAX: nrecs=rm12smohr(dinp,dsmo)
ARGS:
   dinp[n] : {rcvmon12} data to smooth to hour resolution 
RETURNS:
   nrecs      : long    number of smoothed records returned
   dsmo[nrecs]:{rcvmon12} smoothed data
DESCRIPTION:
   Smooth the data fields in dinp to one hour resolution.
Each point is normally sampled every 3 seconds.

EXAMPLE:

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12smohr.pro)


RMGETFILE - FIND THE FILES FOR THE SPECIFIED DATE(S)

[Previous Routine] [Next Routine] [List of Routines]
NAME:
rmgetfile - find the files for the specified date(s)
SYNTAX: nfiles=rm12getfile(yymmdd1,yymmdd2,filelist,ndays=ndays)
ARGS:
   yymmdd1: long  date for first day to read 
   yymmdd2: long  date for last day of interest
KEYWORDS:
   ndays: long find files for ndays starting at yymmdd1. In this case
               ignore yymmdd2.
RETURNS:
   nfiles: number of files found.
   filelist[nfiles]: list of files.
   yymmdd2: will return the actual last day used (in case you have
            requested something in the future.
DESCRIPTION:
   Return the list of filenames that contain the 12meter data for yymmdd1 through
yymmdd2. If keyword ndays is provided then return the list of filenames
for the ndays of data starting at yymmdd1 and return yymmdd2.
   The data is stored by month.

EXAMPLE:
   Get the files for jan23 through mar23
   nfiles=rmgetfile(230101,230331,filelist)
   print,nfiles
   3
   print,filelist
   /share/phildat/rcvm12m/rcvm.2301 
   /share/phildat/rcvm12m/rcvm.2302 
   /share/phildat/rcvm12m/rcvm.2303 

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12getfile.pro)


RMMONINP - INPUT THE MONITOR DATA.

[Previous Routine] [List of Routines]
NAME:
rmmoninp - input the monitor data.

SYNTAX: newrecs=rm12moninp(yymmdd,b,curpos=curpos,daynum=daynum,year=year,$
                        append=append,inprecsize=inprecsize)
KEYWORDS:
rcvmonstr: {}  needed if vm version (run from .sav file, don't use license)
               in .sav file version, all the structs need to be predefined 
              
DESCRIPTION:
   This routine is called by rm12mon to input the next set of monitor
data.

(See /pkg/rsi/local/libao/phil/rcvmon12/rm12moninp.pro)