interference monitoring idl routines

Last modified: Wed Oct 25 13:19:33 2017.


List of Routines


Routine Descriptions

0IMDOC - INTERFERENCE MON DOCUMENTATION.

[Next Routine] [List of Routines]
NAME:
0imdoc - interference mon documentation.

*DAY-----------------------
imgfrq,{imday},frq,{imday}  - extract 1 freq subset from {imday}
iminpday,yymmdd ,{imday}    - input the days worth of data
imls                      - ls current im files online
imopen  ,yymmdd ,lun      - open file, return lun in lun
{imdrec}=imavg  ,{imday1frq} -return average rec for day. use imgfrq 1st
*PLOTTING_-----------------
implot  ,{imdrec}         - plot a an im data structure
implloop,{imday} ,delay   - loop plotting imd with delay secs between each
x[401]=immkfrq ,{imdrec}  - return x array holding the freq for the rec
immktm  ,{imday} ,y       - return y array holding the times(hour)for the rec
*PLOTTING SEQUENTIAL-------
imfreq  ,{imday} ,freq    - freq to plot or -1 freq any freq
imd     ,{imday} ,recnum  - plot recnumber
imc     ,{imday}          - replot current rec
imn     ,{imday}          - plot next rec of selected freq
*MISC----------------------
iminprec,lun,{imdrec}     - input the next record from the file
imlin   ,{imday}          - convert data from db to linear scale
imdb    ,{imday}          - convert data from linear to db
tsys=imtsys,freq          - return tsys for this freq. 0 if not known
davg=imavg(imday)         - compute average 1 freq, 1 day
drms=imrms(imday)         - rms by channel 1 freq, 1 day

*STRUCTURES----------------
d:{imday}          - returned by iminpday
d:yymmdd           - int
d.nrecs            - how many records in day
d.frql[int]        - list of frequencies for this day
d.r[imdrec]        - array of data records. hdr and data
d.crec             - current rec for plotting 1..nrecs
d.cfrq             - current rec for plotting (or -1).
d.r.d[12]          - data record 12, 401 points

r:{imdrec}         - one integration in {imday}
r.h                - {imhdr} header
r.d                - [float 401]   data

h:{imhdr}          - header routine for each record
h.hdrMarker        - bytarr(4)
h.hdrlen           - 0L
h.reclen           - 0L
h.versionj         - bytarr(4)
h.date             - yyyyddd
h.secMid           - 0L
h.cfrDataMhz       - float
h.cfrAnaMhz        - float
h.spanMhz          - float
h.integTime        - long, seconds
h.srcAzDeg:        -   0L

(See /pkg/rsi/local/libao/phil/im/new/0imdoc.pro)


IM1IMG - INPUT AND PLOT AN IMAGE OF 1 FREQUENCY FOR 1 DAY.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
im1img - input and plot an image of 1 frequency for 1 day.

SYNTAX:  im1img,yymmdd,freq,img,xrange,yrange,win=win,zx=zx,zy=zy

ARGS  :
   INPUTS:
   yymmdd: long    year,month,day to display
   freq  : float   frequency band to display
  OUTPUTS:
   img[401,n]:float  2-d image displayed. dbm units.
   xrange[2] :float  min,max frequency   (for x labeling).
   yrange[2] :float  min,max hour of day (for y labeling).

KEYWORDS:
   win   : int     window to write to.default is window,1
   zx    : int     zoom in x direction (by pixel replication). default : 2 
   zy    : int     zoom in y direction (by pixel replication). default : 4 

DESCRIPTION:
   Input a days worth of rfi monitoring data for a particular frequency
band. Create a 2-d image and display it. Return the image and the x,y
label values. Also print out the imgdisp line that was used to display
the image (copy and paste this line to redo the image).

 The frequency bands are:
      70 ,165 , 235, 330, 430, 550, 725, 955,1075,1325,1400,2200,
     3600,4500,5500,6500,7500,8500,9500

The image is scaled to db's. The display routine limits the data range
to -1 sigma and +2 sigma about the median. You can recall the display 
routine with different values.

imgdisp,(img>(-61.0))<(-50.9),xrange=xrange,yrange=yrange,zx= 2,zy= 4,win= 1

