Skip to content

astrosica/python-functions

Repository files navigation

Python functions

Python functions for PhD work.

Polarization

  • compute the polarized intensity and its uncertainty
  • compute the polarization angle and its uncertainty
  • compute the polarization fraction and its uncertainty
  • compute the de-biased polarized intensity
  • compute the polarization gradient (with and without cross-terms)
  • compute the normalized polarization gradient (with and without cross-terms)
  • compute the argument of polarization gradient (with and without cross-terms)
  • apply a mask to the argument of polarization gradient
  • compute the radial and tangential components of the polarization gradient
  • compute the angular version of the polarization gradient
  • compute the plane-of-sky magnetic field orientation
  • compute an estimate of the polarization angle dispersion function
  • compute the de-rotated magnetic field orientation
  • create a dictionary of polarization gradient arguments for each pixel
  • plot an image with pseudovectors overlaid
  • compute the rotation measure structure function (RMSF) and related parameters
  • compute the first moment of a one-dimensional Faraday dispersion function
  • compute the second moment of a one-dimensional Faraday dispersion function
  • compute the first moment map of a three-dimensional Faraday dispersion function
  • compute the second moment map of a three-dimensional Faraday dispersion function

FITS files

  • construct the frequency axis of a 3D FITS file
  • compute the average across a data cube's third axis
  • compute the summation of a list of 2D FITS files
  • create a grid of equatorial coordinates for a FITS file
  • create a grid of Galactic coordinates for a FITS file
  • transform a coordinate grid from equatorial to Galactic coordinates
  • transform a coordinate grid from Galactic to equatorial coordinates
  • reproject one 2D FITS image to another
  • reproject one 3D FITS image to another
  • reproject a 2D FITS image from equatorial to Galactic coordinates
  • reproject a 3D FITS image from equatorial to Galactic coordinates
  • reproject a 2D FITS image from Galactic to equatorial coordinates
  • reproject a 3D FITS image from Galactic to equatorial coordinates
  • reproject a HEALPix image to a standard FITS projection
  • creates a mask using a condition on Galactic latitude
  • masks a 2D FITS image in equatorial coordinates based on Galactic latitude
  • transform a 3D FITS header to a 2D FITS header
  • slice a 3D FITS data cube along its third axis and save each 2D image as a separate FITS image

Sky Coordinates

  • transform Right Ascension and Declination coordinates from decimal degrees to the sexagismal system
  • transform Right Ascension and Declination coordinates from the sexagismal system to decimal degrees
  • precess Right Ascension and Declination coordinates from the sexagismal system in the B1959 equinox to decimal degrees in the J2000 equinox
  • match two sets of catalogue positions in equatorial coordinates
  • write a set of cooridinates to an annotation file for kvis
  • write a set of cooridinates to a region file for ds9

Photometry

  • convert photometric magnitude uncertainty to signal-to-noise ratio
  • convert photometric signal-to-noise ratio to magnitude uncertainty
  • convert AB magnitudes to the Vega magnitude scale
  • compute photometric colour and its uncertainty
  • compute J-, H-, and K-band extinctions using the RJCE technique
  • compute J-, H-, and K-band intrinsic magnitudes using the RJCE technique
  • compute J-, H-, and K-band distance-corrected luminosities using Gaia parallaxes
  • compute distance using Gaia parallax

Rolling Hough Transform

See the Rolling Hough Transform.

  • execute the RHT on all FITS files within a given directory
  • add contents of a FITS image header to an RHT FITS file
  • collect all RHT angles for each spatial pixel in the image plane
  • compute the distribution in RHT angle differences between two images
  • compute the RHT backprojection allowing one to mask specific angles

Planck

  • converts Planck Stokes maps from K_CMB to MJy/sr
  • converts Planck Stokes maps from uK to MJy/sr
  • remove the CMB monopole from the Planck 353 GHz Stokes maps
  • add the Galactic HI offset correction to the Planck 353 GHz Stokes I map

Line Integral Convolution (LIC)

  • compute magnetic field orientation in IAU convention
  • compute LIC texture
  • overplot LIC texture on an image

Colormaps

  • twilight colormap
  • Planck frequency colormap
  • Planck parchment colormap

Miscellaneous

  • convert frequency to wavelength
  • convert wavelength to frequency
  • compute upper limit kinetic temperature from line broadening
  • mask a 2D FITS image in signal
  • mask a 2D FITS image in signal-to-noise
  • compute the 1D and 2D fast Fourier transform (FFT)
  • compute the 1D and 2D inverse fast Fourier transform (IFFT)
  • compute the 2D spatial gradient of an image
  • map angles defined on the polar plane [0,2pi) to the half polar plane [0,pi)
  • compute the angular difference between two angles defined on the half-polar plane
  • convolve a 2D FITS image using FFT convolution
  • reads in a ROHSA data file
  • mask and interpolate over point sources
  • applies a mask to a 2D FITS image and interpolates
  • mask an image within the boundary of a circle
  • mask an image within the boundary of an ellipse
  • mask an image betweeen two lines
  • masks basketweaving artefacts of the GALFACTS sensitivity map FFT