How to fit the noise model to TOD

The noise model fitting is done in two stages. 1. Estimate the noise properties of each chunk of TOD 2. Average these together for each fits file.

We then want to overwrite the noise properties in the TOD fits files that are set by split_data.

Estimate the noise properties of each chunk of TOD

The noise model fitting code is contained in cbasspy.noise_fit_12. Simply call the fucntion or put it in a script and add it to the Glamdring queue on multiple cores. For example, create a python script along the lines of:

#!/usr/bin/env python
from cbasspy.noise_fit_12 import noise_fit_12

noise_fit_12('v28allels_NIGHTMERID20_nf12_2.db3',
         '/stegodon/Reductions/v28_allels/v28_allels_todWithNoiseStats/v28allels_withNoiseStats_goodground_goodels_fullpath.txt',
         '/elephant/cbassvisitor3/v28allels_jk/maps/NIGHTMERID20_v28allels_allGood_masked5pc_G_0256_ol500_g_map.fits',
         niter=int(5e3), nburn=int(2e3), thinFactor=int(1), ntune=int(5e2),
         cutName='NIGHTMERID20'
         )

See the documentation of the function cbasspy.noise_fit_12.noise_fit_12() for details on the inputs. Then simply add this script to the glamdring queue on multiple cores.

Average these together for each fitsfile

Because some of the chunks are very short, the uncertainty on the noise properties can be quite large. Some chunks are so short that the noise properties can not be estimated at all. As such we average the noise properties we have estimated for each chunk in a TOD fits file into one set of values for the whole file. The noise properties for each chunk must be averaged to provide one set of noise statistics for each TOD fits file.

This can be done using cbasspy.overwriteFitsNoiseStats.wavg_12_calc(). Again, see the documentation of this function for more details. It is relatively quick to run (so doesn’t need multiple cores simply calling it from a python terminal will do. It takes two inputs, the name of the sql database you created in the previous section and the name of the sql database you would like to save the results to.

Overwriting the noise properties in TOD fits files

After we have estimated the noise properties for each fits file we need to save them to the fits files. It is safest to copy the TOD and overwrite the copy - that way if you want the noise properties output by split_data, they still exist somewhere. This is done using cbasspy.overwriteFitsNoiseStats.overwriteFitsNoiseStats_fromSql(). See the functions documentation for details.