corcalib

advertisement
CORCALIB - INTENSITY CALIBRATE A SINGLE
SPECTRA
[Previous Routine] [Next Routine] [List of Routines]
NAME:
corcalib - intensity calibrate a single spectra
SYNTAX: istat=corcalib(lun,bdat,bcal,bfit,scan=scan,calscan=calscan,$
calinp=calinp,datinp=datinp,avg=avg,maxrecs=maxrecs,$
han=han,sl=sl,edgefract=edgefract,mask=mask,$
bpc=bpc,fitbpc=fitbpc,smobpc=smobpc,blrem=blrem,svd=svd,nochk=nochk
ARGS:
lun
: int
file descriptor to read from
KEYWORDS
scan
: long
calscan : long
scan number for data. default is current position
scan number for cal on scan. def: scan following
the data scan.
calinp[2]:{corget} pass in the caldata rather than read it from lun
datinp[n]:{corget} pass in the data rather than read it from lun
avg:
if set then return the averaged source record
maxrecs: long
maximum number of recs to read in. default is 300.
han:
if set then hanning smooth the data.
sl[]: {sl}
array used to do direct access to scan.
edgefract[1/2]: float
fraction of bandpass on each side to not use
during
calibration. default .1
mask:{cormask} mask structure created for each brd via cormask
routine
use this rather than edgefract.
note: currently mask.b1[1024,2] will use the mask for
the
first pol of each brd for both entries of the board.
bpc: int
1 band pass correct with cal off
2 band pass correct with calon-caloff
3 band pass correct (smooth or fit) with data spectra
The default is no bandpass correction
fitbpc: int
fit a polynomial of order fitbpc to the masked
version of the band pass correction and use the
polynomial rather than the data to do the bandpass
correction. This is only done if bpc is specified.
smobpc: int
smooth the bandpass correction spectra by smobpc
channels
before using it to correct the data. The number should
be
an odd number of channels. This is only done if bpc is
specified.
blrem: int
Remove a polynomial baseline of order blrem. Fit to
the
masked portion of the spectra. This is done after
any bandpass correction or averaging.
svd
:
nochk :
If baselining is done (blrem) then the default fitting
routine is poly_fit (matrix inversion). Setting svd
will use svdfit (single value decomposition) which is
more robust but slower.
if set then don't bother to check the cal records
to see if they are valid (in case they were written
with a non-standard program.
RETURNS:
bdat: {corget} intensity calibrated data spectra
bcal: {corget} intensity calibrated cal spectra
bfit: {corget} if supplied then return the smoothed or fit data that
was
used for the bandpass correction.
istat: 1 ok
: 0 hiteof
:-1 no cal onoff recs
:-2 could not get cal value
:-3 cal,data scans different configs
:-5 sbc length does not match mask length
DESCRIPTION:
For those people who do not do position switching, corcalib allows you
to scale spectra from a src only scan to kelvins and optionally bandpass
correct it. The routine uses a src scan and a cal on,off pair. The data
can
be read from disc or input directly to this routine (via calinp, datinp).
On output bdat and bcal will be in Kelvins. By default the individual
records
of the scan are returned. If the /avg keyword is used, the average of all
of the src records will be returned. If the bfit argument is supplied
then
the fit or smoothed version used for the bandpass correction will also be
returned. It will be scaled to the median bdat value so you can overplot
them.
If the data is input from disc then lun should be the file descriptor
from the open command. By default it will start reading the src scan from
the current file position. The scan=scan keyword lets you position to the
src scan before reading. By default the calscans will be the two scans
following the src scan. The calscan=calscan keyword lets you position
to the cal on scan before reading them. If the scans on disc have more
than
300 records you need to use the maxrecs= keywords so the entire scan will
be input.
By default 10% of the bandpass on each edge is not used for the
calibration
( when computing the conversion factor:
CalInKelvins/ <Calon[maskFrqChn]-calOff[maskFrqChn]>).
You can increase or decrease this with the edgefract keyword. The mask
keyword overrides the edgefract keyword and allows you to use a mask for
each sbc (use cormask to create the mask before calling corcalib).
The calibration will then only use the channels within the mask when
computing
the gain calibration factors. This mask can be used to exclude rfi or
spectral lines.
Bandpass correction can be done with the cal off scan, the
calon-caloff difference spectrum, the data scan, or not at all. These
can be divided into the data scan as they are (although dividing the
data scan into itself is not very interesting!) or you can smooth or
fit a polynomial to the bandpass correction spectrum and then use the
fit/smooothed spectrum for the bandpass correction.
The keyword fitbpc=n will fit an n'th order polynomial to the bandpass
selected by the bpc keyword. Only the area within the mask (or
edgefraction)
will be used for the fit.
The keyword smobpc=n will smooth the bandpass selected by the keyword
bpc and use it to do the bandpass correction (n should be an odd number
>= 3).
You can pass in the data and/or calscans directly by using the
datinp, calinp keywords.
THE PROCESSING:
let Src be the src spectral data
let CalOn be the calOn spectra
let CalOff be the calOff spectra
let < > average over selected channels.The names will then have
Avg appended to them (eg calOnAvg=<calOn>)
let IndFrq be the set of frequency channels selected to use for the
calibration
The calibration consists of:
1. choose
a. The
b. Use
c. Use
indFrq (the channels to use) in the following order:
mask for each board from the mask keyword
edgefract to throw out this fraction of channels at each edge.
an edgefraction of .1 (10%)
2. compute CalOnAvg=<calOn[IndFrq]>,calOffAvg=<calOffAvg[IndFrq]>
3. Scale to Kelvins using: CntToK=CalValK/(calOnAvg-calOffAvg)
CalOnK =calOn*CntToK
CalOffK=calOff*CntToK
SrcK
=Src*CntToK
4. If band pass correction is selected (bpc=1 or 2) then:
bpc=1: bpcN= calOff/<calOff[IndFrq]>
bpc=2: dif= calOn - calOff
bpcN= (dif)/<dif[IndFrq]>
If fitBpc > 0 then
bpcN=polyfit order fitbpc to bpcN[IndFrq]
else if smobpc > 2 then
bpcN=boxcar smooth (bcpN, smooth=smobpc)
then
SrcK=SrcK/bpcN
When deciding on the mask or edge fraction to use, you should have
a region where the calon-calOff is relatively flat (no filter rolloff and
no rfi).
EXAMPLE:
Suppose we have the following scans:
corlist,lun
SOURCE
B1641+173
B1641+173
B1641+173
40.42+0.70
40.42+0.70
40.42+0.70
SCAN
210200235
210200236
210200237
210200238
210200239
210200240
GRPS
5
1
1
5
1
1
PROCEDURE
on
calonoff
calonoff
on
calonoff
calonoff
STEP LST
RCV
on 17:42:08 5
on 17:47:10 5
off 17:47:21 5
on 18:02:53 5
on 18:07:56 5
off 18:08:07 5
To process the first two sets:
--rew,lun
--print,corcalib(lun,bdat,bcal); will process the first set
--print,corcalib(lun,bdat,bcal,/han); will process the 2nd set with
hanning
To process the 2nd set directly with an edgefraction=.12:
--print,corcalib(lun,bdat,bcal,scan=210200238L,edgefract=.12)
To input the data first, interactively create a mask, and then process
the data with a mask
--print,corinpscan(lun,bdatinp,scan=210200238L,/han)
--print,corgetm(lun,2 ,bcalinp,/han) ; reads the next two records
--cormask,bcalinp,mask
; interactively creates the mask
--print,corcalib(lun,bdat,bcal,calinp=bcalinp,datinp=bdatinp,mask=mask)
Use the same cal for multiple data scans:
--print,corgetm(lun,2 ,bcalinp,scan=210200236L/han);
--print,corcalib(lun,bdat1,bcal1,calinp=bcalinp,scan=210200235L)
--print,corcalib(lun,bdat2,bcal2,calinp=bcalinp,scan=210200238L)
Use the cal off for the bandpass correction. Use a 3rd order polynomial
fit
to the cal off for the bandpass correction.
--print,corcalib(lun,bdat,bcal,scan=210200238L,bpc=1,fitbpc=3)
The bandpass correction is a bit tricky and depends on what type of
observations you are doing. The integration time for the off is usually
a lot less than the on positions so you need to use either the bandpass
fit or smoothing. It would probably be a good idea to add an option for
the user to input a bandpass to use for the correction (from an off src
position).
SEE ALSO:
cormask,corbl,corlist
(See /pkg/rsi/local/libao/phil/Cor2/corcalib.pro)
Download