Read routines for a slab model
This module provides several routines to read the output of a ProDiMo slab model.
All the data belonging to a ProDiMo slab model is put into an hierarchical data structure (slab_data).
The module provides a routine to read “all” the data of a ProDiMo slab model and specialized routines to read only distinct model data (e.g. only the from a list of output files).
Also check the slab notebook example .
The following example reads the output files of a ProDiMo slab model from the current working directory.
The read_slab() function reads ProDiMo slab output data found in the default output file ‘SlabResults.out’.
# the prodimopy modules for reading and plotting
import prodimopy.read_slab as preads
model = preads.read_slab()
model.show()
print(model)
- class prodimopy.read_slab.MyFormatter[source]
Bases:
FormatterString formatter for producing input files
- class prodimopy.read_slab.slab_data[source]
Bases:
objectStructure of the models set up from the SlabInput.in file:
ProDiMo run
|__Model_1 |__molecule_1 |__molecule_2 |__... |__molecule_n |__Model_2 |__molecule_1 |__molecule_2 |__... |__molecule_n |__... |__... |__... |__... |__Model_n |__molecule_1 |__molecule_2 |__... |__molecule_n
Data structure to hold the corresponding slab model output slab_data
|_directory |_models |__model_1 (type:slab) |__prodimo_Model_1_molecule_1 |__model_2 (type:slab) |__prodimo_Model_1_molecule_2 |__model_... (type:slab) |__... |__model_n (type:slab) |__prodimo_Model_2_molecule_n |__model_n+1 (type:slab) |__prodimo_Model_2_molecule_1 |__model_n+2 (type:slab) |__prodimo_Model_2_molecule_2 |__model_... (type:slab) |__... |__model_n+n (type:slab) |__prodimo_Model_2_molecule_n |__model_... (type:slab) |__...
- directory
string: The directory from which the model was read. Can be a relative path.
- models
list: The list containing the models
- convolve(freq_bins=None, R=1, lambda_0=1, lambda_n=1, vr=1300, NLTE=False, conv_type=1, verbose=True, overlap=False)[source]
- property nmodels
- property species_number
- property model_number
- property NH
- property nColl
- property ne
- property nHe
- property nHII
- property nHI
- property nH2
- property dust_to_gas
- property vturb
- property Tg
- property Td
- property Wdil
- property species_name
- property species_index
- property abundance
- property dv
- property nlevels
- property nlines
- property linedata
- property leveldata
- property convWavelength
- property convLTEflux
- property convNLTEflux
- property convType
- property convR
- property convOverlapFreq
- property convOverlapWave
- property overlapFreq
- property convOverlapLTE
- property convOverlapNLTE
- property overlapLTE
- property overlapNLTE
- property overlapTauLTE
- property overlapTauNLTE
- property convOverlapR
- property overlapR
- class prodimopy.read_slab.slab[source]
Bases:
objectclass:: slab Class to hold the data of individual slab models
- prodimopy.read_slab.calculate_mutual_overlap(models, vturb, Tg, mol_mass, R_grid=100000.0, lambda_0=4.9, lambda_n=28)[source]
Calculates mutual line overlap spectra between multiple line-by-line calculated slab models
- Parameters:
models (slab_model or list of slab models)
vturb (scalar) – Turbulent velocity in km/s for calculating the line profile
Tg (scalar) – Gas temperature (used for thermal broadening and planck emission)
mol_mass (scalar) – Molecular mass in AMU to calculate thermal broadening
R_grid (scalar) – High resolution grid on which the overlap spectra is calculated
lambda_0 (scalar) – Lower wavelength limit in microns
lambda_n (scalar) – Upper wavelength limit in microns
- class prodimopy.read_slab.slab1D[source]
Bases:
objectclass:: slab1D Class to hold the data of 1D slab models
- class prodimopy.read_slab.fit_settings(NMOL=None, Nlims=[], Tlims=[], grid=None, grid_mask=None, fit_window=None, Rdisk=None, distance=None, R=None, noise_level=None)[source]
Bases:
object
- prodimopy.read_slab.read_1D_slab(model_path='SlabResults.fits.gz', verbose=True)[source]
Function to read 1D prodimo slab model output
- prodimopy.read_slab.boltzmann_distribution(E_level, g, Temperature, Partition_sum)[source]
Calculates LTE level population
- Parameters:
E_level (scalar or numpy array) – Energy level (cm-1)
g (scalar or numpy array) – Statistical weight or degeneracy of the level
Temperature (scalar or numpy array) – Gas temperature in Kelvin
Partition_sum (scalar or numpy array) – (HITRAN) Partition sum
- prodimopy.read_slab.profile_function(nu, nu0, dnu)[source]
Calculates the profile function at a given spectral location. Assumes a Gaussian profile. Note that here the factor 1/(dnu*pi**0.5) is left out and is required to be multiplied wherever this function is used. All the input parameters should be in the same units.
- Parameters:
nu (scalar or numpy array) – Spectral location where the profile function needs to be calculated
nu0 (scalar or numpy array) – Spectral location of the line center
dnu (scalar or numpy array) – The Doppler frequency shift
- prodimopy.read_slab.planck(T, nu)[source]
Calculates the Planck function at a given frequency for a given temperature
- Parameters:
T (scalar or numpy array) – Temperature of the Planck curve in Kelvin
nu (scalar or numpy array) – Frequency in Hz
- prodimopy.read_slab.read_slab(model_path='SlabResults.out', verbose=True, short_format=False, overlap=False)[source]
Function to read slab model output
- prodimopy.read_slab.read_overlap_spectra(path='SlabOverlap.out', verbose=True)[source]
Function to read 0D prodimo slab model output with line overlap
- prodimopy.read_slab.specConvolve(lineStrengths, lineFreq, freq_bins=None, R=1, lambda_0=1, lambda_n=1, vr=1300)[source]
NOT USED ANYMORE Function to convolve lines into spectra by simply binning them into a wavelength grid
- prodimopy.read_slab.generalConvolve(lineStrengths, lineFreq, R=1, lambda_0=1, lambda_n=1, R_back=1000000.0)[source]
Function to convolve line fluxes into line spectra based on a user defined spectral resolving power R
- prodimopy.read_slab.generate_grid(R=1, lambda_0=1, lambda_n=1, sampling=1)[source]
Generate a spectral grid in GHz
- prodimopy.read_slab.convolve(models, freq_bins=None, R=1, lambda_0=1, lambda_n=1, vr=1300, NLTE=False, conv_type=1, verbose=True)[source]
Same as .convolve() method
- prodimopy.read_slab.generate_slab_grid(directory='.', grid_parameters={}, combination=False, Ntot=None, Tg=None, nHplus=None, nH1=None, nH2=None, nHe=None, nelec=None, Td=None, Wdil=None, vturb=None, dust_to_gas=None, R_overlap=None, line_overlap=None, species_list={}, output_filename='SlabResults.out', overlap_filename='SlabOverlap.out', separate_op_files=True, slab_RT=True, short_format=False, no_individual_lines=False, fits_op_files=False)[source]
Function to generate SlabInput.in input file containing the details of the slab model grid
- prodimopy.read_slab.generate_1D_structure(dz, species_list, vturb, nd, Td, n_species, T_species, nH2=0, nHI=0, nHII=0, nHe=0, nelec=0, filename='1D_structure')[source]
Generates 1D structure file required for 1D slab models
- prodimopy.read_slab.line_flux(l1, l2, wavelength, flux)[source]
Units: Return is in the same unit as input. [Assumed to be in erg/s/cm2/sr] l1 and l2 same unit as wavelength
- Returns:
Sum of integrated line flux between wavelengths l1 and l2.
- Return type:
float
- prodimopy.read_slab.line_fluxes(windows, wavelength, flux)[source]
Return: array of sum of integrated line flux in wavelength windows.
Units: Return is in the same unit as input. [Assumed to be in erg/s/cm2/sr]
windows: list of wavelength limits of windows. Example: [[14,14.5],[15,16.2],[12.5,14.1]]
- prodimopy.read_slab.line_flux_ratios(ratio_windows, wavelength, flux)[source]
Return: Integrated line flux ratios between wavelengths l1 and l2.
Unit: Return has no unit. [Input is assumed to be in erg/s/cm2/sr]
ratio_windows: list of wavelength windows. Example: [[[14,14.5],[15,16.2]],[[12.5,14.1],[13.4,13.8]]]
- prodimopy.read_slab.line_flux_products(product_windows, wavelength, flux)[source]
Return: Integrated line flux products between wavelengths l1 and l2.
Unit: Return unit is output units squared. [Input is assumed to be in erg/s/cm2/sr]
product_windows: list of wavelength windows. Example: [[[14,14.5],[15,16.2]],[[12.5,14.1],[13.4,13.8]]]
- prodimopy.read_slab.spectral_flux(l1, l2, wavelength, flux)[source]
Unit: Return in [erg/s/cm2] and input is in [Jy] l1, l2, and wavelength in microns
- Returns:
Sum of integrated line flux between wavelengths l1 and l2.
- Return type:
float
- prodimopy.read_slab.spectral_fluxes(windows, wavelength, flux)[source]
Return: Sum of integrated line flux between wavelength windows.
Unit: return is in [erg/s/cm2] and input is in [Jy]
windows: list of wavelength limits (microns) of windows. Example: [[14,14.5],[15,16.2],[12.5,14.1]]
- prodimopy.read_slab.spectral_flux_ratios(ratio_windows, wavelength, flux)[source]
Return: Spectral integrated flux ratios between wavelength windows.
Units: Return is without units and input is in [Jy]
ratio_windows: list of wavelength (microns) windows. Example: [[[14,14.5],[15,16.2]],[[12.5,14.1],[13.4,13.8]]]
- prodimopy.read_slab.spectral_flux_products(product_windows, wavelength, flux)[source]
Return: Products of spectral integrated fluxes between wavelength windows.
Units: Return unit is output units squared and input is in [Jy]
product_windows: list of wavelength (microns) windows. Example: [[[14,14.5],[15,16.2]],[[12.5,14.1],[13.4,13.8]]]
- prodimopy.read_slab.chi2_slab(slab_data, spectra, windows=[], ratio_windows=[], product_windows=[], Rdisk=array([1.00000000e-02, 2.78255940e-02, 7.74263683e-02, 2.15443469e-01, 5.99484250e-01, 1.66810054e+00, 4.64158883e+00, 1.29154967e+01, 3.59381366e+01, 1.00000000e+02]), distance=120, convolve=False, NLTE=False, short_format=False)[source]
Returns chi2 based on selected spectral windows across different emitting disk radius
- Parameters:
slab_data (string or slab_model instance) – path corresponding to a single slab model or a single slab_model instance
spectra (numpy.array) – numpy array with first column the wavelength in [microns] and second column flux in [Jy]
windows (array_like) – List of spectral windows for chi2 calculation (weights optional). Format : [window1,window2,….] Window format: [lambda_0, lambda_1, weight] weight is optional, used for weighted chi2 Example without weight: [[14,14.5],[15,16.2],[12.5,14.1]] Example with weight: [[14,14.5,2],[15,16.2,5],[12.5,14.1,1]] Weights are automatically normalised, so sum of weights need not be 1
Rdisk (array_like) – Radius corresponding to emitting area in astronomical units
distance (float) – distance of disk in parsec
convolve (boolean) – If True, the chi2 is performed on convolved spectra and not on individual lines
NLTE (boolean) – if True, NLTE flux is taken from the slab model.
- prodimopy.read_slab.red_chi2_slab(slab_data, spectra, mask, Rdisk=array([1.00000000e-02, 2.78255940e-02, 7.74263683e-02, 2.15443469e-01, 5.99484250e-01, 1.66810054e+00, 4.64158883e+00, 1.29154967e+01, 3.59381366e+01, 1.00000000e+02]), distance=120, NLTE=False, R=3000, short_format=False, overlap=False, noise_level=1)[source]
Returns reduced chi2 based on selected spectral windows across different emitting disk radius
- Parameters:
slab_data (string or slab_model instance) – path corresponding to a single slab model or a single slab_model instance
spectra (numpy.array) – numpy array with first column the wavelength in [microns] and second column flux in [Jy]
mask (numpy.array) – numpy boolean array that masks certain parts of the spectra from the fit
Rdisk (float) – Radius corresponding to emitting area in astronomical units
distance (float) – distance of disk in parsec
NLTE (boolean) – if True, NLTE flux is taken from the slab model in case of overlap=False.
R (float) – Spectral resolving power of the observed spectrum for convolving the slab model
short_format (boolean) – Type of slab model output file, short vs long
overlap (boolean) – Molecular opacity overlap considered in the slab model
noise_level (float) – Noise level in the spectrum, in the same units as the flux passed in the argument spectra
- prodimopy.read_slab.red_chi2_slab_weighted(slab_data, spectra, mask_weight_array, Rdisk=array([1.00000000e-02, 2.78255940e-02, 7.74263683e-02, 2.15443469e-01, 5.99484250e-01, 1.66810054e+00, 4.64158883e+00, 1.29154967e+01, 3.59381366e+01, 1.00000000e+02]), distance=120, NLTE=False, R=3000, short_format=False, overlap=False, noise_level=1)[source]
Returns reduced chi2 based on selected spectral windows across different emitting disk radius
- Parameters:
slab_data (string or slab_model instance) – path corresponding to a single slab model or a single slab_model instance
spectra (numpy.array) – numpy array with first column the wavelength in [microns] and second column flux in [Jy]
mask_array (list of list [numpy.array,float]) – list containing lists of numpy boolean arrays that masks certain parts of the spectra from the fit and their weighting
Rdisk (float) – Radius corresponding to emitting area in astronomical units
distance (float) – distance of disk in parsec
NLTE (boolean) – if True, NLTE flux is taken from the slab model in case of overlap=False.
R (float) – Spectral resolving power of the observed spectrum for convolving the slab model
short_format (boolean) – Type of slab model output file, short vs long
overlap (boolean) – Molecular opacity overlap considered in the slab model
noise_level (float) – Noise level in the spectrum, in the same units as the flux passed in the argument spectra
- prodimopy.read_slab.red_chi2_slab_multi(slab_data, spectra, mask, Rdisk=array([1.00000000e-02, 2.78255940e-02, 7.74263683e-02, 2.15443469e-01, 5.99484250e-01, 1.66810054e+00, 4.64158883e+00, 1.29154967e+01, 3.59381366e+01, 1.00000000e+02]), distance=120, NLTE=False, R=3000, short_format=False, overlap=False, noise_level=1)[source]
Returns reduced chi2 for two slab models based on selected spectral windows across different emitting disk radius
- Parameters:
slab_data (list of strings) – paths corresponding to two slab model
spectra (numpy.array) – numpy array with first column the wavelength in [microns] and second column flux in [Jy]
mask (numpy.array) – numpy boolean array that masks certain parts of the spectra from the fit
Rdisk (float) – Radius corresponding to emitting area in astronomical units
distance (float) – distance of disk in parsec
NLTE (boolean) – if True, NLTE flux is taken from the slab model in case of overlap=False.
R (float) – Spectral resolving power of the observed spectrum for convolving the slab model
short_format (boolean) – Type of slab model output file, short vs long
overlap (boolean) – Molecular opacity overlap considered in the slab model
noise_level (float) – Noise level in the spectrum, in the same units as the flux passed in the argument spectra