Read routines for a molecular cloud model

Routines to read the output of a (time-dependent) molecular cloud (mc,0D chemistry)
ProDiMo
model.
All the data belonging to a mc
ProDiMo
model is put into a hierarchical data structure (
Data_mc
).
Those kind of
ProDiMo
models are 0D chemistry models which provide the abundances for a given set of parameters (e.g. density,temperature etc.)
The module provides routines to read only the final abundances (last age or steady-state model) or the
abundances for all ages (as a function of time). Also the according ages and species names are read.
The following examples reads the time-dependent results of a molecular cloud
ProDiMo
model from the current working directory..
import
prodimopy.read_mc
as
pread_mc
model
=
pread_mc
.
read_mc
(
"MC_Results.out"
)
print
(
model
)
class
prodimopy.read_mc.
MCParameterSet
[source]

Bases:
object
A class to hold (some) physical parameters for one model or for one time step in a dynamic model.
Can also be used to  to generate input files the the molecular cloud mode of ProDiMo.
The order of the parameters is currently fixed and has to match the order in the input file for dynamic models (mc_dynamic.in).
This also means this class only contains those parameters that can be set in the input file for dynamic models.
params
:
dict

:
Dictionary with the parameters. Do not change the order.
property
nH

property
td

property
tg

property
CHI1

property
CHI2

property
a1

property
dust_to_gas

property
rho_gr

property
vturb

property
CRI

property
Av

property
albedo

fill_fromStr
(
s
)
[source]

class
prodimopy.read_mc.
Data_mc
(
name
=
None
)
[source]

Bases:
object
Data structure for one molecular cloud (0D chemistry)
ProDiMo
model.
Can be used for a time-dependent, steady-state (or final) or for a dynamic model.
The dynamic ones can have physical properties as function of f(t).
Parameters
:
name
(
string
) – The name of the model.
name

string:
The name of the model (can be empty)
directory
:
str
|
None

The directory from which the model was read. Is e.g. set
read_mc()
. Can be a relative path.
species

array_like(string,ndim=1):
an ordered list of species names.
ages

array_like(float,ndim=1):
the output ages of the model.
physicalParameters
:
MCParameterSet
|
list
[
MCParameterSet
]
|
None

The physical parameters of the model. In case of a dynamic model it will be a list.
ratecoefficients

array_like(float,ndim=1):
The rate coefficients (just the rates as an array)
abundances

array_like(float,ndim=2):
the abundances for each species and each age
DIMS:
(number of ages,number of species).
property
chemnet
:
ReactionNetworkPout

The chemical reactions of the model. Holds what is in
Reactions.out
. Is only read if needed.
analyse_chemistry
(
species
,
filenameChemistry
=
None
,
to_txt
=
True
,
screenout
=
False
)
[source]

Routine to create a Chemistry analysis object for the given species, if the chemanalysis data is available.
Parameters
:
species
(
str
) – The species to analyse.
filenameChemistry
(
str
|
None
) – The name of the file that holds the reaction rates. Usually one does not need to change that.
to_txt
(
bool
) – Write info about formation and destruction reactions for the selected molecule to a txt file.
screenout
(
bool
) – If
True
all the form./dest. reactions are  printed on the screen.
Returns
:
List of objects that hold all the required information and can be used for the plotting routines or for
reac_rates_ix_iz()
.
Return type
:
list[
Chemistry
]
prodimopy.read_mc.
read_tdep_file
(
filename
)
[source]

Tries to read the MC_conc_tdep.out file and returns the ages and
and abundances of that file.
This file actually includes the number densities and not abundances.
Try to estimate the abundances by adding up H, H2 and H+
Currently this file does not include the initial abundances!
Todo
This is quick and dirty. However, the problem is more in
ProDiMo
because
it is unclear what file is for what and when (depending on parameter configuration)
which file is written.
This does not deal with the two e- like in the normal mode. This is inconsistent.
Returns
:
Returns a tuple containing the list of species, the list of ages, and the
species abundances (in that order)
Return type
:
tuple
Parameters
:
filename
(
str
)
prodimopy.read_mc.
read_mc_final
(
filename
=
'Molecular_cloud.out'
,
directory
=
'.'
,
name
=
None
)
[source]

Reads the final (last timestep) molecular cloud abundances.
Parameters
:
filename
(
string
) – The name of the file containing the abundances (optional).
directory
(
string
) – The model directory (optional).
name
(
string
) – The name of the model. Will be shown in the plots (optional).
FIXME: ist not consistent with read_mc, e.g. the species names such as N2H+ are not adapted here
FIXME: use numpy arrays for the abundances such as for time-dependent models.
prodimopy.read_mc.
read_mc
(
directory
=
'.'
,
filename
=
'mc_output.out'
,
agesfile
=
'mc_ages.txt'
,
speciesfile
=
'mc_species.txt'
,
imodel
=
None
,
rcfile
=
'MC_rate_coefficients.txt'
,
dynamic_input_file
=
'mc_dynamic.in'
,
name
=
None
)
[source]

Read routine for molecular cloud
ProDiMo
models including the ages and the species list.
Parameters
:
directory
(
str
) – The model directory.
filename
(
str
) –
The name of the file containing the abundances for all ages.
Please check what output file you have in your particular model and adapt
it here. (default:
mc_output.txt
)
It is rather confusing how it is done in
ProDiMo
. So it is hard
to find a clean solution here.
The routine also try now to read the
MC_conc_tdep.out
if there is not
agesfile
(i.e. “mc_ages.txt”). However, in that file the initial abundances
are not included.
agesfile
(
str
) – The file with the ages (default:
mc_ages.txt
)
speciesfile
(
str
) – The file with the species names (default:
mc_species.txt
)
rcfile
(
string
) – The file with the calculated rate coefficients (default:
MC_rate_coefficients.txt
)
dynamic_input_file
(
str
) – The name of the file that holds the input for a dynamic model.
This is needed to read the physical parameters for a dynamic model. (default:
mc_dynamic.in
).
Ignored if the file does not exist.
TODO: currently we assume mc_dynamic implies only one model, which is currently the case in prodimo.
imodel
(
int
|
None
) – if imodel is set, the filenames are adapted to read the particular model (e.g. imodel=2 reads
mc_output_002.txt
instead of
mc_output.txt
)
name
(
str
|
None
)
prodimopy.read_mc.
read_umist
(
directory
,
filename
=
'dc_molecules.dat'
,
name
=
None
)
[source]

Reads the results of a UMIST rate13 code model.
Uses the output produced by dc.pl script provided by the UMIST code distribution.
The data is provided as a
prodimopy.read_mc.Data_mc
object.
prodimopy.read_mc.
write_mc_dynamic_input
(
ages
,
params_list
,
filename
=
'./mc_dynamic.in'
)
[source]

Writes a
mc_dynamic.in
file with the given ages and parameter settings.
File format:
Line 1  : N  (number of time steps)
Line 2  : N age values in years, whitespace-separated
Lines 3+: one whitespace-separated parameter line per time step (fields match MCParameterSet.params order)
Parameters
:
filename
(
str
) – The name of the file to write.
ages
(
ndarray
) – The ages to write.
params_list
(
list
[
MCParameterSet
]
) – The list of MCParameterSet objects to write. The length of this list should match the length of the ages array.