Tools

Interferopy comes with a toolbox of useful convenience functions that are either used in the Cube and MultiCube classes, or are meant to improve your analysis workflow.

These functions are divided in four broad categories: interferometry, data analysis, mm/radio Astronomy helper functions for FindClumps.

First, let’s import interferopy.tools as

import interferopy.tools as iftools

Interferometry

The rms of 2D image can be computed using a custom rms routine (calcrms) that excludes sources and artifacts via several rounds of sigma-clipping.

iftools.calcrms(arr=image_data_array, fitgauss=False, around_zero=True, clip_sigma=3, maxiter=20)

Another convenience function, beam_volume_sr , computes the beam volume in steradian:

iftools.beam_volume_sr(bmaj=1, bmin=1) #bmin bmaj are the FWHM in arcsec

Finally, stack2d helps with stacking radio images (in the image plane) at different RAs and Decs

stack2d(ras, decs, im, imhead, imrms=None, pathout=None, overwrite=False, naxis=100, interpol=True)

Additional specialized tasks and helper functions for data reduction in CASA are located in interferopy.casatools and for VLA data interferopy.casatools_vla_pipe. If you want to use these;

from interferopy.casatools import casareg
from interferopy.casatools_vla_pipe import build_cont_dat, flagtemplate_add, lines_rest2obs, partition_cont_range

Data analysis

A number of convenience functions are defined in to round/convert numbers:

iftools.sigfig(1.234, digits=3)  # rounds to 3 significant digits yielding 1.23
width_ghz = iftools.kms2ghz(width_kms, freq_ghz)  # channel width in km/s to GHz at the reference frequency
width_mhz = iftools.kms2mhz(width_kms,  freq_ghz) # velocity in km/s to MHz at the reference frequency
width_kms = iftools.mhz2kms(width_mhz, freq_ghz) # width in  MHz to velocity in km/s at the reference frequency
width_kms = iftools.ghz2kms(width_ghz, freq_ghz) #  width in  MHz to velocity in km/s at the reference frequency
fwhm = iftools.sig2fwhm(sigma)  # convert Gaussian sigma to FWHM
sigma = iftools.fwhm2sig(fwhm)  # and vice-versa
kpc_per_arcsec = iftools.arcsec2kpc(z)  # 1 arcsec to kiloparsecs using concordence cosmology
ra, dec = iftools.sex2deg(ra_hms, dec_dms)  # sexagesimal coordinates h:m:s and d:m:s (strings) to degrees

To help with the analysis of the data, weighted averaged and typical emission profiles are implemented:

avg, st_err, std = iftools.weighted_avg(values, weights) # returns the weighted average, standard error and deviation
y = iftools.gauss(x, amp, freq0, sigma)  # Gaussian profile
y = iftools.gausscont(x, cont, amp, freq0, sigma)  # Gaussian on top of a constant continuum profile

mm/radio Astronomy

A number of function are implemented to compute surface brightness temperature, fit a modified blackbody to the dust SED and derive luminosities and star-formation rates

iftools.surf_temp(freq, rms, theta) #surface brightness temperature sensitivity in Kelvins from frequency [GHz], rms [Jy/beam] and beam FWHM [arcsec]
iftools.dust_lum(nu_rest, Mdust, Tdust, beta) #intrinsic modified blackbody model (optically thin approx)
iftools.dust_sobs(nu_obs, z, mass_dust, temp_dust, beta, cmb_contrast=True, cmb_heating=True) #observed dust SED following the prescriptions of DaCunha+2015
iftools.dust_cont_integrate(dust_mass, dust_temp, dust_beta, print_to_console=True) # integrate a given MBB model and returns FIR/TIR luminosities and SFR rates using Kennicutt+1998,2012 conversions

Helper functions for FindClumps

line_stats_sextractor, run_line_stats_sex, crop_doubles functions are mostly run under the hood when using FindClumps on a Cube and will be described in the appropriate section (Finding line emitters with Findclumps).

Once FindClumps has been run and candidate lines emitters have been found, the fidelity function can be built and used to define a SNR threshold above which emitters are considered real (tools.fidelity_selection) and then plotted (tools.fidelity_plot). By default, tools.fidelity_plot calls tools.fidelity_selection and thus supersedes it.

