Plotting routines for a single model
Collections of plotting routines for ProDiMo model output. All the routines use matplotlib. Typically the output is a pdf file.
# the prodimopy modules for reading and plotting
import prodimopy.read as pread
import prodimopy.plot as pplot
# this is for the PDF output
from matplotlib.backends.backend_pdf import PdfPages
# Load the default prodimopy style
pplot.load_style()
# read the model from the current directory
model=pread.read_prodimo()
# Create an out.pdf where all the various plots are stored
with PdfPages("out.pdf") as pdf:
# create a prodimo Plot object for the various plotting routines
pp=pplot.Plot(pdf)
# vertical hydrogen number density
pp.plot_NH(model,ylim=[1.e20,None])
# a generic contour plot routine with many options
pp.plot_cont(model, model.nHtot, r"$\mathsf{n_{<H>} [cm^{-3}]}$",
zlim=[1.e4,None],extend="both")
# Here follows an example for a more complex contour plot, showing
# some of the plenty options of this routine
# Define some additional contours, with also showing labels
# as the automatic positioning of labels does not work very well,
# you likely have to tweak the label locations (see next line)
tcont=pplot.Contour(model.td, [20,100,1000], linestyles=["-","--",":"],
showlabels=True,label_fontsize=10,label_fmt="%.0f")
#tcont.label_locations=[(100,100),(55,5),(40,5)]
# another contour, a simple one
avcont=pplot.Contour(model.AV,[1.0],colors="black")
# define the ticks shown in the colorbar
cbticks=[10,30,100,300,1000]
pp.plot_cont(model, model.td, "td",zr=True,xlog=True,
ylim=[0,0.5], zlim=[5,1500],extend="both",
oconts=[tcont,avcont], # here the addtional contour added
contour=False, # switch of the standard contours
clevels=cbticks, # explictly set ticks for the cbar
clabels=map(str,cbticks),# and make some nice labels
cb_format="%.0f")
- class prodimopy.plot.Plot(pdf=None, fs_legend=None, title=None)[source]
Bases:
objectPlot routines for a single ProDiMo model.
- Parameters:
pdf (PdfPages | None)
fs_legend (int | None)
title (str | None)
- pdf: PdfPages | None
A
matplotlib.backends.backend_pdf.PdfPagesobject for output as pdf, or None, for output on screen (notebook etc.). Default: None
- fs_legend: int
Default font size for the legend in a plot. If not set it is taken from the matplotlib rcParams.
- ncol_legend: int
Maximum number of columns in the legend. Default: 5
- title: str | None
A title for the plot (e.g. the name of the model). Default: None (no title)
- pcolors: dict[str, str]
Some nice colors.
- plot_grid(model, zr=False, ax=None, **kwargs)[source]
Plots the spatial grid.
Also all the standard parameter like xlim, ylim etc. can be used.
- Parameters:
model (
Data_ProDiMo) – the model datazr (boolean) – show the height z as z/r (scaled by the radius)
- plot_NH(model, sdscale=False, muH=None, marker=None, ax=None, **kwargs)[source]
Plots the total vertical hydrogen column number density as a function of radius.
- Parameters:
model (
Data_ProDiMo) – the model datasdscale (boolean) – show additionally a scale with units in g cm-2
- Returns:
object if self.pdf is None the Figure object is returned, otherwise otherwise the plot is written directly into the pdf object(file) and None is returned.
- Return type:
Figureor None
- plot_cont_dion(model, zr=True, oconts=None, ax=None, **kwargs)[source]
Plots the regions where either X-rays, CR or SP are the dominant H2 ionization source.
Todo
not really general, should be more flexible (i.e. colors)
requires better documentation to make it more general
- plot_cont(model, values, label='value', zlog=True, grid=False, zlim=[None, None], zr=True, cmap=None, norm=None, clevels=None, clabels=None, contour=True, extend='neither', oconts=None, nbins=70, bgcolor=None, showcb=True, cb_format='%.1f', scalexy=[1, 1], patches=None, rasterized=False, returnFig=False, fig=None, ax=None, movie=False, **kwargs)[source]
Plot routine for 2D filled contour plots.
If an ax object is passed to this routine, it is use use to do the plotting. This is especially useful if you want to use that routine together with subplots (e.g. a grid of plots). See for example
plot_abuncont_grid().- Parameters:
model (
Data_ProDiMo) – the model datavalues (array_like(float,ndim=2) or str) – a 2D array with numeric values for the plotting. E.g. any 2D array of the
Data_ProDiMoobject. If a string is passed, it is assumed to be the name of an attribute and the corresponding array is used. E.g. Passed value is “tg” -> the array used will be model.tg.label (str) – The label for the colorbar (color scale). Default: value Should be the quantity and unit of the field that is shown.
zlog (boolean) – Using log scaling for the values. Default: True
grid (boolean) – Use the grid (ix,iz) as spatial coordinates. Default: False
zlim (array_like(float,ndim=2)) – The minimum and maximum values for the color scale. Default: [None,None]
zr (boolean) – Use z/r as the spatial coordinate for the y-axis. Default: True
norm (Normalize | str | None) – Value is passed on to norm attribute of
matplotlib.pyplot.contourf()(i.e. can be a string or Norm object). If norm is set zlog is ignored. Is not well tested, but things like norm=”log” or norm=”symlog”, should work.cmap (str or
matplotlib.colors.Colormap) – this is simply passed on to the contourf routine of matplotlib seematplotlib.pyplot.contourf()for detailclevels (array_like(float,ndim=1)) – The contour levels to plot. Default: None This will also set the labels shown in the colour bar. If None the levels are determined by the MaxNLocator routine and will be 6.
clabels (array_like(str,ndim=1)) – Overwrite the labels for the colorbar. Default: None
contour (boolean) – Show contour lines for the clevels. Default: True
extend (str) – The extend of the colorbar. Default: neither (see
matplotlib.pyplot.colorbar())oconts (array_like(
Contour,ndim=1)) – list ofContourobjects which will be drawn as additional contour levels. See also the example at the top of the page.nbins (int) – The number of bins for the color scale. Default: 70
bgcolor (str) – The background color of the plot. Default: None Can be useful to set the background color in the plot to black for example.
showcb (boolean) – Show the colorbar or not. Default: True
cb_format (str) – The format string for the colorbar labels. Default: %.1f
scalexy (array_like(float,ndim=1)) – A scaling factor (multiplicative) for the x and y coordinates. Default: [1,1] W.g. plot in 1000 of au instead of au.
ax (
matplotlib.axes.Axes) – a matplotlib axis object which will be used for plottingpatches (array_like(
matplotlib.patches.Patch,ndim=1)) – a list of patches objects. For each object in the list, simply ax.add_patch() is called (at the very end of the routine)movie (boolean) – Special mode for movies …
Todo
Option for passing a norm (
matplotlib.colors.LogNorm). But that does not work nicely with contourf and colorbars … works with imshow and pcolormesh though … maybe switch to pcolormesh.
- streamplot_overlay(model, axes, resolution=0.1, use_axlim=True, streamprops={})[source]
Creates a streamplot using the plt.streamplot routine from for the vx and vz velocity components of the model. Is plotted on top of the passed axes object (e.g. from a contour plot). Please note for a “normal” ProDiMo model the vx and vz components are zero and so nothing will be plotted.
- Parameters:
model (Data_ProDiMo) – The ProDiMo model data.
axes (Axes) – The axes object on which the streamplot should be plotted.
resolution (float) – The resolution of the regular grid on which the velocity components are interpolated. Unit: au.
use_axlim (bool) – If True the current axis limits are used to define the grid for the streamplot. So the streamlines are only calculated for the visible part. Please note if the axis limits are changed later on, the streamplot will not be updated! If False the full model grid is used (old behaviour).
streamprops (dict) – A dictionary with properties for the streamplot. This is passed on to the
matplotlib.axes.Axes.streamplot(). By default only a few properties of the streamplot are initialised. But most likely those need to be adapted.
- plot_abuncont(model, species='O', rel2H=True, label=None, zlog=True, zlim=[None, None], zr=True, cmap=None, clevels=None, clabels=None, contour=True, extend='neither', oconts=None, nbins=70, bgcolor=None, cb_format='%.1f', showcb=True, scalexy=[1, 1], patches=None, rasterized=False, ax=None, movie=False, **kwargs)[source]
Plots the 2D abundance structure of a species.
This is a convenience function and is simply a wrapper for
plot_cont()routine.The routine checks if the species exists, calculates the abundance and sets some defaults (e.g. label) for the
plot_cont()routine and calls it. However, all the defaults can be overwritten by providing the corresponding parameter.Contributors: L. Klarmann, Ch. Rab
Todo
can be improved with better and smarter default values (e.g. for the colorbar)
- Parameters:
model (
prodimopy.read.Data_ProDiMo) – the model dataspecies (str) – the name of the species as given in ProDiMo
rel2H (boolean) – plot abundances relative to the total H nuclei number density. If False the number density of the species is plotted
label (str) – the label for the colorbar. If None the default is plotted
For all other parameters see
plot_cont()
- plot_abuncont_grid(model, speciesList=['e-', 'H2', 'CO', 'H2O'], nrows=2, ncols=2, rel2H=True, label=None, zlog=True, zlim=[None, None], zr=True, cmap=None, clevels=None, clabels=None, contour=True, extend='neither', oconts=None, nbins=70, bgcolor=None, cb_format='%.1f', scalexy=[1, 1], patches=None, rasterized=False, **kwargs)[source]
Convenience routine to plot a grid of abundance plots in the same way as
plot_abuncont().The number of plots is given by nrows times ncols and should be equal to the number of species in speciesList
- Parameters:
model (
Data_ProDiMo) – the model dataspeciesList (array_like(str,ndim=1) :) – a list of species names that should be plotted. The plots will be made in order of that list, starting from top left to the bottom right of the grid.
nrows (int) – how many rows should the subplots grid have.
ncols (in) – how many columns should teh subplots grid have.
zlim (array_like) – can either be of the form [zmin,zmax] ore a list of such entries ([zmin1,zmax1],[zmin1,zmax1], ….). For the latter the number of entries must be equal to the number of species.
For the other parameters see
plot_abuncont()
- plot_reaccont(model, chemana, rtype, level=1, showAbun=False, values=None, label=None, cmap=None, zlog=True, zlim=[None, None], clevels=None, clabels=None, contour=True, extend='neither', oconts=None, nbins=70, bgcolor=None, cb_format='%.1f', patches=None, rasterized=True, ax=None, **kwargs)[source]
Make a contour plot with the reactions numbers from chemistry analysis on top. As spatial coordinates the indices of the spatial grid are used.
This is a convenience function and is simply a wrapper for
plot_cont()routine.The same can be achieved by simply using plot_cont and plot the numbers on top (see last part of this routine). Then one has more flexibility.
- Parameters:
model (
prodimopy.read.Data_ProDiMo) – the model datachemana (class:prodimopy.read.Chemistry) – data resulting from prodimopy.read.analyse_chemistry on a single species
rtype (str) – keyword which sets the type of reactions to be shown (destruction or formation) must be set to either ‘d’ (destruction) or ‘f’ (formation)
level (int) – 1 means most important, 2 second most important etc.
showAbun (boolean) – Show the abundances of the species that is analysed as filled contours.
values (array_like(float,ndim=2)) – a 2D array with numeric values for the plotting like in
plot_cont(). However, it an also be None (default) in that case the total formation/destruction rate is plotted.sfigs (array_like(float,ndim=2)) – Is part of kwargs. But this one is relevant here as one might need to make the figure larger to see the reaction numbers. e.g. just pass sfigs=[2.,2.]
- plot_reac_form_dest(chemana, level=1, **kwargs)[source]
Plot the formation and destruction rates of the most important reactions (or second most etc. ) for a given chemistry analysis object.
- Parameters:
chemana (Chemistry) – The chemistry analysis object resulting from
analyse_chemistry().level (int) – The level of the reactions to be plotted (1 for most important, 2 for second most important etc.).
- Return type:
Todo
Currently at most 10 reactions can be plotted (i.e. 10 colors are used).
Currently the axes are fixed:
y=z/randx=log(r)au.
- plot_reac_ixiz(ix, iz, rtype, chemanas, chemana_steadystate=None, ax=None, **kwargs)[source]
Plots the rates for the most important reactions at the point
ix,izfor the given chemanalysis list, which usually come from a time-dependent ProDiMo disk model (i.e time steps). That ages (x-axis) are taken from the model connected the the chemanalysis objects.- Parameters:
ix (int) – The ix index of the grid (starts at 0)
iz (int) – The iz index of the grid (starts at 0)
rtype (str) –
ffor formation reactions,dfor destruction reactions.chemanas (list[Chemistry]) – A list of chemanalysis objects (e.g. for each age in a time-dependent model). All have to be for the same species.
chemana_steadystate (Chemistry | None) – The chemistry analysis of an equivalent steady-state model (i.e. same grid, etc.) for the same species. Optional
- plot_line_origin(model, lineIdents, field, label='value', showBox=True, showRadialLines=True, showContOrigin=False, showztauD1=True, boxcolors=None, boxlinewidths=1.5, boxlinestyles=None, boxhatches=None, lineLabels=None, showLineLabels=True, lineLabelsFontsize=6.0, lineLabelsAlign='left', zlog=True, zlim=[None, None], zr=True, clevels=None, clabels=None, extend='neither', oconts=None, nbins=70, bgcolor=None, cb_format='%.1f', scalexy=[1, 1], patches=None, rasterized=False, ax=None, **kwargs)[source]
Plots the line origins for a list of lineestimates given by their lineIdents ([“ident”,wavelength]).
Does not give the exact same results as the corresponding idl routine as we do not use interpolation here. We rather use the same method for calculating the averaged values over the emission area and for plotting this area.
Note most other parameters, especially for plotting styles (line widths), are also arrays/lists. Those lists should have the same length as the lineIdents list.
The routine uses
plot_cont()for plotting, hence a number of parameters have the same meaning as in plot_cont. They are just passed through to plot_cont).- Parameters:
model (
Data_ProDiMo) – the model datalineIdents (array_like()) – list of line ids of the form [(“ident”,wl),(“ident2”,wl2)]. wl is in micron.
field (array_like(float,ndim=2)) – a 2D array with numeric values for the plotting. E.g. any 2D array, or just the name of that field in in a
Data_ProDiMoobject.showBox (boolean) – if True (default) the box for the emitting region for each line is shown.
showRadialLines (boolean) – if True (default) than two dotted lines are shown for the z15 and z85 values at each radius. This is the main line emitting layer at each radius.
showContOrigin (boolean) – Also show the box for the continuum emitting regions (at the wavelength of the line). Default: False.
showztauD1 (boolean) – show the z_level where taudust_ver=1 for each line. For detail of this quantity see
DataLineEstimateRInfoboxcolors (array_like) – list of colors for the boxes for each line one wants to plot (should have the same number of entries as lineIdents). If not given the default colors are used.
boxlinewidths (array_like) – the widths of the line for each box showing the line origin. Can be a scalar, in that case all boxes have the same linewidth.
boxlinestyles (array_like) – the line styles for the boxes (line emitting regions). Can be a scalar, in that case all boxes have the same linestyle.
boxhatches (array_like) – if given, the origin boxes or the vertical line emitting regions (showRadialLines=True), are hatched. Hatches are the ones from matplotlib (e.g. boxhatches=[“//”]). See https://matplotlib.org/stable/gallery/shapes_and_collections/hatch_style_reference.html#hatch-style-reference for detail.
lineLabels (array_like) – list of labels for the lines. If not given the labels are generated from the lineIdents.
showLineLabels (boolean) – show the labels for the lines. Default: True.
lineLabelsFontsize (float) – fontsize for the line labels. Default: 6.0.
lineLabelsAlign (str) – alignment of the line labels. Default: left. Other options is right.
- plot_avgabun(model, species, ax=None, **kwargs)[source]
Plots the average abundance for the given species (can be more than one) as a function of radius
- plot_radial(model, values, ylabel, zidx=0, color=None, ax=None, **kwargs)[source]
Plots a quantity along the radial grid for the given zidx (from the ProDiMo Array) as a function of radius.
- Parameters:
values (array_like(float,ndim=2) or array_like(float,ndim=2)) – values is any ProDiMo 2D array in the
Data_ProDiMoobject, or a 1D array with dim nx if zidx is None.ylabel (str) – The lable for the y axis.
zidx (int) – The index of the z coordinate that should be plotted. If zidx is None the values array has to be 1D and needs to be filled with the proper values. Default: 0 (midplane)
color (str) – A matplotlib color for the line to plot. Default: None
ax (
matplotlib.axes.Axes) – A matplotlib axes object that will be use to do the actual plotting. No new instance is created. Default: None (make a new figure and axes object).
- plot_cdnmol(model, species, colors=None, styles=None, scalefacs=None, norm=None, normidx=None, ylabel='$\\mathrm{N_{ver}\\,[cm^{-2}}]$', patches=None, ax=None, **kwargs)[source]
Plots the vertical column densities as a function of radius for the given species.
- Parameters:
model (
prodimopy.read.Data_ProDiMo) – the ProDiMo model data.species (array_like(str,ndim=1)) – a list of species names that should be plotted.
scalefacs (array_like(float,ndim=1)) – scale the column density to plot by the given factor. len(scalefacs) must be equal to len(species).
norm (float) – an arbitrary normalization factor (i.e. all column density are divided by norm)
normidx (int) – normalize the plotted column densities to the column density given by normidx. Where normidx is the index of any species in the list of species in the model. TODO: Could actually just use a species name, would be easier to use.
- plot_midplane(model, field, ylabel, xRelTo=None, ax=None, **kwargs)[source]
Plots a quantitiy in in the midplane as a function of radius fieldname is any field in Data_ProDiMo
- Parameters:
xRelTo (float) – use x-xRelTo as the x axis. Default: None (no shif)
FIXME: remove the fieldname stuff passe the whole array …
- plot_abunvert(model, r, species, useZr=False, useNH=True, useT=False, scaling_fac=None, norm=None, styles=None, colors=None, markers=None, linewidths=None, ax=None, **kwargs)[source]
Plots the abundances of all the given species as a function of height at the given radius.
If useZr, useNH and useT are all False the abundances are plotted as function of z in au. By default useNH=True.
FIXME: Make the inferface consistent with plot_vert. Especially the treatment of the xaxis (i.e. what should be use to indicate the height)
- Parameters:
model (
prodimopy.read.Data_ProDiMo) – the model datar (float) – The radius at which the vertical cut is taken. UNIT: au
species (array_like(str,ndim=1) :) – List of species names to plot.
useZr (boolean) – plot the abundances as function of z/r: Default: True
useNH (boolean) – plot the abundances as function of vertical column densities Default: False
useT (boolean) – plot the abundances as function of dust temperature.
- plot_abunrad(model, species, useNH=True, norm=None, styles=None, colors=None, markers=None, linewidths=None, ax=None, **kwargs)[source]
Plots species abundances as function of radius in the midplane (z=0) Similar to
plot_abunvert()but radially is more useful for e.g. envelope structures.- Parameters:
model (
Data_ProDiMo) – the model dataspecies (array_like(str,ndim=1) :) – List of species names to plot.
useNH (boolean) – plot the abundances as function of radial column densities Default: False
norm (float) – normalize the y values by the given number (i.e. y=y/norm) Default: None (i.e. no normalisation)
- plot_abun_midp(model, species, norm=None, styles=None, colors=None, ax=None, **kwargs)[source]
Plots the abundances in the midplane for the given species (can be more than one)
- Parameters:
model (
prodimopy.read.Data_ProDiMo) – the model dataspecies (array_like(str,ndim=1) :) – List of species names to plot.
norm (float) – normalize the y values by the given number (i.e. y=y/norm) Default: None (i.e. no normalisation)
- plot_dust_opac(model, dust=None, ax=None, pseudoaniso=False, **kwargs)[source]
Plots the dust opacities (dust_opac.out) or the data given in the dust object
- Parameters:
pseudoaniso (boolean) – Use the pseudo anisotropic scattering opacity (Default: False).
- plot_opac(model, xunit='micron', ax=None, **kwargs)[source]
Plots gas and dust opacity data.
The unit is per hydrogen, to make it comparable. see Rab+ (2018) .
- Parameters:
model (Data_ProDiMo) – the model data.
xunit (str) – The unit for the x-axis. Options are eV or micron.
ax (Axes) – A matplotlib axes object that will be use to do the actual plotting. No new instance is created.
- Return type:
- plot_vertical(model, r, values, ylabel, zr=True, xfield='zr', marker=None, ax=None, **kwargs)[source]
Plots a quantity (values) as a function of height at a certain radius radius.
- valuesarray_like(float,ndim=2)
a 2D array with numeric values for the plotting. E.g. any 2D array of the
Data_ProDiMoobject.- xfieldstr
What field should be used a x-axis. Options are zr,`NHver`,`tg`,`AVver` .
FIXME: Make the inferface consistent with plot_abunvert. Especially the treatment of the xaxis (i.e. what should be use to indicate the height)
- plot_taus(model, r, ax=None, **kwargs)[source]
Plot’s taus (A_V, X-rays) as a function of vertical column density
- plot_starspec(model, step=10, xunit='micron', nuInu=True, second_xaxis=False, showInuInterpol=False, showInuBand=False, ax=None, **kwargs)[source]
Plots the full Stellar Spectrum.
- Parameters:
model (Data_ProDiMo) – The model to plot.
step (int) – only every step point is plotted from the Stellar Spectrum (makes is less dense)
xunit (str) – the unit for the x-axes. Current options are micron or eV.
nuInu (bool) – Plot \(\nu\) times \(I_\nu\) instead of \(I_\nu\) only.
second_xaxis (bool) – If True add a second x-axis showing the corresponding energy/wl in eV/micron.
showInuInterpol (bool) – If True also plot the interpolated stellar spectrum used in the radiative transfer (from RTinterpolation.out).
showInuBand (bool) – If True also plot the band-averaged stellar spectrum used in the radiative transfer (from RTinterpolation.out).
ax (Axes) – The axes object to plot the spectra on. Default: None (new figure)
- Return type:
- plot_sed(model, plot_starSpec=True, incidx=0, unit='erg', sedObs=None, reddening=False, ax=None, **kwargs)[source]
Plots the sed(s) including the stellar spectrum and observations (last two are optional).
- Parameters:
model (
Data_ProDiMo) – the model data. Only required if wl,ident and or lineObs are passed.plot_starSpec (boolean) – also show the (unobscured) stellar spectrum. Default: True
incidx (int or array_like(ndim=1)) –
which inclination (index) should be used for plotting (0 is the first one and default). If it is a single value only the profile for that inclination index is plotted.
If it is an array of values all profiles for that chosen inclinations are plotted. If incidx=[] profiles for all inclinations will be plotted. Test
unit (str) – in what unit should the sed be plotted. Possible values: erg, W, Jy, mJy
sedObs (
DataContinuumObs) – ifsedObs(e.g. sedObs=model.sedOBS) is provided also the observational data is plotted. But in principal can be any object of typeDataContinuumObs.reddening (boolean or str) – If True also apply the reddening of the SED using the given A_V value from the provided observational data (sedObs). If reddening is a string the according extinction model is used in
extinction().
- plot_sedAna(model, lams=[1.0, 3.0, 6.0, 10.0, 30.0, 60.0, 100.0, 200.0, 1000.0], field=None, label=None, boxcolors=None, zlog=True, zlim=[None, None], zr=True, clevels=None, clabels=None, extend='neither', oconts=None, nbins=70, bgcolor=None, cb_format='%.1f', scalexy=[1, 1], patches=None, rasterized=False, ax=None, **kwargs)[source]
Plots the SED analysis stuff (origin of the emission).
- Parameters:
model (
prodimopy.read.Data_ProDiMo) – the ProDiMo model.lams (array_like(float,ndim=1)) – list of wavelengths in micrometer.
field (array_like(float,ndim=2)) – And array with dimension (nx,nz) with values that should be plotted as filled contours. DEFAULT: the nHtot field of
prodimopy.read.Data_ProDiMo.
- plot_taulines(model, lineIdents, showCont=True, ax=None, **kwargs)[source]
Plots the line optical depth as a function of radius for the given lines. The lines are identified via a list of lineIdents containt of an array with ident and wavelength of the line e.g. [“CO”,1300.0]. It searches for the closest lines.
- Parameters:
model (
Data_ProDiMo) – the model datalineIdents (array_like()) – list of line identifactors of the form [[“ident”,wl],[“ident2”,wl2]].
TODO (there are no options for linestyles and colors yet (the defaults are used).)
- plot_lineprofile(model=None, wl=None, ident=None, lineObj=None, linetxt=None, lineObs=None, incidx=0, lw=None, line_styles=None, unit=None, normalized=False, convolved=False, removecont=True, style=None, color=None, ax=None, **kwargs)[source]
Plots the line profile for the given line (id wavelength and optionally the line ident)
- Parameters:
model (Data_ProDiMo | None) – The model data. Required if
wl,``ident`` and/orlineObsare passed.wl (float | None) – The wavelength of the line in micrometer. The line closest to wl is plotted.
ident (str | None) – The optional line ident which is additionally use to identify the line.
lineObj (DataLine | None) – The full line data. In that case
model,wlandidentare ignoredlinetxt (str) – A string that is used as the label for the line.
lineObs (array_like(ndim=1)) – list of
DataLineObsobjects. Must be consistent with the list of lines from the line radiative transfer.incidx (int or array_like(ndim=1)) –
which inclination (index) should be used for plotting (0 is the first one and default). If it is a single value only the profile for that inclination index is plotted.
If it is an array of values all profiles for that chosen inclinations are plotted. If normalized=True the profiles will be normalized to the first one, in that case. If incidx=[] profiles for all inclinations will be plotted.
If lineObj is passed only one inclination (the one set in that obj) will be plotted.
lw (float) – The line width of the plotted profiles. Default: None (i.e. use default value). Can be usefull for multiple inclinations plots, where the default value might be to thick.
line_styles (list[str] | str | None) – The line style of the plotted profiles. Default: None (i.e. use default value). If a scalar style is applied to all lines. If it is an array the styles are applied in order to the plotted lines (i.e. must have the same length as incidx).
unit (str) – In what unit should the line flux be plotted (see
flux_unit()). ifNonethe current unit of the line profile is used.normalized (boolean) – if True normalize the profile to the peak flux
convolved (boolean) – if True plot the convolved profile.
removecont (boolean) – if True remove the continuum from the profile. Default: True
color (str) – the color for the plotted 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.
- plot_lines(model, lineIdents, useLineEstimate=True, jansky=False, showBoxes=True, lineObs=None, lineObsLabel='Obs.', peakFlux=False, showCont=False, xLabelGHz=False, showGrid=True, **kwargs)[source]
Plots a selection of lines or lineEstimates.
See
plot_lines()for more details.- Parameters:
model (
Data_ProDiMo) – the model datalineIdents (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)
- plot_heat_cool(model, zr=True, oconts=None, showidx=(0, 0), **kwargs)[source]
Plots the dominant heating and cooling processes.
The initial python code for this routine is from Frank Backs
- Parameters:
model (
Data_ProDiMo) – the model datazr (boolean) – use z/r for y axis Default: True
oconts (array_like(
Contour,ndim=1)) – list ofContourobjects which will be drawn contours (like inplot_cont().showidx (tuple(ndim=1)) – Default is (0,0): will show the most dominant heating and cooling process. For example (1,1) will show the second most dominant heating and cooling process. For example (-1,-1) will show the least dominant heating and cooling process.
Todo
possibility to have different oconts for the heating and cooling figures
possibility to map certain heating/cooling processes always to the same color
- plot_contImage(model, wl, iinc=0, zlim=[None, None], cmap='inferno', rlim=[None, None], cb_show=True, cb_fraction=0.15, ax=None, **kwargs)[source]
Simple plot for the continuum Images as produced by PRoDiMo. (The output in image.out).
The scale is fixed to LogNorm at the moment.
- Parameters:
model (
Data_ProDiMo) – The model data.wl (float) – The wavelength in micron for which we should plot the image. The routine simple selected the closest one to the given image.
iinc (int) – the inclination index in case of multiple inclinations. Default
iinc=0zlim (array_like(ndim=1)) – the min and max value for the data to plot. Optional.
rlim (array_like(ndim=1)) – the extension of the image eg. rlim[-1,1] plot the x and y coordinate from -1 to 1 au. Optional
cmap (str) – The name of a matplotlib colormap. Optional.
cb_show (boolean) – show colorbar or not. Optional.
cb_fraction (float) – fractoin of the image use for the colorbar. Useful for subplots. Optional
- plot_sled(models, lineIdents, units='W', ax=None, title='SLED', **kwargs)[source]
Plots the Spectral Line Energy Distribution
- Parameters:
models (list(
Data_ProDiMo)) – or a single model the model(s) to plotlineIdents (array_like) –
a list of line identifiers. Examples
lineIdents = [‘CO’]
lineIdents = [‘CO’, ‘o-H2’, ‘p-H2O’]
units (str, optional) – In which units should be plotted. Allowed values: erg [erg/s/cm^2], W [W/m^2] default : W
Example
In the directory of the ProDiMo model
from matplotlib.backends.backend_pdf import PdfPages import prodimopy.plot as pplot import prodimopy.read as pread outfile = "out_test.pdf" model=pread.read_prodimo() with PdfPages(outfile) as pdf: pp=pplot.Plot(pdf, title=model.name) pp.plot_sled(model, ["CO", "o-H2"])
- plot_reac(model, chemistry, rtype, level=1, plot_size=10, lograte=True, grid=True, with_abun=False, vmin=None, **kwargs)[source]
Plots the 2D main formation/destruction reaction structure for a given species, in each grid point. Each number corresponds to the reaction indices in prodimo.read.chemistry.sorted_form_info or prodimo.read.chemistry.sorted_form_info
By default it is plotted along the 2D main formation/reaction rate structure, but it can also be plotted along the abundance of the species.
The routine checks if the reaction type is set plots the data (lograte, rate or abundance) as an image, and fills in the reaction indices for each grid point.
An index of 0 means that the total rate at that point was so low it didn’t get registered in chemanalysis.out (in ProDiMo)
Contributors: G. Chaparro, Ch. Rab
- Parameters:
model (
prodimopy.read.Data_ProDiMo) – the model datachemistry (class:prodimopy.read.Chemistry) – data resulting from prodimopy.read.analise_chemistry on a single species
rtype (str) – keyword which sets the type of reactions to be shown (destruction or formation) must be set to either ‘d’ (destruction) or ‘f’ (formation)
level (int) – 1 means most important, 2 second most important etc.
plot_size (int) – plot size, it is set to square for now
lograte (bool) – plot log rate instead of rate, default to True (the difference are more noticeable)
grid (bool) – plot nx,ny instead of r, z, default to False
with_abun (bool) – plot abundance instead of formation or destruction rate, overrides lograte, default to False
vmin (float) – sets the minimum value for plt.imshow (abundance, rate or lograte) default min(array)
- class prodimopy.plot.Contour(field, levels, colors='white', linestyles='solid', linewidths=1.5, showlabels=False, label_locations=None, label_fmt='%.1f', label_fontsize=7, label_inline_spacing=5, filled=False)[source]
Bases:
objectDefine a contour line that can be used in the contour plotting routines. Something like the visual exctinction of unity in a plot for the 2D dust temperature distribution. Objects of this class can be passed to e.g. the
plot_cont()routine and will be drawn their.Example
# define some contours for the dust temperature tdcont=Contour(model.td,[10,20,30,100]) # we also want to show the AV=1 line avcont=Contour(model.AV,[1],color="red",showlabels=True,label_fmt=r"A$_V$=%1.0f") # use them with plot_cont pp.plot_cont(model, "td", oconts=[tdcont,avcont])
Todo
provide a field for label strings (arbitrary values) need to be the same size as levels
- field: ndarray[tuple[int, ...], dtype[float64]]
A 2D array of values used for the Contours. Needs to have the same dimensions as the array used for the contour plotting routine. So any 2D array of the
Data_ProDiMowill do.
- levels: list[float]
list of values for which contour lines should be drawn.
- colors: str | list[str]
List of colors for the idividual contours. If only a single value is provided (i.e. no array/list) this value is applied to all contours. The values of colors can be given in the syntax as for matplotlib.
- linestyles: str | list[str]
Linestyles for the contours. Works like the colors parameter. Any style that matplotlib understands will work.
- linewidths: float | list[float]
linewidths for the individual contour levels. Works like the colors parameter.
- showlabels: bool
show text label for each level or not
- label_locations: list[tuple[float, float]] | None
Locations for the labels if shown. If None, default locations are used e.g. [(0.3,2),(0.4,2)].
- label_fmt: str
Format string for the labels if shown, e.g.
r"A$_V$=%1.0f"
- label_fontsize: float
The fontsize of the contour level label if enabled
- label_inline_spacing: float
Control the space around the contour label (i.e. if it overlaps with the line)
- filled: bool
Use filled contours (contourf) instead of lines. Can be usefull sometimes. But not supported everywhere (just try).
- prodimopy.plot.getField2D(model, fieldname, label='value', log=True)[source]
Returns quantity with name
fieldnamefrom model.- Parameters:
model (The model to get the field from.)
fieldname (The name of the field to get.)
label (The label to use for the field.)
log (Include log in label or not.)
- Returns:
values (The values of the field from the model.)
label (The label for the field)
zmin (The default value for
zminto be used e.g. inplot_cont())
- Return type:
tuple[ndarray, str, float]
- prodimopy.plot.mapField(fieldname, log=True)[source]
Maps a field/attribute name from
Data_ProDiMoto a nice label for the plotting. Please note the labels do not include mathrm or similar things. It is recommended to use a matplotlib style file for this. E.g. mathtext.default : regular or simply use the prodimopy style file.- Parameters:
fieldname (str) – The field name of a quantity in
Data_ProDiMo.log (boolean) – If True the label is prepended with log. Default: True
- Returns:
str (The label for the field, or the passed fieldname if no mapping is found.)
float (The default min value for the contour plot)
- Return type:
tuple[str, float]
- prodimopy.plot.spnToLatex(spname)[source]
Utilitiy function to convert species names to proper latex math strings.
The returned string can directly be embedded in a latex $ $ statement.
- prodimopy.plot.reacToStr(reaction)[source]
Builds a string representation for a reactions. Usefull to put it on plots or in legends.
- Parameters:
reaction (Reaction)
- Return type:
str
- prodimopy.plot.scale_figs(scale)[source]
Scale the figure size from matplotlibrc by the factors given in the array scale the first element is for the width the second for the heigth.
- prodimopy.plot.load_style(style='prodimopy')[source]
Simple wrapper that calls
load_mplstyle()with the given style.- Parameters:
style (str) – The name of the style to load. Default: “prodimopy”