In the above line the image is clipped below at -61, and clipped from above
at -50.9. To get an idea of the range of data values you can:
window,0       .. so you don't overwrite the image
plot,img       .. plot out the whole image.

EXAMPLE:
 .. do the following 3 lines when starting idl.
 .. the routines are setup to work from an xterm.

idl
@phil
@iminit

then you enter:

im1img,10423,1325,img,xrange,yrange,
.. the routine will display the image and then print the lines:

   average:-56.9 median:-57.6 rms: 3.35 call:
   imgdisp,(img>(-61.0))<(-50.9),xrange=xrange,yrange=yrange,zx= 2,zy= 4,win= 1

You can use the cursor left button to grab the 2nd line and re-execute it
(this also puts it in idl's history buffer so the up arrow can then 
 re-execute it).

xloadct  .. to start the color  table editor.
window,0
plot,img .. to get an idea of the data range
imgdisp,(img>(-61.0))<(-55),xrange=xrange,yrange=yrange,zx= 2,zy= 4,win= 1
         .. redo the image with a different scaling.
cp       .. position the cursor and then hit a button to read the 
            freq, and time off of the image.

(See /pkg/rsi/local/libao/phil/im/new/im1img.pro)


IMAVG - COMPUTE DAILY AVERAGE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
imavg - compute daily average

SYNTAX:  davg=imavg(d1frq)

ARGS:
	d1frq:{iminpday} single freq data  for 1 day (see imgfrq())

RETURNS:
  davg:{imdrec}  Holds the averaged data.

KEYWORDS:

DESCRIPTION:
	Average a days worth of data at 1 frequency. The user should call:
 iminpday,yymmdd,d
 and then
 imgfrq,d,freq,d1frq
 and then pass d1frq to this routine.
	The data is first converted from db to linear, averaged, and then
 converted back to db.

(See /pkg/rsi/local/libao/phil/im/new/imavg.pro)


IMBPC - BANDPASS CORRECT A DAYS WORTH OF DATA

[Previous Routine] [Next Routine] [List of Routines]
NAME:
imbpc  - bandpass correct a days worth of data
SYNTAX: dbpc=imbpc(d)
ARGS:
   d   :{imday}    days worth of data already input
   dbpc:{imday}    same data after bandpass correction.

(See /pkg/rsi/local/libao/phil/im/new/imbpc.pro)


IMBPC1 - BANDPASS CORRECT 1 FREQ RANGE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
imbpc1 - bandpass correct 1 freq range
SYNTAX: imbpc1,d1
ARGS:
   d1  :{imday}    1 freq range, update in place

(See /pkg/rsi/local/libao/phil/im/new/imbpc.pro)


IMC - REPLOT THE CURRENT CURRENT

[Previous Routine] [Next Routine] [List of Routines]
NAME:
imc   - replot the current current
SYNTAX: imc,d

ARGS:
   d:{iminpday} data input from iminpday.

RETURNS:

KEYWORDS:

DESCRIPTION:
   Replot the current record. This is part of the sequential plotting
package. 

SEE ALSO:
	imd,imn,imfreq

(See /pkg/rsi/local/libao/phil/im/new/imc.pro)


IMDB - COMPUTE DATA FROM LINE TO DB FORMAT

[Previous Routine] [Next Routine] [List of Routines]
NAME:
imdb  - compute data from line to db format
SYNTAX:  imdb,d

ARGS:
   d:{iminpday} data input via iminpday. All of the data will be
				 converted from a linear to db scale. The converted data is
				 returned in place.
RETURNS:
  d:{iminpday}  data returned in place.

DESCRIPTION:
	Convert the data from linear to db format. It is the users responsibility
to keep track of the current data format (linear or db). This routine is
normaly used when averaging a days data: (imlin,imavg,imdb).

(See /pkg/rsi/local/libao/phil/im/new/imdb.pro)


IMGFRQ - GET A SINGLE FREQUENCY SUBSET OF A DAYS DATA.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
imgfrq - get a single frequency subset of a days data.
SYNTAX:  imgfrq,d,frq,d1frq

ARGS:
   d:{iminpday} data for entire day from iminpday().
 frq:float		 Center frequency of band to return. The list of frequencies
			     can be found in d.frql

