Create simple ProDiMo grids

This module provides routines to generate simple (and small) ProDiMo model grids.

This is a working and usable implementation but still very limited. More features and improvements are planned and might also require to change the interfaces (e.g. how the grid routines are used) significantly.

Usage example

The following example reads defines the parameters and their ranges used for the grid, creates the grid and runs the grid by submitting a jobscript on a cluster.

import prodimopy.grid as pgrid

gridname="grid1"
indir="IN"

params=list()
params.append(["Lstar",100,300,3,"lin"])
params.append(["env_Mdot",1.e-6,1.e-4,3,"log"])
params.append(["Rout",3000,6000,4,"lin"])


modelnames=pgrid.make_grid(gridname, params, indir)
pgrid.run_grid(gridname,modelnames,
  "sbatch -J $MODELNAME$ -p short ../../prodimo.slurm ParameterGrid.in")

Source documentation

prodimopy.grid.chgriddir(gridname)[source]

Changes the current working directory to the grid directory.

Verifies if I am already in the grid directory.

Parameters:

gridname (str) – The name of the grid (the directory with the models).

prodimopy.grid.genparamentry(name, value)[source]
prodimopy.grid.genvalues(param)[source]

Generates the values for the given parameter.

Currently only lineare and logarithmic spacing is possible.

Todo

allow boolean type of parameters

Todo

allow for the dust composition parameters

prodimopy.grid.run_grid(gridname, modeldirs, runProDiMo)[source]

Runs the grid.

Changes to the grid directory and runs each model by either calling a passed python function or a system command string (see parameters).

Parameters:
  • gridname (str) – The name of the grid (the directory with the models).

  • modeldirs (list) – a list of all models in the grid (also the directory name of each model)

  • runProDiMo (str or method object) –

    if it is a str the string is interpreted as a system command. Any accurence of $MODELNAME$ in the given string is replaced by the actual model name (model directory).

    if the parameter is a python function. This funcion is called with the modeldir as a parameter.

prodimopy.grid.get_modeldirs(modeldirs)[source]

Returns all grid models of the current grid. If modeldirs is not ` Assumes that I am already in the grid directory.

Todo

also pass the gridname as optional parameter.

Returns:

If modeldirs is not None modeldirs is returned. Otherwise all directory names staring with model*/ are returned.

Return type:

list

prodimopy.grid.check_grid(gridname, modeldirs=None)[source]

Checks if all models look okay.

This routine checks if finished.out exists for all models of the grid.

Parameters:
  • gridname (str) – The name of the grid (the directory with the models).

  • modeldirs (list) –

    a list of all models in the grid (directory name of each model).

    If modeldirs is None all directories with names starting with model are considered as potential grid models.

prodimopy.grid.sel_lowest_chisquare(gridname, modeldirs=None, tolerance=None)[source]

Selects the model(s) with the lowest chi squared. If a tolerance is given all models within this tolerance, measured relative to the minimum chi square are selected.

Parameters:
  • gridname (str) – The name of the grid (the directory with the models).

  • modeldirs (list) –

    a list of all models in the grid (directory name of each model).

    If modeldirs is None all directories with names starting with model are considered as potential grid models.

prodimopy.grid.sel_param_val(gridname, param, value, modeldirs=None)[source]

Very primitiv and inefficient method to select models having a certain value of a parameter.

prodimopy.grid.make_grid(gridname, params, indir=None)[source]

Produces a grid of prodimo models.

A directory with the name gridname is created. Within this directory for each parameter combination a directory is created. This directory is initially copied from the directory given by indir and additionally the new parameters are added to a ParameterGrid.in file. If ParameterGrid.in does not exist it will be created.

Todo

deal with dust composition properties (e.g. carbon fraction)

Todo

deal with boolean values

Todo

deal with something like stellar particles and CR spectra (e.g. on/off)

Parameters:
  • gridname (str) – The name of the grid (the directory with the models).

  • params (list) – the list of parameters. Each entry contains the parameter name, its start and end value, the number of steps and if either linear (lin) or logarithmic (log) spacing should be used.

  • indir (str) –

    an input or starting directorz containing the usual ProDiMo input files. This directory is copied into a new model.

    If it is None only the ParameterGrid.in are created

Returns:

the list of modelnames (directory names)

Return type:

list