Plotting routines for a set of models

Collections of plotting routines to produce comparison plots for a set of ProDiMo models.

Usage example

# the prodimopy modules for reading and plotting
import prodimopy.read as pread
import prodimopy.plot_models as ppms
# this is for the PDF output
from matplotlib.backends.backend_pdf import PdfPages

# Load the prodimopy style
import matplotlib.pyplot as plt
plt.style.use("prodimopy")

# the ProDiMo model directories, each directory is one model
# adapt to your needs
# for some plotting routines it is assumed that the last model
# in that list is a reference model
mdirs=["model1","model2","model3"]

# make a list of models and read all of them
models=list()
for mdir in mdirs:
  models.append(pread.read_prodimo(mdir))

# one can also manipulate the name of a model, this name
# will be shown in the legend of the plots
models[-1].name="reference"

# Create out_models.pdf where all the various plots are stored
with PdfPages("out_models.pdf") as pdf:
  # create the PlotModels object, here it is also possible to e.g.
  # configure the colors used for line plots. For Details see the
  # documentation
  pms=ppms.PlotModels(pdf)

  pms.plot_NH(models,xlog=True)

  # if there was at least one SED calculated for the models, plot them including
  # observational data for comparison (if available)
  if not all(x.sed is None for x in models):
    pms.plot_sed(models,ylim=[1.e-17,None],plot_starSpec=False,sedObs=models[0].sedObs)


  # compare some column densities and average abundances
  for spec in ["CO","H2O"]:
    pms.plot_tcdspec(models, spec,xlog=True)
    pms.plot_avgabun(models,spec,xlog=True)


  # get all line estimates for CO in the wl range from 200 to 1500 mic
  lines=models[0].selectLineEstimates("CO",wlrange=[200,1500])


  # build an array of line idents which are considered for the plot
  # here also only CO lines with an upper level smaller 20 are considered (i.e. the main transition)
  # here jup is the internal level numbering of ProDiMo
  idents=[[x.ident,x.wl] for x in lines if x.jup <20]
  pms.plot_lines(models,idents,showBoxes=False)

Source documentation

class prodimopy.plot_models.PlotModels(pdf, colors=None, styles=None, markers=None, fs_legend=None, ncol_legend=0)[source]
plot_lines(models, lineIdents, useLineEstimate=True, jansky=False, showBoxes=True, lineObs=None, lineObsLabel='Obs.', peakFlux=False, showCont=False, xLabelGHz=False, showGrid=True, **kwargs)[source]

Plots the fluxes for a given selection of lines or lineEstimates.

Parameters:
  • models (array_like) – The list of models of type prodimopy.read.Data_ProDiMo

  • lineIdents (array_like) – a list of line identifiers. Each entry should contain [“ident”,wl] (e.g. [“CO”,1300],[“CO”,800]]. Those values are passed to getLineEstimate(). The order of the lineIdents also defines the plotting order of the lines (from left to right)

  • useLineEstimate (boolean) – if True the lines are selected from the lineEstimates otherwise the lines are taken from the full line radiative transfer. Default: True

  • jansky (boolean) – plot the fluxes in units of Jansky Default: True

  • showBoxes (boolean) – show boxes that indicate the the region within a factor of 3 to the line flux. Default: True

  • lineObs (list(DataLineObs)) – a list of DataLineObs should include all the lines that were include in the line transfer and in the same order. The observations are plotted together with the model line fluxes. if None no observations are plotted. Default: None

  • peakFlux (boolean) – If True use the peakFlux from the line profile instead of the total line fluex. Is sometimes usefull to make predictions for observations, as in that case the peakFlux is often used to estimate observing times. Only works with useLineEstimate=False and jansky=True

  • TODO (if not FlineEstimates than it would be also possible to plot all lines for which line transfer is done) –

  • TODO

plot_NH(models, sdscale=False, marker=None, **kwargs)[source]

Plots the total vertical hydrogen column density as a function of radius for all given models.

Parameters:
  • models (list(Data_ProDiMo)) – the models to plot

  • sdscale (boolean) – set to True to show the scale in g/cm^2 for the second y axis Default : False

  • marker (str) – if not None plot also the given marker symbol. Default : None

