magritte.tools module
- class magritte.tools.Timer(name)
Bases:
objectA 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.convert_dust_opacity_table_to_SI(wavelengths_wavenumbers_wavefrequencies: Quantity, complex_refractory_index: ndarray, reference_density: Quantity, new_frequency_grid: Quantity = None, left_fill_value: float = 0.0, right_fill_value: float = 0.0)
Convert a dust opacity table (wavelengths, wavenumbers or frequencies) with complex refractive index to absorption coefficient in SI units (m^-1) and rescaled to unit density (kg/m^3).
- Parameters:
wavelengths_wavenumbers_wavefrequencies (Astropy.units.Quantity) – 1D array containing the wavelengths, wavenumbers or frequencies in compatible units (m, m^-1 or Hz).
complex_refractory_index (np.ndarray) – 1D array containing the complex refractive index values (unitless). Same length as wavelengths_wavenumbers_wavefrequencies.
reference_density (astropy.Quantity) – Refernce density in units compatible with kg/m^3, used for rescaling the absorption coefficient.
new_frequency_grid (Astropy.units.Quantity, optional) – New frequency grid to interpolate values upon. If None, use `wavelengths_wavenumbers_wavefrequencies’ instead. Defaults to None.
left_fill_value (float, optional) – Fill value for dust opacity (in m^2/kg) for frequencies lower than the input frequency range. Defaults to 0.0.
right_fill_value (float, optional) – Fill value for dust opacity (in m^2/kg) for frequencies higher than the input frequency range. Defaults to 0.0.
- Raises:
- Returns:
frequencies in Hz, rescaled absorption coefficient in m^2/kg (needs to be multiplied by density in kg/m^3 to get absorption coefficient in m^-1).
- Return type:
tuple(Astropy.units.Quantity, Astropy.units.Quantity)
- 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.read_dust_opacity_table(filename: str, wavelength_frequency_unit: Unit)
Simple script for reading headerless dust opacity data files (with file format like the Jena dust database). Returns the first column (wavelengths, wavenumbers or frequencies) and the third column (complex refractive index).
- Parameters:
filename (str) – Location of the dust opacity table file.
wavelength_frequency_unit (Astropy.units.Unit) – Unit of the first column (wavelengths, wavenumbers or frequencies).
- Returns:
wavelengths or wavenumbers or frequencies, complex refractive index
- Return type:
tuple(Astropy.units.Quantity, np.ndarray)
- 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