RETURNS:
 d1frq:{iminpday} single freq data for 1 day.

DESCRIPTION:
   Create a subset of a days data that contains only the band centered
at frq.

(See /pkg/rsi/local/libao/phil/im/new/imgfrq.pro)


IMINPDAY - INPUT ONE DAYS WORTH OF DATA

[Previous Routine] [Next Routine] [List of Routines]
NAME:
iminpday - input one days worth of data
SYNTAX:	iminpday,yymmdd,d[{iminprec}] ,recsfound=recsfound
ARGS:
	yymmdd: long	day to input.
RETURNS:
	recsfound: long	 number of records found
   d:{imday}: structure holding data
DESCRPITION:
	Read in a complete days worth of the im data. The date is specifed by
the argument yymmdd. The d data structure contains:
 help,d,/st
   YYMMDD LONG   60309			the date used
   NRECS  LONG   586           the number of records found
   FRQL   FLOAT  Array[19]     the list of frequencies in use
   R      struct IMDREC[586]   array of structures holding the ind records.
   CREC   INT    15            current record we're displaying
   CFRQ   FLOAT  -1.00000      current frequency we are displaying
The indidividual record formats are:
 help,d.r,/st
  H STRUCT  -> IMHDR Array[1] .. the header for this record
  	 .HDRMARKER  BYTE  Array[4]  the string HDR_
    .HDRLEN     LONG  44        bytes in this header
    .RECLEN     LONG  846       record length (hdr,data) in bytes)
    .VERSION    BYTE  Array[4]  version strin
    .DATE       LONG  2006068   date yyyyddd year, daynumber
    .SECMID     LONG   60       seconds from midnite for this record
    .CFRDATAMHZ FLOAT 165.000   center freq data Mhz
    .CFRANAMHZ  FLOAT 165.000   center freq specAnalyzer Mhz (dif if mixed).
    .SPANMHZ    FLOAT  70.0000  span of spectrum analyzer in Mhz
    .INTEGTIME  LONG   60       peak hold time for this record in secs
    .SRCAZDEG   LONG   -1       not implemented

  D FLOAT  Array[401]         .. the 401 freq points for this rec (in dbm)

(See /pkg/rsi/local/libao/phil/im/new/iminpday.pro)


IMINPREC - INPUT 1 RECORD FROM THE DATA FILE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
iminprec - input 1 record from the data file
SYNTAX: iminprec,lun,r
ARGS:
	lun: int	 logical unit not for file we are reading
RETURNS:
	   r:{imdrec} record of data input 
DESCRIPTION:
	Read in the next record from the data file. This routine is normally
called from the routine iminpday. The returned record contains
 r.h the record header
 r.d the frequency data
See iminpday for a descrption of the header/data.

(See /pkg/rsi/local/libao/phil/im/new/iminprec.pro)


IMLIN - COMPUTE DATA FROM DB TO LINEAR FORMAT

[Previous Routine] [Next Routine] [List of Routines]
NAME:
imlin  - compute data from db to linear format
SYNTAX:  imlin,d

ARGS:
   d:{iminpday} data input via iminpday. All of the data will be
                converted from a db to a linear scale. The converted data is
                returned in place.
RETURNS:
  d:{iminpday}  data returned in place.

DESCRIPTION:
   Convert the data from db to linear format. It is the users responsibility
to keep track of the current data format (linear or db). This routine is
normaly used when averaging a days data: (imlin,imavg,imdb).

(See /pkg/rsi/local/libao/phil/im/new/imlin.pro)


IMMKFRQ - MAKE THE FREQUENCY ARRAY FOR A SET OF DATA.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
immkfrq  - make the frequency array for a set of data.
SYNTAX:  frq=immkfrq(d1frq)

ARGS:
   d1frq:{imdrec} a single data record.
RETURNS:
  frq[401]:float  the frequency array that corresponds to the 401 data
				   points in the record.

DESCRIPTION:
   Compute the frequency array for a single data record. There are 401
data points in each data record. The routine uses the band center frequency,
bandwidth, and number of points to compute the array.

(See /pkg/rsi/local/libao/phil/im/new/immkfrq.pro)


