MultiCube¶
- class interferopy.cube.MultiCube(filename: Optional[str] = None, autoload_multi=True)[source]¶
Bases:
object
A container like object to hold multiple cubes at the same time. Cubes are stored in a dictionary. Allows performing tasks such as residual scaled aperture integration or spectrum extraction. Load another cube into MultiCube object by e.g. mc.load_cube(“path_to_cube.residual.fits”, “residual”)
- Example
filename="cube.fits" ra, dec, freq = (205.533741, 9.477317341, 222.54) # coord for the emission line mc=MultiCube(filename) # will automatically try to load cube.xxx.fits, where xxx is residual, dirty, pb, model, psf, or image.pbcor # Alternatively load each cube manually # mc = MultiCube() # mc.load_cube("somewhere/cube.fits", "image") # mc.load_cube("elsewhere/cube.dirty.fits", "dirty") # mc.load_cube("elsewhere/cube.residual.fits", "residual") # mc.load_cube("elsewhere/cube.pb.fits", "pb") # spectrum extracted from the circular aperture, with associated error, corrected for residual and PB response flux, err, tab = mc.spectrum_corrected(ra=ra, dec=dec, radius=1.5, calc_error=True) # tab.write("spectrum.txt", format="ascii.fixed_width", overwrite=True) # Save results for later # curve of growth up to the maximum radius, in steps of one pixel, in a chosen frequency channel radius, flux, err, tab = mc.growing_aperture_corrected(ra=ra, dec=dec, freq=freq, maxradius=5, calc_error=True) # tab.write("growth.txt", format="ascii.fixed_width", overwrite=True) # Save results for later
Attributes Summary
Array of frequencies corresponding to cube channels (from the first loaded cube).
List of keys corresponding to loaded cubes.
Methods Summary
Get a list of loaded cubes (those that are not None).
growing_aperture_corrected
([ra, dec, freq, ...])Extract the curve of growth from the map using the residual scaling to account for the dirty beam.
load_cube
(filename[, key])Add provided fits file to the MultiCube instance.
log
(text)Basic logger function to allow better functionality in the future development.
make_clean_comp
([overwrite])Generate a clean component cube.
make_flatnoise
([overwrite])Generate a flat noise cube from the primary beam (PB) corrected one, and the PB response (which is <= 1).
spectrum_corrected
([ra, dec, freq, radius, ...])Extract aperture integrated spectrum from the cube using the residual scaling to account for the dirty beam.
Attributes Documentation
- freqs¶
Array of frequencies corresponding to cube channels (from the first loaded cube).
- loaded_cubes¶
List of keys corresponding to loaded cubes.
Methods Documentation
- get_loaded_cubes()[source]¶
Get a list of loaded cubes (those that are not None).
- Returns
List of key names.
- growing_aperture_corrected(ra: Optional[float] = None, dec: Optional[float] = None, freq: Optional[float] = None, maxradius=1.0, binspacing: Optional[float] = None, bins: Optional[list] = None, px: Optional[int] = None, py: Optional[int] = None, channel: int = 0, calc_error=True, apply_pb_corr=True, plot=False)[source]¶
Extract the curve of growth from the map using the residual scaling to account for the dirty beam. Correction for the primary beam response is applied if avaliable. Coordinates can be given in degrees (ra, dec) or pixels (px, py). If no coordinates are given, the center of the map is assumed.
For details on the method see appendix A in Novak et al. (2019): https://ui.adsabs.harvard.edu/abs/2019ApJ…881…63N/abstract
- Parameters
ra – Right ascention in degrees.
dec – Declination in degrees.
freq – Frequency in GHz.
maxradius – Max radius for aperture integration in arcsec.
binspacing – Resolution of the growth flux curve in arcsec, default is one pixel size.
bins – Custom bins for curve growth (1D np array).
px – Right ascention pixel coord (alternative to ra).
py – Declination pixel coord (alternative to dec).
channel – Index of the cube channel to take (alternative to freq). Default is the first channel.
calc_error – Set to False to skip error calculations, if the rms computation is slow or not necessary.
apply_pb_corr – Scale flux and error by the primary beam response (single pix value), needs loaded pb map.
- Returns
radius, flux, err, tab: 1D array for radius[arcsec] and corrected flux and error estimate; tab is a Table with all computations.
- load_cube(filename: str, key: Optional[str] = None)[source]¶
Add provided fits file to the MultiCube instance. Known keys are: “image”, “residual”, “dirty”, “pb”, “model”, “psf”, “image.pbcor” If the filename does not end with these words, please provide a manual key.
- Parameters
filename – Path string to the fits image.
key – Dictionary key name used to store the cube.
- Returns
- log(text: str)[source]¶
Basic logger function to allow better functionality in the future development. All class functions print info through this wrapper. Could be extended to provide different levels of info, timestamps, or logging to a file.
- make_clean_comp(overwrite=False)[source]¶
Generate a clean component cube. Defined as the cleaned cube minus the residual, or, alternatively, model image convolved with the clean beam. This cube is not outputted by CASA.
- Parameters
overwrite – If true, overrides any present “clean.comp” cube.
- Returns
None
- make_flatnoise(overwrite=False)[source]¶
Generate a flat noise cube from the primary beam (PB) corrected one, and the PB response (which is <= 1). PB corrected cube has valid fluxes, but rms computation is not straightforward. PB corrected cube = flat noise cube / PB response
- Parameters
overwrite – If true, overrides any present “image”” cube.
- Returns
None
- spectrum_corrected(ra: Optional[float] = None, dec: Optional[float] = None, freq: Optional[float] = None, radius: float = 1.0, px: Optional[int] = None, py: Optional[int] = None, channel: Optional[int] = None, calc_error=True, sn_cut: float = 2.5, apply_pb_corr=True)[source]¶
Extract aperture integrated spectrum from the cube using the residual scaling to account for the dirty beam. Correction for the primary beam response is applied if avaliable. Coordinates can be given in degrees (ra, dec) or pixels (px, py). If no coordinates are given, the center of the map is assumed.
For details on the method see appendix A in Novak et al. (2019): https://ui.adsabs.harvard.edu/abs/2019ApJ…881…63N/abstract
- Parameters
ra – Right ascention in degrees.
dec – Declination in degrees.
radius – Circular aperture radius in arcsec.
px – Right ascention pixel coord (alternative to ra).
py – Declination pixel coord (alternative to dec).
channel – Channel index (alternative to freq)
freq – Frequency in GHz. Extract only in a single channel instead of the full cube.
calc_error – Set to False to skip error calculations, if the rms computation is slow or not necessary.
sn_cut – Use emission above this S/N threshold to estimate the clean-to-dirty beam ratio, need calc_error.
apply_pb_corr – Scale flux and error by the primary beam response (single pix value), needs loaded pb map.
- Returns
flux, err, tab: 1D array for corrected flux and error estimate; tab is a Table with all computations.