The 1D PB philosophy is to specify the Voltage pattern or Primary Beam via a small number of parameters via one of the derived types (PBMath1DGauss, for example). The derived type knows how to instantiate itself from a row in a beam subTable, and how to convert itself into a lookup vector. The lookup vector is fine enough that no interpolation need be done when finding the nearest PB or VP value for a particular pixel (currently, there are 1e+4 elements in the lookup vector, so on average, an error on order of 1e-4 is made when applying the primary beam).
There are two ways of creating the derived PB types: 1) explicitly create one of the babies. You have control over the details such as PB size and total extent, the reference frequency at which this size is true (the size scales inversely with wavelength), the squint orientation, and whether a mean symmetrized beam will be calculated from the squinted beam. (Nice defaults can reduce the arguments in most cases.)
PBMath1DGauss myPB (Quantity(1.0, "'"), Quantity(3.0, "'"), Quantity(1.0, "GHz"), False, // these are PB parameters, not VP BeamSquint(MDirection(Quantity(2.0, "\""), Quantity(0.0, "\""), MDirection::Ref(MDirection::AZEL)), Quantity(2.0, "GHz")), False); PBMath1DGauss myPB2 (Quantity(1.0, "'"), Quantity(3.0, "'"), Quantity(1.0, "GHz"));2) via the envelope class PBMath's enumerated CommonPB type. This is much simpler, and will deal with a majority of the cases required:
PBMath wsrtPB(PBMath::WSRT); PBMath vla_LPB(PBMath::VLA_L); // has L band squint built in
The main thing you want to do with a primary beam or voltage pattern is to apply it to an image. The top level "apply" methods are defined in PBMathInterface. They are applyPB, applyPB2, applyVP. These top level apply's then call a lower level private polymorphic apply, which are defined in PBMath1D and in PBMath2D. These two different apply's deal with the different details of 1D and 2D primary beam application.
PagedImage<Float> in; PagedImage<Complex> out; MDirection pointingDir(Quantity(135.0, "deg"), Quantity(60.0, "deg"), MDirection::Ref(MDirection::J2000)); Quantity parallacticAngle(26.5, "deg"); PBMath wsrtPB(PBMath::WSRT_LOW); wsrtPB.applyPB(in, out, pointingDir); // multiply by primary beam wsrtPB.applyPB(in, out, pointingDir, parallacticAngle, BeamSquint::GOFIGURE, True, 0.02); // divide by primary beam wsrtPB.applyVP(in, out, pointingDir); // multiply by voltage pattern
lower level helping apply methods: reduce code by this bundling
Get the PB in a vector to look at Concerning n_elements: they are evenly spaced between 0 and maxradius. r is in units of arcminutes at 1 GHz
Summarize the Voltage Pattern; For PBMath1D, list nValues worth of the VP array
Is state of PBMath OK?
Get the ImageRegion of the primary beam on an Image for a given pointing Note: ImageRegion is not necesarily constrained to lie within the image region (for example, if the pointing center is near the edge of the image). fPad: extra fractional padding, beyond Primary Beam support (note: we do not properly treat squint yet, this will cover it for now) iChan: frequency channel to take: lowest frequency channel is safe for all
Potential problem: this ImageRegion includes all Stokes and Frequency Channels present in the input image.
calculate the limited box of the Primary Beam model's support, return in blc and trc (which are NOT contrained to be inside the image
push blc lower, trc higher such that they define an image which is a power of 2 in size.
Adjust blc and trc such that they are within the image and such that they create an image with power of 2 (SkyJones::POWEROF2) shape or composite number (SkyJones::COMPOSITE) shape
Fill in PB_p array from construction parameters, rescale construction parameters to the 1 GHz internal reference frequency Eventually: create it as its needed; we've got 4 arrays to fill; only create and store as they are required Right now: just construct all arrays
Helper method to fit a circularly symmetric beam to the squinted RR + LL beam. Called upon construction. Build this later. PB' = azimuthal fit to: ( VP(x+s)**2 + VP(x-s)**2 )/2 VP' = sqrt(PB')