bins, hist_N, hist_P, fidelity, popt, pcorr, sn_thres, hist_N_fitted = iftools.fidelity_selection(cat_negative, cat_positive, max_SN=20, i_SN=5, fidelity_threshold=0.6)
bins, hist_N, hist_P, fidelity, popt, pcorr, sn_thres, fig, [ax1, ax2] = iftools.fidelity_plot(cat_negative, cat_positive, max_SN=20, i_SN=5, fidelity_threshold=0.6, plot_name='', title_plot=None)

Reference API

interferopy.tools Module

Functions

arcsec2kpc([z])

Return the number of kiloparsecs contained in one arcsecond at given redshift.

beam_volume_sr(bmaj[, bmin])

Compute Gaussian beam volume.

blackbody(nu, temp)

Planck's law for black body emission, per unit frequency.

calcrms(arr[, fitgauss, around_zero, ...])

Calculate rms by iteratively disregarding outlier pixels (beyond clip_sigma x rms values).

crop_doubles(cat_name[, ...])

Takes a catalogue of clumps and group sources likely from the same target.

curve_fit(f, xdata, ydata[, p0, sigma, ...])

Use non-linear least squares to fit a function, f, to data.

deepcopy(x[, memo, _nil])

Deep copy operation on arbitrary Python objects.

dust_cont_integrate(dust_mass, dust_temp, ...)

Integrate over the IR spectral energy distribution.

dust_lum(nu_rest, Mdust, Tdust, beta)

Compute intrinsic dust luminosity at specific rest frame frequency assuming modified black body emission.

dust_sobs(nu_obs, z, mass_dust, temp_dust, beta)

Compute observed flux density of the dust continuum, assuming a modified black body.

fidelity_analysis(catN_name, catP_name[, ...])

Perform and plot the fidelity analysis on a positive and negative catalog

fidelity_function(sn, sigma, c)

fidelity_plot(cat_negative, cat_positive[, ...])

fidelity_selection(cat_negative, cat_positive)

Fidelity selection following Walter et al. 2016 (https://ui.adsabs.harvard.edu/abs/2016ApJ...833...67W/abstract) to select clumps which are more likely to be positive than negative.

fwhm2sig(fwhm)

Convert Gaussian FWHM to sigma.

gauss(x, a, mu, sigma)

Gaussian profile.

gausscont(x, b, a, mu, sigma)

Gaussian profile (not normalized) on top of a constant continuum.

ghz2kms(width_ghz, freq_ghz)

Convert channel width in GHz into km/s at the specified reference frequency.

kms2ghz(width_kms, freq_ghz)

Convert channel width in km/s into GHz at the specified reference frequency.

kms2mhz(width_kms, freq_ghz)

Convert channel width in km/s into MHz at the specified reference frequency.

line_stats_sextractor(catalogue, binning[, ...])

A convenience function extracting high-SNR clumps from a FINDCLUMP(s) output catalogue, adding the binning and changing the frequency to GHz, plus reordering for output catalogues

mhz2kms(width_mhz, freq_ghz)

Convert channel width in MHz into km/s at the specified reference frequency.

plot_growing_aperture_corrected(mc, tab)

run_line_stats_sex(sextractor_catalogue_name)

Merges, cleans and reformat clump catalogues (positive or negative) of different kernel widths.

sex2deg(ra_hms, dec_dms[, frame])

Convert sexagesimal coords (hours:minutes:seconds, degrees:minutes:seconds) to degrees.

sig2fwhm(sigma)

Convert Gaussian sigma to FWHM.

sigfig(x[, digits])

Round a number to a number of significant digits.

stack2d(ras, decs, im, imhead[, imrms, ...])

Perform median and mean (optionally rms weighted) stacking of multiple sources in a single radio map.

surf_temp(freq, rms, theta)

Copmute surface brightness temperature sensitivity in Kelvins.

weighted_avg(values, weights)

Compute weighted average of a masked array.

interferopy.casatools Module

Functions

casareg(outfile, ra, dec, rad)

interferopy.casatools_vla_pipe Module

Functions

build_cont_dat([vis, line_freqs, ...])

Creates a cont.dat file for the VLA pipeline.

flagtemplate_add([sdm, flagcmds, outfile])

Append additional flagging commands to the flagtemplate if they are not present already.

lines_rest2obs(line_freqs_rest, ...)

Get observed frame frequencies and widths of the lines.

partition_cont_range([line_freqs, ...])

Cuts one continuum range into smaller ones to avoid lines.