Computing Tsys from the telescope archive data.

07mar05

The system temperature is computed from the calon (tsys + Tcal) and the caloff (Tsys) scans. The
processing is normally:

caloff
TsysK= ------------ * calK
(calOn - calOff)

This is the same as:
let calRatio=calOn/caloff

1.                                (1.)
TsysK= ---------- * calK
calratio - 1

Rfi in the cal on or cal off can cause problems in the computation.
It is best to ignore frequency bins that contain rfi. Fitting the
band pass and removing outliers is hard because of the iflo bandpass
shape. The ratio calon/caloff does not have this problem.
Using the following definitions:
Tsky - sky temp, Gsky frquency dependence of sky temp
Tcal - cal temp, Gcal frequency dependence of the cal
Tiflo - power from the omt,amps. iflo, Giflo frequency dependence
The the cal ratio can be written as:

(Tsky*Gsky + Tcal*Gcal + Tiflo )*Giflo
calRatio=   ---------------------------
(Tsky*Gsky + Tiflo )*Giflo

So Giflo cancels. If you assume that Tsky,Gsky is the same for the on/off
then you get:
(Tcal*Gcal)
calRatio - 1 = --------------
(Tsky*Gsky + Tiflo )

Since Gcal,Gsky is a slowly varying function of frequency (we're ignoring standing waves since they have little power in them) you can
do a low order fit and throw out any outliers (nsig above the fit residuals).

The procedure is then:

1. Find all of the calOn scans in the data archive. Ignore :
1. files with project ID  of unknown, a9999, x108, elec since these are usually testing.
2. Any polarization scans (since these are stored as acfs and i'm lazy..)
2. Find an off scan that goes with this cal on. The offs can be:
1. If this is an calon/off procedure use the off scan
2. Look for records before and after this scan that are within 4.5 seconds from the start of the calOn and have the cal off. If one record is found, use it. If two records are found then use the average.
3. Compute the calratio CalOn/Caloff (remember that Caloff is Tsys).
4. Use corblauto to iteratively fit a linear plus 3rd order harmonic to the ratio throwing out all points above 3 sigma. Keep iterating till no points are removed.
5. Store the following for info in the tsys archive each fit:
1. The scan number that identifies the calon and cal off records. You can use this to get the full scan info later.
2. The fit coefficients
3. The fraction of channels used for the fit.
4. The rms of the fit. Since it is Tsys+tcal/tsys the units are tsys.
5. The min/max channel numbers used in the fit (normally the edges are removed by the fitting process).
6. The the alfa cal values in 1 Mhz steps from 1220 to 1520 Mhz.
7. Take 100 points across the inner 80% of each scan. Evaluate the fit at these points . Also compute the Cal value at these 100 points. Compute Tsys for these 100 points using (1) and then average to get Tsys.
8. Throw out any points where:
1. Tsys< 20K or Tsys > 100K
2. The 0 lag was < .5 or gt 3. These numbers are the ratio of measured to optimum power for the correlation function. If the input power levels were very low (wrong settings) or high (maybe a continuum source) then ignore the points.
The routines used to do this are:
• tsysfindcals():  find the cal ons and cal offs in the archive
• tsysfit(): do the fits
• tsysfiteval() : evaluate the fit.
• tsyscmpK() : Compute tsys from the fits and the cal values
• tsys_gettbl(): get fit data from the tsys archive for a range of months.
This processing also lets you look at the bandpass shape of calOn/calOff. The fit residuals are typically within 2 sigma of the radiometer equation. Low frequency ripples in the cal are easily seen.