1.118. polarPair

Full Name: herschel.hifi.dp.tools.PolarPairTask
Alias: polarPair
Type: Java Task - Java Task
Import: from herschel.hifi.dp.tools import PolarPairTask



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 channel-by-channel 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 (meta-data) 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.


Example 1: # Make polarPairs of WBS and HRS SpectrumDatasets
pp_wbs = polarPair(ds1=wbs_h, ds2=wbs_v)
pp_hrs = polarPair(ds1=hrs_h, ds2=hrs_v)
Example 2: # Make polarPairs of WBS and HRS timeline products
pp_wb = polarPair(htp=wbs_h, htp2=wbs_v)
pp_hrs = polarPair(ds1=hrs_h, ds2=hrs_v)
Example 3: # Change tolerance (the values provided here are for example purpose only, not a recommendation
pp_wbs = polarPair(ds1=wbs_h, ds2=wbs_v, tolerance=150)
pp_hrs = polarPair(ds1=hrs_h, ds2=hrs_v, tolerance=90)
Example 4: # Find averages of H and V polarizations for the WBS but only subband (segment) 3
pp_wbs = polarPair(ds1=wbs_h, ds2=wbs_v)
wbs_av = avg(ds=pp_wbs, segments=[3])
# all of HRS subbands
pp_hrs = polarPair(ds1=hrs_h, ds2=hrs_v)
hrs_av = avg(ds=pp_hrs)
Example 5: # Compute the (pair-wise) difference between H and V.
pp_wbs = polarPair(ds1=wbs_h, ds2=wbs_v, difference=True)

API details


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]


See also


  • 2011-07-11 - Melchior: History and examples added.
  • 2013-07-07 - Melchior: Extended to work with SpectrumContainers or HifiTimelineProducts.