IMMKTM - MAKE THE TIME ARRAY ARRAY FOR A DAYS WORTH OF DATA.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
immktm  - make the time array array for a days worth of data.
SYNTAX:  hr=immktm(d)

ARGS:
   d:{iminpday} days worth of data input using iminpday.
RETURNS:
  hr[n]:float   hour of day for each record in d.

DESCRIPTION:
   Compute the time array for a days worth of data. The data is
returned in hours from midnite (ast).

(See /pkg/rsi/local/libao/phil/im/new/immktm.pro)


IMMOSIMG1FRQ - IMAGE MOSAIC OF MULTIPLE DAYS, 1 FREQ.

[Previous Routine] [Next Routine] [List of Routines]
NAME:
immosimg1frq - image mosaic of multiple days, 1 freq.

SYNTAX: immosimg1frq,year,mon,day1,dohardcopy,freq=freq,nplts=nplts,$
                     bpc=bpc,win=win,_extra=e

ARGS  :
   INPUTS:
   year  : long    year to start with (4 digits)
   mon   : long    month to start with (1 to 12)
   day1  : long    day of month to start with
dohardcopy: int    if hardcopy is not equal to 0, write to the file 
                   idl.ps and then spool to printer via lpr. The
                   default is to write to the screen.
KEYWORDS:
   freq  : float   The rfi monitoring band center frequency to use for the
                   images. The frequecies are: 70 ,165 , 235, 330, 430,$
                    550, 725, 955,1075,1325,1400,2200,3600,4500,5500,6500,$
                    7500,8500,9500. The default is the 1400 mhz band.
   nplts : int     the number of days to put in the mosaic.
   bpc   :         if set then do a bandpass correction before creating the
                   mosaic (min value in channel over day).
   win   : int     window to write to.default is window,1

  Extra keywords that are passed to immosimgscl:
stretch[2]: float  scale stretch[0],stretch[1] to 0 to 255 before plotting.
nohisteq  :        if set then don't do histogram equalization on each
                   freq img. 
linear    :        if set then convert db to linear before scaling and 
                   histogram equalizing the image.

DESCRIPTION:
   immosimg1frq will make a mosaic of spectral density images for a single
frequency band on consecutive days starting at the day specified by 
year,mon,day. The keyword freq= selects the freq band to use. There will
be nplts days in the mosaic. All of the images will be placed on a single 
page. Each image in the mosaic will be spectral density with axes
freq vs hour. 

The image is made from db units (the linear keyword can change this). By
default each image is histogram normalized to cover the dynamic range
of the data.

EXAMPLE:
 .. do the following 3 lines when starting idl.

idl
@phil
@iminit

make a mosaic of 6 days starting 01aug03 for the 1325 band.

   immosimg1frq,2003,8,1,0,freq=1325,nplts=6

The routine uses the current value of the lookup table for display. 
You can adjust the lookup table with xloadct after running the routine.
For hardcopy you should run the routine to the screen, adjust the lookup
table, and then rerun the routine with hardcopy set to 1.

hardcopy=0
immosimg1frq,2003,8,1,hardcopy,freq=1325,nplts=6
xloadct .. then play with sliders
hardcopy=1
immosimg1frq,2003,8,1,hardcopy,freq=1325,nplts=6

SEE ALSO: IM1IMG - mosaic 1 day 1 freq.

(See /pkg/rsi/local/libao/phil/im/new/immosimg1frq.pro)


IMRMS - COMPUTE RMS FOR 1 FREQUENCY FOR A GIVEN DAY.

[Previous Routine] [List of Routines]
NAME:
imrms - compute rms for 1 frequency for a given day.
SYNTAX: drms=imrms(d1)
ARGS:
   d1frq[] :   {imday} where you've extracted just 1 freq via imfrq()
               and passed it thru imlin so it is a linear scale.
   drms:        {imdrec} return rms here
DESCRIPTION:
 compute rms/Mean by channel for a single frequency. d1 should contain
a single frequency and be linear. You can do this via:
iminpday,yymmdd,d
imlin,d
imgfrq,d,d.frql[i],d1
drms=imrms(d1)

 You could then loop on i

(See /pkg/rsi/local/libao/phil/im/new/imrms.pro)