NAME:
rdev0Intro - Intro to using rdev routines.
rdev is the radar processing version of jeff mocks pdev spectrometer.
Data is sampled, filtered, packed, and then output to disc. The disc
format consists of a 1024 byte header followed by packed binary data.
The header contains the standard pdev header:
hdr.h1:{pdev_hdrpdev ,$
magic_num : "deadbeef"XUL,$ ; unsigned long
magic_sp : 0L ,$ ; magic number for sp unsigned long
adcf : 0L ,$ ; adc clock freq Hz.
byteswapCode: 0L ,$ ;
blkSize : 0L ,$ ; size of each block (integration)
nblksdumped : 0L ,$ ; number of blocks dumped
beam : 0L ,$ ; from [pdev] section
subband : 0L } ; 0,1 from [pdev] section
It is followed by the rdev specific header (this is currently being defined)
a={rdev_hdrsp ,$
decF: 0U ,$;decimation: 2&decF on 160Mhz clock
tuner: 0U ,$;for mix to baseband. ..2^16*(fout/fclock)
shiftEn: 0U ,$;upshift bits before output
bitSel: 0U ,$; 0=2,1=4,2=8,3=16 bits output
dualPol: 0U ,$; 0=1pol, 1=2pol
boxEnab: 0U }; 1==> enable boxcar smoothing. 0==> fir
IDL BASICS:
; starting idl.. init rdev routines:
;
idl
@phil
@rdevinit
;
; some basic routines:
;
hor ,0,1000 ; this will limit horizontal to 0 to 1000
hor ; with no args this resets to auto scaling
ver ,-100,100 ; this will limit vertical scale to -100 to 100
ver ; with no args this resets to auto scaling
!p.multi=[0,1,2] ; make 3 plot areas in the plot window (vertically)
!p.multi=0 ; reset to 1 plot in the window
plot,d ; plot the array d
plot,frq,d ; plot d versus frq
;
; To label a plot...
;
plot,frq,d,title='This is the title',xtitle='freq',ytitle='volts'
;
; to send the plot of x,y data to the postscript file:testfile.ps
;
pscol,'testfile.ps',/full
plot,x,y
hardcopy
x
;
; to print the values in an array;
;
print,d[0:99] ; first 100 pnts
USING THE RDEV ROUTINES:
idl ; start idl
@phil ; connect to phils routines
@rdevinit ; initialize the rdev routines
;
; print info on the rdev routines:
;
explain,rdevdoc ; list of all the routines
explain,rdevopen ; rdev documentation.
;
; define the file to use
;
file='/share/pdata/pdev/sp_tamara.20070423.b0a.00000.pdev'
;
; open the file.. returns lun, and the header h.
lun=rdevopen(file,hdr)
;
; look at the header
;
help,hdr.h1,/st
print,hdr.h2
;
; read 16384 samples:
; returns number of points actually read in: npnts
; returns data in int array d[npnts]
;
pntsRequested=16384L
npnts=rdevget(lun,hdr,pntsRequested,d)
;
; plot the first 1000 points of the data
;
hor,0,1000
plot,d[*,0] ;; I dig polA
oplot,d[*,1],col=colph[2] ;; Q dig polA
;
; plot a histogram of the data
;
rdevhist,hdr,d
; input data, compute spectra and plot it
;
naccum=rdevspc(lun,hdr,fftlen,spc,toavg=10,/plot)
(See /pkg/rsi/local/libao/phil/rdev/rdev0intro.pro)
NAME:
rdevget - input pdev radar data
SYNTAX psmp=rdevget(lun,h,nSmpReq,d,pos=pos,cmplx=cmplx,rawbuf=rawbuf,$
dec=dec)
ARGS:
lun : int returned from rdevopen()
h : {} header returned from rdevopen()
nSmpReq:long number of sample points requested. This is the decimated
count.
KEYWORDS:
pos : long if set then start reading this many datasamples from the
front of the file. It skips the header automatically
cmplx : if set then return complex data (default is int)
rawbuf: int if set then return the raw input buffer here (before
negative correction or byteswapping.
dec : long decimate the input by this amount using a boxcar.
0,1 --> no decimation.
RETURNS:
nsmp: long samples we read
d[nsmp,2*npol]: float returned data [*,IA/QA,IB,QB] if not /cmplx
d[nsmp,npol]: complex if /cmplx is set
DESCRIPTION:
Input sampled data from pdev radar processor. You need to call
rdevopen() once to open the file before using this routine.
The returned data is floats unless /cmplx is set. In that case
the return value is complex.
If 2 pols are available then the 2nd dimension of d holds :
polAI,polAQ,polBI,polBQ.
History:
26feb08: swapped i,q to get correct sign
switched to return float or complex.. no more ints
(See /pkg/rsi/local/libao/phil/rdev/rdevget.pro)
NAME:
rdevhist - make a histogram of rdev data.
SYNTAX: rdevhist,hdr,d
ARGS:
hdr : {} header read in with rdropen()
d[n]: int data read in via rdevget()
KEYWORDS:
tit: string title for plot
plot keywords.. you can enter keywords to plot and they will be included.
DESCRIPTION:
Plot a histogram of the sampled data as well as the bit usage. The top
plot is the histogram of the data. The horizontal axis is the values the
data can take. The vertical axis is the fraction of total counts taken.
The bottom plot is a plot of the fraction of time each of the n bits
were a 1.
(See /pkg/rsi/local/libao/phil/rdev/rdevhist.pro)
NAME:
rdevopen - open a pdev radar data file
SYNTAX: lun=rdevopen(filename,h)
ARGS:
filename: string file to open
RETURNS:
h: {} header read from start of file
lun: int logical unit number to use when reading file
DESCRIPTION:
Open a radar file and read the header. After returning from this routine
you are positioned to read the first data same (with rdevget()).
(See /pkg/rsi/local/libao/phil/rdev/rdevopen.pro)
NAME:
rdevspc - compute the spectrum of the data
SYNTAX: naccum=rdevspc(lun,h,fftlen,spc,npol=npol,freq=freq,toavg=toavg,plot=plot,_extra=e,pos=pos
ARGS:
lun: int to read from
h: {} header input from rdevopen()
fftlen:long length of fft
d[npol,n]: int The data read in via rdevget()
Keywords:
toavg: long number of spectra to avg. default is 1
plot : if set the plot spectra
_e : pass to plot routine.. ytitle=ytitle, etc..
pos : long position in file before reading. count from 0,
null or -1 --> read from current position.
RETURNS:
npol : int number of pols we found
spc[fftlen,npol]: float The frequency array for the spectrum (in Mhz).
freq[fftlen]: float freq array Mhz
DESCRIPTION:
Input and compute spectra for rdevdata. toavg keyword allows you to average
multiple spectra. The spectra is returned. it will also return via keywords the number
of pols (npol), the frequency array (freq).
The /plot keyword will plot the spectra before returning.
EXAMPLE:
file='/share/pdata/pdev/sp_tamara.20070423.b0a.00000.pdev'
lun=rdevopen(file,h)
; set each plot in a separate window
!p.multi=[0,1,2]
naccum= rdevspc(lun,h,spc,freq=freq,/plot)
history:
04mar08 .. switched to new decF coding
(See /pkg/rsi/local/libao/phil/rdev/rdevspc.pro)