operations_lib

class lsmtool.operations_lib.NormalizedRADec(ra, dec)

Bases: tuple

dec

Alias for field number 1

ra

Alias for field number 0

lsmtool.operations_lib.apply_beam(beamMS, fluxes, RADeg, DecDeg, timeIndx=0.5, invert=False)

Returns flux attenuated by primary beam.

Note: the attenuation is approximated using the array factor beam from the first station in the beam MS only (and it is assumed that this station is at LOFAR core). This approximation has been found to produce reasonable results for a typical LOFAR observation but may not work well for atypical observations.

Parameters:
  • beamMS (str) – Measurement set for which the beam model is made

  • fluxes (list) – List of fluxes to attenuate

  • RADeg (list) – List of RA values in degrees

  • DecDeg (list) – List of Dec values in degrees

  • timeIndx (float (between 0 and 1), optional) – Time as fraction of that covered by the beamMS for which the beam is calculated

  • invert (bool, optional) – If True, invert the beam (i.e. to un-attenuate the flux)

Returns:

attFluxes (numpy.ndarray) – Attenuated fluxes

lsmtool.operations_lib.calculateSeparation(ra1, dec1, ra2, dec2)

Returns angular separation between two coordinates (all in degrees).

Parameters:
Returns:

separation (astropy.coordinates.Angle or numpy.ndarray) – Angular separation in degrees

lsmtool.operations_lib.gaussian_fcn(g, x1, x2, const=False)

Evaluate a Gaussian on the given grid.

Parameters:
  • g (list) – List of Gaussian parameters: [peak_flux, xcen, ycen, FWHMmaj, FWHMmin, PA_E_of_N]

  • x1 (numpy.ndarray) – Grid coordinates on which to evaluate the Gaussian (as produced by numpy.mgrid)

  • x2 (numpy.ndarray) – Grid coordinates on which to evaluate the Gaussian (as produced by numpy.mgrid)

  • const (bool, optional) – If True, all values are set to the peak_flux

Returns:

img (numpy.ndarray) – Image of Gaussian

lsmtool.operations_lib.getFluxAtSingleFrequency(LSM, targetFreq=None, aggregate=None)

Returns flux density at given target frequency, adjusted according to the spectral index.

Parameters:
  • LSM (lsmtool.skymodel.SkyModel) – RA of coordinate 1 in degrees

  • targetFreq (float, optional) – Frequency in Hz. If None, the median is used

  • aggregate (str, optional) – Aggregation to use

Returns:

fluxes (numpy.ndarray) – Flux densities in Jy

lsmtool.operations_lib.make_template_image(
image_name,
reference_ra_deg,
reference_dec_deg,
reference_freq,
ximsize=512,
yimsize=512,
cellsize_deg=0.000417,
fill_val=0,
)

Make a blank image and save it to disk

Parameters:
  • image_name (str) – Filename of output image

  • reference_ra_deg (float) – RA for center of output image

  • reference_dec_deg (float) – Dec for center of output image

  • reference_freq (float) – Ref freq of output image

  • ximsize (int, optional) – Size of output image

  • yimsize (int, optional) – Size of output image

  • cellsize_deg (float, optional) – Size of a pixel in degrees

  • fill_val (int, optional) – Value with which to fill the image

lsmtool.operations_lib.make_wcs(refRA, refDec, crdelt=None)

Makes simple WCS object.

Parameters:
  • refRA (float) – Reference RA in degrees

  • refDec (float) – Reference Dec in degrees

  • crdelt (float, optional) – Delta in degrees for sky grid

Returns:

w (astropy.wcs.WCS) – A simple TAN-projection WCS object for specified reference position

lsmtool.operations_lib.matchSky(LSM1, LSM2, radius=0.1, byPatch=False, nearestOnly=False)

Matches two sky models by position.

Parameters:
  • LSM1 (lsmtool.skymodel.SkyModel) – Sky model for which match indices are desired

  • LSM2 (lsmtool.skymodel.SkyModel) – Sky model to match against

  • radius (float or str, optional) – Radius in degrees (if float) or ‘value unit’ (if str; e.g., ‘30 arcsec’) for matching when matchBy=’position’

  • byPatch (bool, optional) – If True, matching is done by patches

  • nearestOnly (bool, optional) – If True, only the nearest of multiple matches is returned

Returns:

matches1, matches2 (numpy.ndarray) – matches1 is the array of indices of LSM1 that have matches in LSM2 within the specified radius. matches2 is the array of indices of LSM2 for the same sources.

lsmtool.operations_lib.normalize_ra_dec(ra, dec)

Normalize RA to be in the range [0, 360) and Dec to be in the range [-90, 90].

Parameters:
Returns:

normalized_ra_dec (NormalizedRADec) – The normalized RA in degrees in the range [0, 360) and the Dec in degrees in the range [-90, 90], with the following elements:

  • NormalizedRADec.ra: RA in degrees

  • NormalizedRADec.dec: Dec in degrees

lsmtool.operations_lib.radec_to_xyz(ra, dec, time)

Convert RA and Dec ICRS coordinates to ITRS cartesian coordinates.

Parameters:
Returns:

pointing_xyz (numpy.ndarray) – NumPy array containing the ITRS X, Y and Z coordinates