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 hierachical data structure (slab_data).

The module provides a routine to read “all” the data of a ProDiMo slab model and spezialized routines to read only distinct model data (e.g. only the from a list of output files).

Also check the example notebook.

Usage 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)

Source documentation

class prodimopy.read_slab.MyFormatter[source]

String formatter for producing input files

format_field(value, format_spec)[source]
check_unused_args(used_args, args, kwargs)
convert_field(value, conversion)
format(format_string, /, *args, **kwargs)
get_field(field_name, args, kwargs)
get_value(key, args, kwargs)
parse(format_string)
vformat(format_string, args, kwargs)
class prodimopy.read_slab.slab_data[source]

Structure 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

show()[source]
add_model(model_data)[source]
remove_model(index)[source]
convolve(freq_bins=None, R=1, lambda_0=1, lambda_n=1, vr=1300, NLTE=False, conv_type=1, verbose=True, overlap=False)[source]
convolve_overlap(R=1, lambda_0=1, lambda_n=1, verbose=True)[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 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]

class:: slab Class to hold the data of individual slab models

convolve(freq_bins=None, R=1, lambda_0=1, lambda_n=1, vr=1300, NLTE=False, conv_type=1, overlap=False)[source]
convolve_overlap(R=1, lambda_0=1, lambda_n=1)[source]
show()[source]
class prodimopy.read_slab.slab1D[source]

class:: slab1D Class to hold the data of 1D slab models

convolve(R=1, lambda_0=1, lambda_n=1, verbose=True)[source]
show()[source]
class prodimopy.read_slab.fit[source]
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]
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.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, 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