### CALCQU

Calculate Q and U images from a set of time-series data files

#### Description:

This application creates Q and U values from a set of POL-2 time series data files. It has two modes of operation, selected by the LSQFIT parameter. The supplied time series data files are first flat-fielded, cleaned and concatenated, before being used to create the Q and U values.

If LSQFIT is set TRUE, then the output NDFs associated with parameters OUTQ, OUTU and OUTI hold time series data in which the data values represent Q, U and I respectively, rather than raw bolometer values. These time-series are much shorter in length than the supplied input time-series files. Each input time series is split into blocks of adjacent time slices, and a single Q, U and I value is created for each bolometer for each such block. The size of these blocks is specified by the POLBOX configuration parameter, which is an integer giving the size of each block as a multiple of the time taken for a complete revolution of the half-waveplate. Each (Q,U,I) triplet is found by doing a least squares fit to the supplied input data (i.e. the analysed intensity data) within a single block of time slices. The fitted function includes first, second, fourth and eight harmonics of the half-waveplate, together with a linear background: (" w" is the angle of the half-waveplate, and " itime" is the zero-based offset of the time slice into the box):

y = A$\ast$sin(4$\ast$w) $+$ B$\ast$cos(4$\ast$w) $+$ C$\ast$sin(2$\ast$w) $+$ D$\ast$cos(2$\ast$w) $+$ E$\ast$sin(w) $+$ F$\ast$cos(w) $+$ G$\ast$itime $+$ H $+$ J$\ast$sin(8$\ast$w) $+$ K$\ast$cos(8$\ast$w)

The returned Q, U and I values are then:

U = 2$\ast$A Q = 2$\ast$B I = 2$\ast$( G$\ast$box/2 $+$ H )

The Q and U values are specified with respect to either north or the focal plane Y axis (see parameter NORTH). Each single pair of corresponding Q and U values in the output NDFs are created from a single least-squares fit, and the residuals of each such fit are used to calculate a notional variance for the corresponding pair of Q and U values. These are not " real" variances, but are just a scaled form of the residuals variance using a scalaing factor that gives reasonable agreement to the visible noise in the Q and U values measured in ten test observations. These variances are intended for determining relative weights for the Q and U values, and should not be used as absolute variance values.

If LSQFIT is set FALSE, then the output NDFs associated with parameters OUTQ, OUTU and OUTI are each 2D and contain a single Q, U or I value for each bolometer. Multiple 2D images are created, as the telescope slowly moves across the sky. Each image is created from a block of time slices over which the sky position of each bolometer does not change significantly (see parameters ARCERROR, MAXSIZE and MINSIZE). The resulting set of Q images can be combined subsequently using KAPPA:WCSMOSAIC, to form a single Q image (normally, the " I" image should be used as the reference image when running WCSMOSIAC). Likewise, the set of U images can be combined in the same way. All the created Q and U images use the focal plane Y axis as the reference direction (positive polarisation angles are in the same sense as rotation from the focal plane X axis to the focal plane Y axis). Since this direction may vary from block to block due to sky rotation, the idividual Q and U images should be processed using POLPACK:POLROTREF before combining them using KAPPA:WCSMOSAIC, to ensure that they all use the same reference direction. Q and U values are determined from the Fourier component of each time series corresponding to the frequency of the spinning half-waveplate (6 - 12 Hz), and should be largely unaffected by signal at other frequencies. For this reason, the cleaning specified by parameter CONFIG should usually not include any filtering that affects frequencies in the range 2 -16 Hz. There is an option (see configuration parameter SUBMEAN) to subtract the mean value from each time slice before using them to calculate Q and U.

Separate Q, U and I esimates are made for each half revolution of the half-wave plate. The Data values in the returned NDFs are the mean of these estimates. If there are four or more estimates per bolometer, the output will also contain Variance values for each bolometer (these variances represent the error on the final mean value, not the variance of the individual values). A warning message will be displayed if variances cannot be created due to insufficient input data.

The current WCS Frame within the generated I, Q and U images will be SKY (e.g. Right Ascension/Declination).

#### Parameters:

Specifies values for various configuration parameters. If the string " def" (case-insensitive) or a null (!) value is supplied, a set of default configuration parameter values will be used.
The supplied value should be either a comma-separated list of strings or the name of a text file preceded by an up-arrow character "^" , containing one or more comma-separated lists of strings. Each string is either a " keyword=value" setting, or the name of a text file preceded by an up-arrow character " ^" . Such text files should contain further comma-separated lists which will be read and interpreted in the same manner (any blank lines or lines beginning with " #" are ignored). Within a text file, newlines can be used as delimiters, as well as commas. Settings are applied in the order in which they occur within the list, with later settings over-riding any earlier settings given for the same keyword.
$<$keyword$>$=$<$value$>$