plot_tcdspec(models, species, relToH=False, facGrayBox=3.0, ice=False, ax=None, **kwargs)[source]

Plots the total vertical columndensity for the given species for all the models as a function of the radius.

Parameters:
  • models (list(Data_ProDiMo)) – the models to plot

  • species (str) – the name of the species to plot.

  • relToH (boolean) – Plot the columnd density relative to the total hydrogen columne density. Which is essential equal to the average abundance at a certain radius. DEFAULT: False

  • facGrayBox (float) – Plot a gray area for each column density line with width given by y / facGrayBox and y * facGrayBox. Uses matplotlib:fill_between. Set to None if it should not be plotted. DEFAULT: 3

  • ice (boolean) – Plot also the ice phase column density if the ice species exists.

plot_tauline(models, lineIdent, xlog=True, **kwargs)[source]

Plots the line optical depths as a function of radius for a given line.

Parameters:
  • models (list(Data_ProDiMo)) – the models to plot

  • lineIdent (array_like(ndim=1)) – two elment array. First item lineIdent (e.g. CO) second item wavelenght (mu m) see also getLineEstimate()

FIXME: better treatment if no lines are found (should not crash).

plot_avgabun(models, species, **kwargs)[source]

Plots the average abundance of the species as a function of radius. The avergae abundance is given by the vertical column density of the species divided by the total hydrogen column density.

Parameters:
  • models (list(Data_ProDiMo)) – The models to plot.

  • species (str) – The name of the species to plot.

plot_abunvert(models, r, species, **kwargs)[source]

Plot abundances at the given radius r as a function of height.

Parameters:
  • models (list(Data_ProDiMo)) – The models to plot.

  • r (float) – The radius at which the plot should be made UNIT: [au]

  • species (str) – The species name for which the abundance should be plotted.

Todo

Make this a wrapper of plot_vertical(). Just pass nmol as fieldname and species name

plot_radial(models, fields, ylabel, zidx=0, ax=None, showlegend=True, **kwargs)[source]

Plots a quantitiy in radial direction. Fields must have the same number of entries as models and must contain arrays with the dimension of nx.

Parameters:
  • models (list(Data_ProDiMo)) – the models to plot.

  • fields (list(array_like(float,ndim=1))) –

    A list of the data to plot. Each entry in the list needs to be an array with dimension of NX and corresponds to one model. The order has to be the same as for the models list.

    Example to produce a proper fields list.

    zidx=5
    fields=[mod.rhog[:,zidx] for mod in models]
    

  • ylabel (str) – The label for the y Axis of the plot.

  • zidx (int) – The z index for which height the radial plot should be made. This is use to properly calculat the radius. DEFAULT: z=0

plot_midplane(models, fieldname, ylabel, xfieldname=None, xlabel=None, species=None, patches=None, scaleToRin=False, **kwargs)[source]

Plots a quantitiy in in the midplane as a function of radius.

Parameters:
  • models (list(Data_ProDiMo)) – the models to plot

  • fieldname (str) – fieldname is any atrribute of Data_ProDiMo

  • ylabel (str) – The label for the y axis of the plot.

  • xfieldName (str) – xfieldName is any atrribute of Data_ProDiMo and will be used as the x coordinate in the plot. If xfieldName=None the x coordinate of the models is used. DEFAULT: None

  • xlabel (str) – The label for teh x-coordinate of the plot.

  • species (str) – The name of a chemical species. If set the abundance of this species is plotted. DEFAULT: None

  • patches (matplotlib.patches object) – A matplotlib patches object that is overplotted on the figure.

  • scaleToRin (boolean) – If True the r-Rin is used for the x-coordinate of the plot.

plot_vertical_nH(models, r, field, ylabel, species=None, patches=None, showR=True, **kwargs)[source]

Plots a quantity (field) as a function of height (column density) at a certain radius. If field is a string it is interpreted as a field name in the ProDiMo data structure. If field is a list the list is directly used. The list needs to contain 2D arrays with the same shape as other ProDiMo fields

plot_vertical(models, r, fieldname, ylabel, fieldnameIdx=None, species=None, ylog=True, xlog=False, zr=True, xfield='zr', showlegend=True, ax=None, **kwargs)[source]

