Utilities for manipulating line cubes

Some utility functions for manipulating ProDiMo observables with CASA.

This requires the modular Python CASA packages to be installed. See CASA Modular packages.

As the CASA packages might require a particular Python version, we recommend to use a separate environment. The following steps should work to enable the use of the casasim utilities:

  • create a Python environment (e.g. with conda) with a compatible Python version for CASA e.g.

    conda create -n CASA python=3.12 ipykernel
    conda activate CASA
    
  • use pip to install the casatasks package in that environment.

    pip install casatasks
    
  • install prodimopy in the same environment.

    pip install prodimopy
    
  • you might need to create a directory ~/.casa/data in your home directory for CASA to work properly. You will get an error message if the directory is missing when you try to use the casasim utilities. For details see CASA External Data.

  • try it: by simply doing the following in a python script or jupyter notebook:

    import casatasks as ctasks
    import prodimopy.utils_casasim as ucsim
    import prodimopy.plot_casasim as pcsim
    import prodimopy.read_casasim as rcsim
    
    help(ctasks)
    

If that works without errors, you are ready to use the utils_casasim module in prodimopy!

prodimopy.utils_casasim.radprof(infile, incl, PA, fracbeam=0.33, rms=None, r_out=None)[source]

Make an azimuthally averaged deprojected radial profile of an 2D fits image.

Used casatasks to make the radial profiles.

The radial gridding is determined by the beam size. By default 1/3 of the beam size are used to define the width of one annulus.

The information of the center of the image, beam sizes etc. are read from the fits header. So they have to be there. Ususullay that routine works fine with images that can be opened within casa.

incl and PA have to be in degree.

Parameters:
  • infile (str) – The path/filename of the fits file to use.

  • incl (float) – The inclination in degrees

  • PA (float) – The position angle in degrees

  • fracbeam (float) – What fraction of the beam should be used for the radial spacing. Can also be >1. DEFAULT: 0.33

  • rms (float) – rms value of the image. Is used to determine the error. DEFAULT: None (no error estimate)

  • r_out (float) – the maximum outer radius use for the radial profile in arcsec. Default: None (whole image is used)

Returns:

r,flux,fluxerr – Three arrays with the radius (in arcsec) the flux at each radius (units of the Image) and the error for the flux.

Return type:

array_like(ndim=1)

prodimopy.utils_casasim.write_radprof(outfile, r, flux, fluxerr)[source]

Writes a radial profile to a file in the format used by casairing. This is only for compatibility for older projects.

class prodimopy.utils_casasim.ContinuumPP(proj, modelfits, chans=None, band=None, incl=None, PA=None, refimage=None, singleimage=False, removeBackground=False)[source]

Bases: _PostProcess

Object to post-process ProDiMo continuum images for CASA.

Atrributes

proj

string: A project name which will be used to store the casa files in a directoy with name proj. Also all files will start with the prefix proj.

modelfits

string: The path/filename for the continuum images output of ProDiMo. Usually this file is called image.fits.

chans

string: A string with the desired channel number for the image. E.g. “0” selctes the first one. “50,51,51” will produce an average of this three channels.

band

array_like(ndim=1): start and end wavelength [start,end] in [micron] of a “band”. All images found withing this wavelength range will be combined to one.

cleanup()[source]
conv_image(beam=None, noise=None)[source]
regrid_image(fitsfile=None)[source]
residual_image()[source]
radial_profile(incl=None, PA=None, fracbeam=0.33, rms=None, r_out=None, fitsfile=None)[source]
get_coord_refimage()[source]
doall()[source]
class prodimopy.utils_casasim.LinePP(proj, modelfits, sys_vel=None, incl=None, PA=None, refimage=None)[source]

Bases: _PostProcess

Object to post-process ProDiMo linecubes for comparison to observations.

This is all still very experimental and everything can still change.

Atrributes

proj

str: A project name which will be used to store the casa files in a directoy with name proj. Also all files will start with the prefix proj.

modelfits

str: The path/filename for the line cube output of ProDiMo. Usually this file is called LINE_3D_xxx.fits.

lineid

str: The identificatoin string for the spectral line (From ProDiMo).

linewl

str: The wavelength of the line [micron]

linefreq

str: The frequency of the line [GHz]

cleanup()[source]
conv_image(infits, outfits, beam=None, noise=None)[source]
momentmap(infits, outfits, moment=0, immomentsparams=None)[source]
radial_profile(incl=None, PA=None, fracbeam=0.33, rms=None, r_out=None, infits=None)[source]
spectral_profile(infits=None)[source]
contsub_model(removeBackground=False, realcont=False)[source]

Removes the continuum. This is done in the image plane. By default it uses directly the model continuum in the cube (this cannot be done in reality).

Parameters:
  • removeBackground (bool) – Remove the background from the continuum result. Simply removes the min value if the continuum image from the image.

  • realcont (bool) – Uses the real continuum from the cube. This real continuum is included the _CONT output files. This is useful to test the impact of continuum oversubtraction. With this option the absorption of the continuum by the line is considered and therefore the continuum subtraction is exact. But this is not something that can be done in reality.

  • TODO (include method to use certain channels from the cube for the cont subtraction)

  • TODO