Next Previous Contents

5. Subroutines needed

The following is based on HP code, but there is some guesswork here as I don't really know just how SYPARM will work, what calls to it are like, or what commands can be sent to STEER and what data can be obtained from STEER.

5.1 System Temperature Calibration subroutine


// standard calibration routine for absolute total power mode:

// usually just two polarizations, but
// note that with a polarimeter there could be four counters to read

inputs: counter_to_read[Ncounters]
        noise diode to fire
        local oscillator for receiver
        ND_in_Kelvins_for_this_output[Ncounters]
        Nsamples 
outputs: Tsys[Ncounters]
        Tsys_err[Ncounters]
        CperK[Ncounters]
        CperK_err[Ncounters]
        NDerror[Ncounters]
        LOerror[Ncounters]
        output[Ncounters][Nsets]Nsamples]       

// three sets samples are taken
Nsets = 3

// initialise the outputs
for (ic = 0 ; ic < Ncounters ; ic++ ) do
        {
        COerror[ic] = 0 /* counter problem */
        NDerror[ic] = 0 /* noise diode problem */
        LOerror[ic] = 0 /* local oscillator problem */
        CperK[ic] = 0   /* counts per Kelvin per counter */
        CperK_err[ic] = 0 /* uncertainty in CperK per counter */
        Tsys[ic] = 0    /* System temperature per counter */
        Tsys_err[ic] = 0  /* uncertainty in Tsys per counter */
        for ( is = 0 ; is < Nsets ; is++ ) do
                {
                for ( i = 0 ; i < Nsamples ; i++ ) do
                        { output[ic][is][i] = 0 }
                }
        }

// obtain three sets of data
for ( is = 0 ; is < Nsets ; is++ ) do 
        {
        if ( is = 0 ) then { turn off local oscillator,
                            turn off noise diode }
        if ( is = 1 ) then { turn on local oscillator,
                            turn on noise diode }
        if ( is = 2 ) then { turn off noise diode }

        pause to let output settle

        ask all counters in use for Nsamples of output

        check for errors reading counters
        
        // get mean and rms for all good counters (ic) and each sample (i)
        for ( ic = 0 ; ic <= Ncounters ; ic++ ) do
                {
                sum[ic] = 0
                sum_sqd[ic] = 0
                for ( i = 0 ; i <= Nsamples ; i++ ) do 
                        {
                        sum[ic] = sum[ic] + output[ic][is][i]
                        sum_sqd[ic] = sum_sqd[ic] + output[ic][is][i]**2
                        }
                mean[ic][i] = sum[ic] / Nsamples
                rms[ic][i] = sqrt ((sum_sqd[ic] - sum[ic]**2/Nsamples) 
                          / (Nsamples - 1)
                }
        }

// now we have all the data, lets see what we can calculate from it
// for each good counter:
for ( ic = 0 ; ic <= Ncounters ; ic++ ) do
        {
        // check that the noise diode fired (ND > 6 x RMS noise):
        if ((mean[ic][2] - mean[ic][3]) < 3*(rms[ic][2]+rms[ic][3])) then 
                { NDerror[ic] = 1 }

        // check that the local oscillator switched off:
        if ((mean[ic][3] - mean[ic][1] < 3*(rms[ic][3]+rms[ic][1])) then 
                { LOerror[ic] = 1 }

        // calculate the counts per Kelvin and error:
        if ( NDerror[ic] = 0 ) then 
                {
                CperK[ic] = (mean[ic][3] - mean[ic][2]) / ND_in_Kelvins[ic]

                CperK_err[ic] = sqrt (rms[ic][3]**2 + rms[ic][2]**2) 
                                / ND_in_Kelvins[ic]
                }

        // calculate the system temperature and error:
        if ( NDerror[ic] = 0 && LOerror[ic] = 0) then 
                {
                Tsys[ic] = (mean[ic][3] - mean[ic][1]) 
                           / (mean[ic][2] - mean[ic][3]) 
                           * ND_in_Kelvins[ic]

                Tsys_err[ic] = Tsys[ic] * sqrt ((
                                 (rms[ic][3]**2 + rms[ic][1]**2) / 
                                 (mean[ic][3] - mean[ic][1])**2) +
                                ((rms[ic][2]**2 + rms[ic][3]**2) /
                                 (mean[ic][2] - mean[ic][3]**2))
                }
        }


Next Previous Contents