Plots a quantity (fieldname) as a function of height (various options) at the given radius.

The routine searches for the closest radial grid point for the given radius, no interpolation is done.

Parameters:
  • fieldname (str) – The name of a field(attribute) of the model data object (Data_ProDiMo)

  • fieldnameIdx (int) – An additional index in case the quantity to plot has more than the two spatial dimensions. e.g. fiels[ix,iz,fieldnameIdx]

  • species (str) – A species name. If provided the abundance of this species is plotted. fieldname has to be nmol in that case.

  • xfield (str) –

    Chose the field/quantity that should be used for the x-axis (height). Options:

    • zr z/r, default

    • NHver vertial hydrogen column density.

    • AVver vertial visual extinction.

    • tg gas temperature.

    If none of those or an unknown value is given the z coordinate is used.

plot_abunradial(models, species, perH2=False, **kwargs)[source]

Plots the abundance of the given species as a function of radius for the midplane of the disk.

Parameters:
  • models (list(Data_ProDiMo)) – the models to plot

  • species (str) – The name of the species to plot.

  • perH2 (boolean) – Plot the abundance relative to molecular hydrogen number density instead of the total hydrogen number density.

plot_sed(models, plot_starSpec=True, sedObs=None, sedObsModels=False, unit='erg', reddening=False, **kwargs)[source]

Plots the Seds and the StarSpectrum (optionally).

Parameters:
  • models (list(Data_ProDiMo)) – the models to plot

  • plot_starSpec (boolean) – If True also plot the stellar spectrum.

  • sedObs (DataContinuumObs) – One set of the SED observations to plot (photometry)

  • sedObsModels (boolean) – If True use the DataContinuumObs object from each model individually. So for each model the provided observations are plotted.

  • unit (str) – In which unit the SED should be plotted. Allowed values: erg [erg/s/cm^2], W [W/m^2], Jy, mJy.

  • reddening (boolean) – If True also apply the reddening of the SED using the given A_V value from the provided observational data.

plot_dust_opac(models, xenergy=False, opactype='both', pseudoaniso=False, **kwargs)[source]

Plots the dust opacities, absorption, scattering or extinction.

Parameters:
  • opactype (str) – both absorption and scattering (separately), abs only absorption, sca only scattering, ext only extinction

  • pseudoaniso (boolean) – Use the pseudo anisotropic scattering opacity (Default: False).

plot_starspec_xray(models, nuInu=False, ax=None, **kwargs)[source]

Plots the X-ray spectrum.

plot_starspec(models, step=10, xunit='micron', nuInu=True, ax=None, **kwargs)[source]

Plots the full Stellar Spectrum for each model.

Parameters:
  • models (list(Data_ProDiMo)) – the models to plot

  • step (int) – Only plot every step point of the spectrum.

  • xunit (str) – Unit for the x-axis. Currently mircon and eV are possible.

  • nuInu (boolean) – Plut nu times Inu instead of Inu only.

plot_line_profil(models, wl, ident=None, linetxt=None, lineObs=None, unit='Jy', normalized=False, **kwargs)[source]
plot_lineprofile(models, wl, ident=None, contsub=True, linetxt=None, lineObs=None, incidx=0, normalized=False, convolved=False, style=None, ax=None, **kwargs)[source]

Plots the line profile for the given line (id wavelength and line ident)

Parameters:
  • models (array_like(Data_ProDiMo,dim=1)) – the models

  • wl (float) – The wavelength of the line in micrometer. Plotted is the line with the wavelength closest to wl.

  • ident (str) – The optional line ident which is additionally use to identify the line.

  • contsub (boolean) – Remove the continuum. Default: True

  • linetxt (str) – A string the is used as the label for the line. Default: None

  • lineObs (array_like(ndim=1)) – list of prodimopy.read.DataLineObs objects. Must be consistent with the list of lines from the line radiative transfer.

  • incidx (int) –

    which inclination (index) should be used for plotting (0 is the first one and default).

    If lineObj is passed only one inclination (the one set in that obj) will be plotted.

  • normalized (boolean) – if True normalize the profile to the peak flux of each line

  • convolved (boolean) – if True plot the convolved profile.

  • style (str) – if style is step the profile is plotted as a step function assuming the values are the mid point of the bin.