herschel.hifi.dp.tools.PolarPairTask 
polarPair 
Java Task 

from herschel.hifi.dp.tools import PolarPairTask 
HIFI/Analysis

Description
Task to compute the average or the difference of two spectrum containers or timeline products which is useful
for averaging H and V. The algorithm works on a point spectrum by point spectrum basis. It convolves one spectrum on the other,
insuring a perfect channelbychannel association. The average takes also into account channel weights. Various checks are
applied to reduce the processing on a per poiont spectrum basis. In particular, it means that pairs of datasets are identified
in a timeline product to have consistent LoFrequency or pointing positions. In case of passing two spectrum containers these
are checked to contain the same number of point spectra. In case of passing two SpectralSimpleCubes additional checks are
applied such that consistent raster map positions are combined. The task does nod operate symmetrically in the two point spectra:
the second point spectrum (V) is convolved over the first point spectrum (H), so that a new version of the second with exactly
the same wave scale as the first is created (denoted by V*). Thereafter, the average (or the difference) is taken between
H and V*. Given a middle frequency nu_0 of a channel i in H, the corresponding channel in V* is given by: V*[i] = Sum[j=0..N] V[j]*exp((nu[j]nu_0[i])^2/(2*sigma[i]^2))) / Sum[j=0..N] exp((nu[j]nu_0[i])^2/(2*sigma[i]^2)))
where N
is the number of channels in V and sigma
is set so that the standard deviation of the Gaussian corresponds to the channel width in H. Computing V over H takes N*N
operations, which can take a long time. As only channels near nu_0
are significantly contributing to the V* channel value, this sum can be reduced to a limited number of channels around nu_0
. This is the aim of setTolerance(int number_of_channels)
method. If H and V are shifted in frequency a minimal tolerance is required for a correct convolution, which is equal to
the number of channels corresponding to the shift. However, if the tolerance is too small, the final averaged dataset may
contain NaNs only. To avoid this, giving 2 times the corresponding shift in channel numbers is perfect. A tolerance of 20
channels has been found to be sufficient in most cases, but 100 is even safer (which is currently set as default). The resulting
variables of these operations are SpectrumDatasets that can be plotted and compared with other datasets. It should be noted
that resulting SpectrumDatasets contain only changed fluxes, header information (metadata) are not adapted at the moment,
as this class is still under development. This remark is particularly relevant for the integration time given in the averaged
spectrum.
Examples
Example 1: # Make polarPairs of WBS and HRS SpectrumDatasets 


Example 2: # Make polarPairs of WBS and HRS timeline products 


Example 3: # Change tolerance (the values provided here are for example purpose only, not a recommendation 


Example 4: # Find averages of H and V polarizations for the WBS but only subband (segment) 3 


Example 5: # Compute the (pairwise) difference between H and V. 


Properties 
SpectrumContainer ds1
[INPUT, OPTIONAL, default=no default value] 
SpectrumContainer ds2
[INPUT, OPTIONAL, default=no default value] 
HifiTimelineProduct htp
[INPUT, OPTIONAL, default=no default value] 
HifiTimelineProduct htp1
[INPUT, OPTIONAL, default=no default value] 
Boolean difference
[INPUT, OPTIONAL, default=False] 