magritte.tools module

class magritte.tools.Timer(name)

Bases: object

A simple timer class.

print()

Print the elapsed time.

start()

Start the timer.

stop()

Stop the timer.

magritte.tools.I_CMB(frequency)

Intensity of the cosmic microwave background.

Parameters

frequency (float) – Frequency at which to evaluate the intensity.

Returns

out – Intensity of the cosmic microwave background evaluated at the frequency.

Return type

float

magritte.tools.LTEpop(linedata, temperature)

Returns the LTE level populations give the temperature.

Parameters
  • linedata (Magritte Linedata object) – Magritte linedata object of the of the relevant species.

  • temperature (float) – Temperature for which to evaluate the LTE level populations.

Returns

out – Array containing the LTE level populations for the given temperature.

Return type

array_like

magritte.tools.check_one_line_approximation(model)
magritte.tools.dnu(linedata, k, temp, vturb2)

Spectral line width.

Parameters
  • linedata (Magritte Linedata object) – Magritte linedata object of the of the relevant species.

  • k (int) – Transition number of the line.

  • temp (float) – Local temperature [K].

  • vturb2 (float) – Square of the turbulent velocity as fraction of the speed of light.

Returns

out – Line width of the line profile function.

Return type

float

magritte.tools.extract_spectrum_from_FITS(fits_file, aperture)

Extract a spectrum from a FITS file for a given aperture.

Parameters
  • fits_file (str) – FITS file containing a data cube.

  • aperture (float) – Aperture over which to intergrate the image in arcseconds [as].

Return type

Two arrays, one containing the velocities (in km/s) and one containing the intensities.

magritte.tools.lineEmissivity(linedata, pop)

Returns the line emissivity for each radiative transition.

Parameters
  • linedata (Magritte Linedata object) – Magritte linedata object of the of the relevant species.

  • pop (array_like) – Populations of the levels.

Returns

out – Array containing the line emissivity function for each radiative transition.

Return type

array_like

magritte.tools.lineOpacity(linedata, pop)

Returns the line opacity for each radiative transition.

Parameters
  • linedata (Magritte Linedata object) – Magritte linedata object of the of the relevant species.

  • pop (array_like) – Populations of the levels.

Returns

out – Array containing the line opacity function for each radiative transition.

Return type

array_like

magritte.tools.lineSource(linedata, pop)

Returns the line source function for each radiative transition.

Parameters
  • linedata (Magritte Linedata object) – Magritte linedata object of the of the relevant species.

  • pop (array_like) – Populations of the levels.

Returns

out – Array containing the line source function for each radiative transition.

Return type

array_like

magritte.tools.planck(temperature, frequency)

Planck function for thermal radiation.

Parameters
  • temperature (float) – Temperature at which to evaluate the intensity.

  • frequency (float) – Frequency at which to evaluate the intensity.

Returns

out – Planck function evaluated at the frequency for the given temperature.

Return type

float

magritte.tools.profile(linedata, k, temp, vturb2, nu)

Gaussian line profile function.

Parameters
  • linedata (Magritte Linedata object) – Magritte linedata object of the of the relevant species.

  • k (int) – Transition number of the line.

  • temp (float) – Local temperature [K].

  • vturb2 (float) – Square of the turbulent velocity as fraction of the speed of light.

  • nu (float) – Frequency at which to evaluate the line profile function.

Returns

out – Gaussian profile function evaluated at frequency nu.

Return type

float

magritte.tools.relative_error(a, b)

Returns the relative error between a and b.

magritte.tools.save_fits(model, filename=None, image_nr=- 1, zoom=1.3, npix_x=300, npix_y=300, method='nearest', dpc=1.0, coord=None, f_rest=0.0, square=False)

Save channel maps of synthetic observation (image) as a fits file.

Parameters
  • model (object) – Magritte model object.

  • image_nr (int) – Number of the synthetic observation to plot. (Use -1 to indicate the last one.)

  • zoom (float) – Factor with which to zoom in on the middel of the image.

  • npix_x (int) – Number of pixels in the image in the horizontal (x) direction.

  • npix_y (int) – Number of pixels in the image in the vertical (y) direction.

  • method (str) – Method to interpolate the scattered intensity data onto a regular image grid.

  • dpc (float) – Distance of source in parsec.

  • coord (str) – Image centre coordinates.

  • f_rest (float) – Rest frequency of the transition.

  • square (bool) – True if square pixels are required.

Return type

None

magritte.tools.save_fits_1D(model, filename=None, image_nr=- 1, zoom=1.3, npix=300, dpc=1.0, coord=None, f_rest=0.0)

Save channel maps of synthetic observation (image) as a fits file.

Parameters
  • model (object) – Magritte model object.

  • image_nr (int) – Number of the synthetic observation to plot. (Use -1 to indicate the last one.)

  • zoom (float) – Factor with which to zoom in on the middel of the image.

  • npix (int) – Number of pixels in the image in the horizontal and vertical direction.

  • dpc (float) – Distance of source in parsec.

  • coord (str) – Image centre coordinates.

  • f_rest (float) – Rest frequency of the transition.

Return type

None

magritte.tools.timestamp()

Returns a time stamp for the current date and time.

Returns

out – A string containing the current date and time.

Return type

str