temet.plot

Plotting routines.

temet.plot.cloudy

Diagnostic and production plots based on CLOUDY photo-ionization models.

plotUVB(uvb='FG11')

Debug plots of the UVB(nu) as a function of redshift.

plotIonAbundances(res='lg_c17', elements=('Magnesium',))

Debug plots of the cloudy element ion abundance trends with (z,dens,Z,T).

grackleTable()

Plot Grackle cooling table.

gracklePhotoCrossSec(uvb='FG11')

Plot the photo-ionization cross sections from Grackle. Compare to new derivation.

grackleReactionRates()

Plot the photo-ionization cross sections from Grackle. Compare to new derivation.

uvbEnergyDens()

Plot the UVB energy density as a function of redshift, integrating over some frequency ranges.

ionAbundFracs2DHistos(saveName, element='Oxygen', ionNums=(6, 7, 8), redshift=0.0, metal=-1.0)

Plot 2D histograms of ion abundance fraction in (density,temperature) space at one Z,z.

Metal is metallicity in [log Solar].

temet.plot.clustering

Plots related to galaxy clustering statistics, two-point correlation functions, and conformity.

galaxyTwoPoint(sPs, cenSatSelects=('all', 'cen', 'sat'), colorBin=None, cType=None, mstarBin=None, mType=None)

Plot the galaxy two-point correlation function for a run or multiple runs.

galaxyTwoPointQuantBounds(sPs, cenSatSelect='all', ratioSubPlot=False, colorBins=None, cType=None, mstarBins=None, mType=None, redshiftBins=None)

Plot the galaxy two-point correlation function for a run or multiple runs.

Show a range of bins in either color, stellar mass, or redshift (choose one).

conformityWithRedFrac(sP, cenSatSelectSec='all')

Plot the galaxy two-point correlation function for a run or multiple runs.

Show a range of bins in either color, stellar mass, or redshift (choose one). NOTE: Conformity analysis incomplete (need to reconcile with Bray+/Illustris).

temet.plot.config

Global plot-related configuration which can be imported into other plotting submodules.

temet.plot.cosmoMisc

Misc plots related to cosmological boxes.

plotRedshiftSpacings()

Compare redshift spacing of snapshots of different runs.

plotMassFunctions()

Plot DM halo and stellar mass functions comparing multiple boxes, at one redshift.

haloMassesVsDMOMatched()

Plot the ratio of halo masses matched between baryonic and DMO runs.

simClustersComparison(masslimit='15')

Meta plot: place TNG-Cluster into its context of (N_clusters,resolution) for similar simulations.

Parameters:

masslimit (str) – ‘14’, ‘14.5’, or ‘15’

simResolutionVolumeComparison()

Meta plot: place TNG50 into its context of (volume,resolution) for cosmological simulations.

simHydroResolutionComparison()

Meta plot: compare total volume at a given spatial hydro discretization (cell size) between simulations.

simHydroResolutionProfileComparison(onlyCold=False, ckpc=False)

Meta plot: compare radial profiles of resolution (cell size) between simulations.

compareEOSFiles(doTempNotPres=False)

Compare eos.txt files from different runs (in eosFiles), and actual runs as well (in sPs).

simHighZComparison()

Meta plot: place MCST into its context of (res,halo mass) similar simulations.

temet.plot.drivers

Drivers (i.e. examples) of plots using the generalized functionality.

plots()

Exploration of 2D histograms, vary over all known quantities as cQuant.

plots_explore(sP)

Exploration of 2D histograms, vary over all known quantities as y-axis.

plots2()

Exploration of 1D slices.

plots3()

Exploration of median trends.

plots4()

Single median trend.

plots5()

Single median trend over multiple redshifts.

plots_uvj()

Explore UVJ color-color diagram.

plots_tng50_structural(rel=False, sP=None)

Exploration of 2D histograms.

compareRuns_PhaseDiagram()

Compare a series of runs in a PDF booklet of phase diagrams.

oneRun_PhaseDiagram(redshift=None, snaps=None, hInd=10677, res=13, variant='ST7')

Density temperature phase diagram for a single halo or full box, over multiple snapshots.

oneRun_tempcheck()

Driver.

compareRuns_RadProfiles()

Compare median radial profile of a quantity, differentiating between two runs.

compareHaloSets_RadProfiles()

Compare median radial profile of a quantity, differentiating between two different types of halos. One run.

compareHaloSets_1DHists()

Compare 1D histograms of a quantity, overplotting several halos. One run.

singleHaloProperties()

Several phase/radial profile plots for a single halo.

compareRuns_particleQuant()

Compare a series of runs in a single panel plot of a particle median quantity vs another.

coolingPhase()

Phase diagram colored by different quantities.

temet.plot.driversObs

Summary plots comparing one or more cosmological simulations to observational constraints.

Includes the usual comparisons such as stellar to halo mass ratio (SMHM), the stellar mass function (SMF), and so on.

stellarMassHaloMass(sPs, pdf, ylog=False, allMassTypes=False, use30kpc=False, simRedshift=0.0, dataRedshift=0.0)

Stellar mass vs. halo mass relation.

sfrAvgVsRedshift(sPs, pdf)

Average SFRs in some halo mass bins vs. redshift vs. abundance matching lines.

sfrdVsRedshift(sPs, pdf, xlog=True, addSubhalosOnly=False)

Star formation rate density of the universe, vs redshift, vs observational points.

blackholeVsStellarMass(sPs, pdf, twiceR=False, vsHaloMass=False, vsBulgeMass=False, actualBHMasses=False, actualLargestBHMasses=True, simRedshift=0.0, sizefac=1.0, xlim=None, ylim=None)

Black hole mass vs. stellar (bulge) mass relation at z=0.

stellarMassFunction(sPs, pdf, highMassEnd=False, centralsOnly=False, use30kpc=False, use30H=False, useP10=False, haloMasses=False, s850fluxes=False, simRedshift=0.0, dataRedshift=0.0)

Stellar mass function (number density of galaxies) at redshift zero, or above.

HIMassFunction(sPs, pdf, centralsOnly=True, simRedshift=0.0)

HI mass function (number density of HI masses) at redshift zero.

HIMassFraction(sPs, pdf, centralsOnly=True, simRedshift=0.0)

HI mass fraction (M_HI/M*) vs M* at redshift zero.

HIvsHaloMass(sPs, pdf, simRedshift=0.0)

HI mass (M_HI) vs M_halo at redshift zero.

massMetallicityStars(sPs, pdf, simRedshift=0.0, sdssFiberFits=False)

Stellar mass-metallicity relation at z=0.

massMetallicityGas(sPs, pdf, simRedshift=0.0)

Gas mass-metallicity relation at z=0.

baryonicFractionsR500Crit(sPs, pdf, simRedshift=0.0)

Gas, star, and total baryonic fractions within r500_crit (for massive systems).

nHIcddf(sPs, pdf, moment=0, simRedshift=3.0, molecular=False)

CDDF (column density distribution function) of neutral (atomic) hydrogen, in the whole box.

dlaMetallicityPDF(sPs, pdf, simRedshift=3.0)

Metallicity distribution of Damped Lyman-alpha Absorbers (DLAs; N_HI>20.3), using whole box grids.

velocityFunction(sPs, pdf, centralsOnly=True, simRedshift=0.0)

Velocity function (galaxy counts as a function of v_circ/v_max).

stellarAges(sPs, pdf, centralsOnly=False, simRedshift=0.0, sdssFiberFits=False)

Luminosity or mass weighted stellar ages, as a function of Mstar (Vog 14b Fig 25).

haloXrayLum(sPs, pdf=None, xlim=(10, 12), ylim=(38, 45), bolometric=False)

X-ray luminosity scaling relation vs stellar mass. Bolometric or 0.5-2 keV soft band.

haloSynchrotronPower(sPs, pdf=None, xlim=(12.5, 15.5), ylim=(19, 26))

Halo total synchrotron power at 1.4 Ghz (VLA configuration) vs M500.

plots()

Plot portfolio of global population comparisons between runs.

temet.plot.driversSizes

Plots of galaxy sizes, half mass and half light radii.

galaxySizes(sPs, vsHaloMass=False, simRedshift=0.0, addHalfLightRad=None, sizefac=1.0, scatterPoints=False, markersize=12.0, xlim=None, ylim=None, pdf=None)

Galaxy sizes (half mass radii) vs stellar mass or halo mass, compared to data.

Parameters:
  • sPs (simParams or list) – simulation instance(s).

  • vsHaloMass (bool) – plot versus halo mass instead of stellar mass.

  • simRedshift (float) – plot simulations at this redshift instead of sP.redshift.

  • addHalfLightRad (tuple) – if not None, then a 3-tuple [dustModel,band,show3D] e.g. [‘p07c_cf00dust_res_conv_efr_rad30pkpc’,’sdss_r’,False].

  • sizefac (float) – figure size scaling factor.

  • scatterPoints (bool) – include all raw points with a scatterplot.

  • markersize (float) – if scatterPoints then override the default marker size.

  • xlim (2-tuple) – plot x-limits.

  • ylim (2-tuple) – plot y-limits.

  • pdf (PdfPages or None) – if None, an actual PDF file is written to disk with the figure. If not None, then the figure is added to this existing pdf collection.

galaxyHISizeMass(sPs, pdf, simRedshift=0.0)

Galaxy HI size-mass relation, at redshift zero.

sizeModelsRatios()

Look at calculated HalfLightRadii, plot ratios to evaluate impact of dust.

lumModelsRatios(res=1820, run='tng', redshifts=(0.0,))

Look at calculated StellarPhot, plot ratios to evaluate impact of dust.

clumpSizes(sP)

Galaxy sizes of the very small things vs stellar mass or halo mass, at redshift zero.

characteristicSizes(sP, vsHaloMass=False)

Compare many different ‘characteristic’ halo/galaxy sizes as a function of mass.

temet.plot.gasflows

Plots of galaxy/halo-scale gas flow rates, velocities, and related properties.

outflowRates(sP, ptType, xQuant='mstar_30pkpc', eta=False, config=None, massField='Masses', v200norm=False, f_post=None)

Plot radial mass flux (single value per galaxy) as a function of stellar mass or other galaxy properties.

outflowRatesVsRedshift(sP, ptType, eta=False, config=None, massField='Masses', v200norm=False)

Plot radial mass fluxes (single value per galaxy) as a function of redshift (for bins of other gal props).

outflowVel(sP_in, xQuant='mstar_30pkpc', ylog=False, redshifts=(None,), config=None, massField='Masses', proj2D=False, v200norm=False, f_post=None)

Plot outflow velocity (single value per galaxy) versus stellar mass or other gal/halo properties.

If massField is not ‘Masses’, then e.g. the ion mass (‘SiII’, ‘MgII’) to use to compute massflux-weighted outflow velocities. If proj2D, then line-of-sight 1D projected velocities are computed in the down-the-barrel treatment, instead of the usual 3D radial velocities.

outflowRatesStacked(sP_in, quant, mStarBins, redshifts=(None,), config=None, inflow=False, f_post=None)

Plot radial mass flux as a function of a histogrammed quantity, for single or stacked galaxies.

Binning in stellar mass. Optionally at multiple redshifts.

outflowRates2DStacked(sP_in, xAxis, yAxis, mStarBins, redshifts=(None,), clims=([-3.0, 2.0],), config=None, eta=False, rawMass=False, rawDens=False, discreteColors=False, contours=None, v200norm=False)

Explore radial mass flux data, 2D panels where color indicates Mdot_out.

Give clims as a list, one per mStarBin, or if just one element, use the same for all bins. If config is None, generate many exploration plots, otherwise just create the single desired plot. If eta is True, plot always mass-loadings instead of mass-outflow rates. if rawMass is True, plot always total mass, instead of mass-outflow rates. if rawDens i True, plot always total mass density, instead of mass-outflow rates. If discreteColors is True, split the otherwise continuous colormap into discrete segments.

temet.plot.meta

Non-science and other meta plots.

plotUsersData()

Parse and plot a user data dump from the Illustris[TNG] public data release website.

plotNumPublicationsVsTime()

Compare the number of publications vs time for various projects.

plotCpuTimeEstimates()

Plot predicted total CPUh and finish date, as a function of prediction date, given the plotCpuTimes() log.

periodic_slurm_status(machine='vera', nosave=False)

Collect current statistics from the SLURM scheduler, save some data, make some plots.

temet.plot.perf

Performance, scaling and timings analysis.

plotCpuTimes(sims=None, xlim=(0.0, 1.0))

Plot code time usage fractions from cpu.txt.

plotTimebins()

Plot analysis of timebins throughout the course of a run.

plotTimebinsFrame(pStyle='white', conf=0, timesteps=None)

Plot analysis of timebins at one timestep.

scalingPlots()

Strong (fixed problem size) and weak (Npart scales w/ Ncores) scaling plots.

temet.plot.quantities

Metadata and default plotting hints (labels, bounds, units) for group catalog and particle/cell-level quantities.

bandMagRange(bands, sim=None)

Hard-code some band dependent magnitude ranges.

quantList(wCounts=True, wTr=True, wMasses=False, onlyTr=False, onlyBH=False, onlyMHD=False, alwaysAvail=False)

Return a list of quantities (galaxy properties) which we know about for exploration.

Note that the return of this function, with alwaysAvail == True, is used to populate the available fields of the ‘Plot Galaxy/Halo Catalogs’ web interface on the TNG website.

simSubhaloQuantity(sP, quant)

Load requested quantity, one value per subhalo, and associated metadata.

Parameters:
  • sP (simParams) – simulation instance.

  • quant (str) – name of the subhalo property to load.

Returns:

  • ndarray: a 1D vector of size Nsubhalos, one quantity per subhalo as specified by the string

  • label: appropriate label for plotting.

  • minMax: 2-tuple of (min,max) values for plotting limits.

  • log: boolean, whether log10 of the return values should always be taken.

Return type:

tuple(4)

simParticleQuantity(sP, ptType, ptProperty, haloLims=False, u=False)

Return meta-data for a given particle/cell property, as specified by the tuple (ptType,ptProperty).

Our current unit system is built around the idea that this same tuple passed unchanged to snapshotSubset() will succeed and return values consistent with the label and units.

Parameters:
  • sP (simParams) – simulation instance.

  • ptType (str) – e.g. [0,1,2,4] or (‘gas’,’dm’,’tracer’,’stars’).

  • ptProperty (str) – the name of the particle-level field.

  • haloLims (bool) – if True, adjust limits for the typical values of a halo instead of typical values for a fullbox.

  • u (bool) – if True, return the units string only.

Returns:

label, lim, log

Return type:

tuple

temet.plot.snapshot

Generalized plotting of particle/cell-level data from snapshots.

histogram1d(sPs, ptType='gas', ptProperty='temp', ptWeight=None, subhaloIDs=None, haloIDs=None, ylog=True, ylim=None, xlim=None, qRestrictions=None, nBins=400, medianPDF=False, legend=True, ctName=None, ctProp=None, colorbar=False, pdf=None, saveFilename=None)

Simple 1D histogram/PDF of some quantity, for the whole box or one or more halos/subhalos.

Parameters:
  • sPs (list[simParams]) – list of simulation instances.

  • ptType (str) – particle type, e.g. ‘gas’,’dm’,’stars’.

  • ptProperty (str) – particle property to histogram, e.g. ‘temp’,’density’,’metallicity’.

  • ptWeight (str or None) – if None then uniform weighting, otherwise weight by this quantity.

  • subhaloIDs (list[int] or None) – list of subhalo IDs, either one ID, one list of IDs, or a list of lists of IDs, per sP. If specified, haloIDs must be None. If both are None, then histogram all particles/cells in the box.

  • haloIDs (list[int] or None) – list of halo IDs, either one ID, one list of IDs, or a list of lists of IDs, per sP. If specified, subhaloIDs must be None. If both are None, then histogram all particles/cells in the box.

  • ylog (bool) – if True, then log-scale the y-axis.

  • ylim (2-tuple,str,or None) – if None, use automatic limits based on data.

  • xlim (2-tuple or None) – if None, use automatic limits based on data.

  • qRestrictions – a list containing 3-tuples, each of [fieldName,min,max], to restrict all points by.

  • nBins (int) – number of bins to use.

  • ylim – If ‘auto’, then autoscale. Otherwise, 2-tuple to use as limits.

  • medianPDF (bool or str) – add this mean (per sP) on top. If ‘only’, then skip the individual objects.

  • legend (bool) – if True, add a legend.

  • ctName (str or None) – If ctName not None, sample from this colormap to choose line color per object.

  • ctProp (str) – use this property to assign colors.

  • colorbar (bool) – if not False, then use this field (string) to display a colorbar mapping.

  • pdf (PdfPages or None) – if not None, then save to this multipage PDF object.

  • saveFilename (str or None) – if not None, save the figure to this filename. Automatic if None.

phaseSpace2d(sP, partType='gas', xQuant='numdens', yQuant='temp', weights=('mass',), meancolors=None, haloIDs=None, xlim=None, ylim=None, clim=None, contours=None, contourQuant=None, normColMax=False, hideBelow=False, ctName='viridis', colorEmpty=False, smoothSigma=0.0, nBins=None, qRestrictions=None, median=False, normContourQuantColMax=False, addHistX=False, addHistY=False, colorbar=True, f_pre=None, f_post=None, saveFilename=None, pdf=None)

Plot a 2D phase space plot (arbitrary values on x/y axes), for a list of halos, or for an entire box.

weights is a list of the gas properties to weight the 2D histogram by, if more than one, a horizontal multi-panel plot will be made with a single colorbar. Or, if meancolors is not None, then show the mean value per pixel of these quantities, instead of weighted histograms. If xlim,ylim,clim specified, then use these bounds, otherwise use default/automatic bounds. If contours is not None, draw solid contours at these levels on top of the 2D histogram image. If contourQuant is None, then the histogram itself (or meancolors) is used, otherwise this quantity is used. if normColMax, then normalize every column to its maximum (i.e. conditional 2D PDF). If normContourQuantColMax, same but for a specified contourQuant. If f_pre, f_post are not None, then these are ‘custom’ functions accepting the axis as a single argument, which are called before and after the rest of plotting, respectively. If addHistX and/or addHistY, then int, specifies the number of bins to add marginalized 1D histogram(s). If hideBelow, then pixel values below clim[0] are left pure white. If colorEmpty, then empty/unoccupied pixels are colored at the bottom of the cmap. If smoothSigma is not zero, gaussian smooth contours at this level. If qRestrictions, then a list containing 3-tuples, each of [fieldName,min,max], to restrict all points by. If median, add a median line of the yQuant as a function of the xQuant.

median(sPs, partType='gas', xQuant='hdens', yQuant='temp', haloIDs=None, radMinKpc=None, radMaxKpc=None, xlim=None, ylim=None, nBins=50, legendLoc='best', total=False, totalCum=False, totalCumBoundsX=None, totalCumRangeX=None, totalCumLog=False, sizefac=1.0, f_pre=None, f_post=None)

Plot the relationship between two particle/cell properties, for the full box or one or more (sets of) halos.

Parameters:
  • sPs (list[simParams]) – list of simulation instances.

  • partType (str) – particle type, e.g. ‘gas’, ‘dm’, ‘star’, etc.

  • xQuant (str) – particle property for the x-axis.

  • yQuant (str) – particle property for the y-axis.

  • haloIDs (list[int or list or dict]) – one entry per sPs entry. For each entry, if haloIDs[i] is a single halo ID number, then one halo only. If a list, then median relation. If a dict, then k:v pairs where keys are a string description, and values are haloID lists, which are then overplotted. This is the same behavior as profilesStacked1d().

  • radMinKpc (float) – if by-halo loading, optionally restrict to radii above this value (physical kpc).

  • radMaxKpc (float) – above, optionally restrict to radii below this value (physical kpc). (Can generalize to qRestrictions approach).

  • xlim (list[float]) – x-axis limits. If None, use default/automatic.

  • ylim (list[float]) – y-axis limits. If None, use default/automatic.

  • nBins (int) – number of bins in xQuant to use.

  • legendLoc (str) – legend location string, passed to matplotlib.

  • total (bool) – plot the total sum, instead of the (otherwise default) median.

  • totalCum (bool) – plot the total cumulative sum, in ascending x-axis bins.

  • totalCumBoundsX (list) – If not None, then should be a 2-tuple [min,max] within which to -exclude- bins of the xQuant in the cumulative calculation.

  • totalCumRangeX (list[float]) – if totalCum, then this gives the x-quantity range to include.

  • totalCumLog (bool) – controls whether the y-axis is in linear or log.

  • sizefac (float) – overrides the default plot sizefac.

  • f_pre (function) – if not None, this ‘custom’ function hook is called just before plotting. It must accept the figure axis as its single argument.

  • f_post (function) – if not None, this ‘custom’ function hook is called just after plotting. It must accept the figure axis as its single argument.

Returns:

None. Produces a PDF figure in the current directory.

profilesStacked1d(sPs, subhaloIDs=None, haloIDs=None, ptType='gas', ptProperty='temp', op='mean', weighting=None, ptRestrictions=None, nBins=50, proj2D=None, xlim=None, ylim=None, plotMedian=True, indiv=False, ctName=None, ctProp=None, colorbar=False, saveFilename=None)

Radial profile(s) of some quantity vs. radius for halos (FoF-scope, using non-caching auxCat functionality).

subhaloIDs is a list, one entry per sPs entry. For each entry of subhaloIDs: If subhaloIDs[i] is a single subhalo ID number, then one halo only. If a list, then median stack. If a dict, then k:v pairs where keys are a string description, and values are subhaloID lists, which are then overplotted. sPs supports one or multiple runs to be overplotted. If haloIDs is not None, then use these FoF IDs as inputs instead of Subfind IDs. ptType and ptProperty specify the quantity to bin, and op (mean, sum, min, max) the operation to apply in each bin. If ptRestrictions, then a dictionary containing k:v pairs where k is fieldName, v is a 2-tuple [min,max], to restrict all cells/particles by, e.g. sfrgt0 = {‘StarFormationRate’:[‘gt’,0.0]}, sfreq0 = {‘StarFormationRate’:[‘eq’,0.0]}. if proj2D is not None, then a 2-tuple as input to subhaloRadialProfile(). If plotMedian is False, then skip the average profile. if indiv, then show individual profiles, and in this case: If ctName is not None, sample from this colormap to choose line color per object. Assign based on the property ctProp. If colorbar is not False, then use this field (string) to display a colorbar mapping.

profile(sPs, ptType='gas', ptProperty='temp', subhaloIDs=None, haloIDs=None, xlog=True, xlim=None, ylog=None, ylim=None, sfreq0=False, scope='fof')

Radial profile of some quantity vs. radius from a halo, one per simulation (i.e. for zooms).

subhaloIDs (or haloIDs) is an ID list with one entry per sPs entry. If haloIDs is not None, then use these FoF IDs as inputs instead of Subfind IDs. Scope can be: global, fof, subfind.

profilesStacked2d(sim, ptType='gas', ptProperty='temp', subhaloID=None, haloID=None, rlog=True, rlim=None, clog=None, clim=None, sfreq0=False, max_z=20.0, scope='fof', ctName='viridis')

2D stacked radial profile of some quantity vs. distance, for one halo, as a function of time (temporal-spatial).

Tracking through time is based on the merger tree MPB.

Parameters:
  • sim (simParams) – simulation object.

  • ptType (str) – particle type, e.g. ‘gas’.

  • ptProperty (str) – particle property, e.g. ‘temp’.

  • subhaloID (int) – subhalo ID.

  • haloID (int) – if not None, then use these FoF IDs as inputs instead of Subfind IDs.

  • rlog (bool) – log distance axis.

  • rlim (list[float]) – 2-tuple of distance axis limits.

  • clog (bool) – log color axis.

  • clim (list[float]) – 2-tuple of color (ptProperty) axis limits.

  • sfreq0 (bool) – restrict to non-eEOS cells (only).

  • max_z (float) – maximum redshift to include in the plot.

  • scope (str) – ‘global’, ‘fof’, ‘subfind’.

  • ctName (str) – colormap name for the 2D plot.

profileEvo2d(sPs, ptType='gas', ptProperty='temp', ylim=(0.0, 2.0), median=True, cLog=True, clim=(-1.0, 0.5), cNormQuant='virtemp', smoothSigma=2.0, xQuant='mhalo_200_log', xlim=(9.0, 15.0), xbinsize=None, ctName='viridis')

2D Stacked radial profile(s) of some quantity vs. radius from (all) halos.

(spatial_global based, using caching auxCat functionality, restricted to >1000 dm particle limit). Note: Combination of {ptType,ptProperty} must already exist in auxCat mapping. xQuant and xlim specify x-axis (per subhalo) property, by default halo mass, binned by xbinsize. ylim specifies radial range, in linear rvir units. cLog specifies whether to log the color quantity, while clim (optionally) gives the colorbar bounds. If cNormQuant is not None, then normalize the profile values -per halo- by this subhalo quantity, e.g. ‘tvir’ in the case of ptProperty==’temp’. If smoothSigma > 0 and cNormQuant is not None, use this smoothing to contour unity values.

temet.plot.subhalos

Generalized plots based on group catalog objects (i.e. subhalos) of cosmological boxes.

addRedshiftAxis(ax, sP, zVals=(0.0, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0))

Add a redshift axis as a second x-axis on top (assuming bottom axis is Age of Universe [Gyr]).

addUniverseAgeAxis(ax, sP, ageVals=(0.7, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 9.0))

Add a age of the universe [Gyr] axis as a second x-axis on top (assuming bottom is redshift).

addRedshiftAgeAxes(ax, sP, xrange=(-0.0001, 8.0), xlog=True)

Add bottom vs. redshift (and top vs. universe age) axis for standard X vs. redshift plots.

histogram2d(sP, yQuant, xQuant='mstar2_log', cenSatSelect='cen', cQuant=None, xlim=None, ylim=None, clim=None, cStatistic=None, cNaNZeroToMin=False, minCount=None, cRel=None, cFrac=None, nBins=None, qRestrictions=None, filterFlag=False, medianLine=True, sizeFac=1.0, pStyle='white', ctName=None, saveFilename=None, output_fmt=None, pdf=None)

Make a 2D histogram comparing two subhalo properties, optionally coloring by a third.

minCount specifies the minimum number of points a bin must contain to show it as non-white. If ‘_nan’ is not in cStatistic, then by default, empty bins are white, and bins whose cStatistic is NaN (e.g. any NaNs in bin) are gray. Or, if ‘_nan’ is in cStatistic, then empty bins remain white, while the cStatistic for bins with any non-NaN values is computed ignoring NaNs (e.g. np.nanmean() instead of np.mean()), and bins which are non-empty but contain only NaN values are gray. If cRel is not None, then should be a 3-tuple of [relMin,relMax,takeLog] in which case the colors are not of the physical cQuant itself, but rather the value of that quantity relative to the median at that value of the x-axis (e.g. mass). If cFrac is not None, then a 4-tuple of [fracMin,fracMax,takeLog,label] specifying a criterion on the values of cQuant such that the colors are not of the physical cQuant itself, but rather represent the fraction of subhalos in each pixel satisfying (fracMin <= cQuant < fracMax), where +/-np.inf is allowed for one-sided, takeLog should be True or False, and label is either a string or None for automatic. If qRestrictions, then a list containing 3-tuples, each of [fieldName,min,max], to restrict all points by. If filterFlag, exclude SubhaloFlag==0 (non-cosmological) objects. If xlim, ylim, or clim are not None, then override the respective axes ranges with these [min,max] bounds. If cNanZeroToMin, then change the color of the NaN-only bins from the usual gray to the colormap minimum.

slice(sPs, xQuant, yQuants, sQuant, sRange, cenSatSelect='cen', yRel=None, xlim=None, ylim=None, filterFlag=False, sizefac=None, saveFilename=None, pdf=None)

Make a 1D ‘slice’ showing the dependence of one quantity on another, for subhalos selected by a range in a third.

This can be thought of as a slice through the 2D histogram by restricting to some range sRange of some quantity sQuant which is typically Mstar (e.g. 10.4<log_Mstar<10.6 to slice in the middle of the bimodality).

Supports multiple sPs which are overplotted. For all subhalos in this slice, optically restricted by cenSatSelect, load a set of quantities yQuants (could be just one) and plot this (y-axis) against xQuant, with any additional configuration provided by xQuantSpec. Multiple yQuants results in a grid. If xlim or ylim are not None, then override the respective axes ranges with these [min,max] bounds. If sRange is a list of lists, then overplot multiple different slice ranges. If yRel is not None, then should be a 3-tuple of [relMin,relMax,takeLog] or 4-tuple of [relMin,relMax,takeLog,yLabel] in which case the y-axis is not of the physical yQuants themselves, but rather the value of the quantity relative to the median in the slice (e.g. mass). If filterFlag, exclude SubhaloFlag==0 (non-cosmological) objects.

median(sPs, yQuants, xQuant, cenSatSelect='cen', sQuant=None, sLowerPercs=None, sUpperPercs=None, sizefac=1.0, alpha=1.0, nBins=50, qRestrictions=None, indivRestrictions=False, f_pre=None, f_post=None, xlabel=None, ylabel=None, lowessSmooth=False, scatterPoints=None, markersize=6.0, maxPointsPerDex=None, scatterColor=None, ctName=None, markSubhaloIDs=None, cRel=None, mark1to1=False, drawMedian=True, medianLabel=None, extraMedians=None, legendLoc='best', labelSims=True, xlim=None, ylim=None, clim=None, cbarticks=None, filterFlag=False, colorbarInside=False, saveFilename=None, pdf=None)

Plot the running median (optionally with scatter points) of some quantity vs another for all subhalos.

Parameters:
  • sPs (simParams or list) – simulation instance(s).

  • yQuants (str or list[str]) – names of quantities (could be just one) to plot on the y-axis. Multiple yQuants results in a grid of panels.

  • xQuant (str) – name of quantity to plot on the x-axis.

  • cenSatSelect (str) – restrict subhalo sample to one of ‘cen’, ‘sat’, or ‘all’.

  • sQuant (str or None) – if not None, then in addition to the median, load this third quantity and split the subhalos on it according to (mandatory) sLowerPercs and sUpperPercs. Each such split adds another median line derived from that sub-sample alone.

  • sLowerPercs (tuple[float][2]) – a list of percentiles (e.g. [16,84]), to split the sample on.

  • sUpperPercs (tuple[float][2]) – a list of percentiles (e.g. [16,84]), to split the sample on.

  • sizefac (float) – overrides the default plot sizefac.

  • alpha (float) – controls only the scattered points (if plotted).

  • nBins (int) – number of bins along the x-axis quantity for computing the median lines.

  • qRestrictions (list) – one or more 3-tuples, each containing [fieldName,min,max], which are then used to restrict all points by.

  • indivRestrictions (bool) – if True, then each item in qRestrictions is applied independently, and added to the plot, otherwise all are applied simultaneously and only one sample is shown.

  • f_pre (function) – if not None, this ‘custom’ function hook is called just before plotting. It must accept the figure axis as its single argument.

  • f_post (function) – if not None, this ‘custom’ function hook is called just after plotting. It must accept the figure axis as its single argument.

  • xlabel (str) – if not None, override x-axis label.

  • ylabel (str) – if not None, override y-axis label.

  • lowessSmooth (bool) – smooth the resulting color distribution (slow for large number of points).

  • scatterPoints (bool) – include all raw points with a scatterplot.

  • markersize (float) – if scatterPoints then override the default marker size (of 6).

  • maxPointsPerDex (int) – if not None, then randomly sub-sample down to at most this number (equal number per 0.1 dex bin) as a maximum, to reduce confusion at the low-mass end.

  • scatterColor (str) – color each point by a third property.

  • ctName (str or list) – if not None, then specify a different colormap name to use for the points or medians. If a list, then the first entry should be the string name, while the second should be a bounds 2-tuple.

  • markSubhaloIDs (bool) – highlight these subhalos especially on the plot.

  • cRel – if not None, then should be a 3-tuple of [relMin,relMax,takeLog] in which case the colors are not scatterColor itself, but the value of that quantity relative to the median at that value of the x-axis (e.g. mass).

  • mark1to1 (bool) – show a 1-to-1 line (i.e. assuming x and y axes could be closely related).

  • drawMedian (bool) – include median line and 1-sigma band.

  • medianLabel (str) – if not None, then override the median label with this string.

  • extraMedians (list[str]) – if not None, add more median lines for these (y-axis) quantities as well.

  • legendLoc (str) – override ‘best’ default location. None to disable legend.

  • labelSims (bool) – if True, then label each simulation (of sPs) in the legend.

  • xlim (list[float][2]) – if not None, override default x-axis limits.

  • ylim (list[float][2]) – if not None, override default y-axis limits.

  • clim (list[float][2]) – if not None, override default colorbar limits.

  • cbarticks (list[float]) – if not None, override automatic colorbar tick values.

  • filterFlag (bool) – if True, exclude SubhaloFlag==0 (non-cosmological) objects.

  • colorbarInside (bool) – place colorbar (assuming scatterColor is used) inside the panel.

  • saveFilename (str) – name (and extension, setting format) of output plot. Automatic if None.

  • pdf (PdfPages or None) – if None, an actual PDF file is written to disk with the figure. If not None, then the figure is added to this existing pdf collection.

Returns:

None. PDF figure is saved in current directory, or added to pdf if input.

temet.plot.subhalos_evo

Generalized plots following group catalog objects (i.e. subhalos) through time (i.e. for zooms).

scatter2d(sims, xQuant, yQuant, xlim=None, ylim=None, vstng100=False, vstng50=True, tracks=True, sizefac=1.0, f_selection=None, f_pre=None, f_post=None)

Scatterplot between two quantities, optionally including time evolution tracks through this plane.

Designed for comparison between many zoom runs, including the target subhalo(s) from each.

Parameters:
  • sims (list[simParams]) – list of simulation objects to compare.

  • xQuant (str) – name of quantity to plot on the x-axis.

  • yQuant (str) – name of quantity to plot on the y-axis.

  • xlim (list[float][2]) – if not None, override default x-axis limits.

  • ylim (list[float][2]) – if not None, override default y-axis limits.

  • vstng100 (bool) – if True, plot the TNG100-1 relation for comparison.

  • vstng50 (bool) – if True, plot the TNG100-1 relation for comparison.

  • tracks (bool) – if True, plot tracks of individual galaxies. If False, only plot final redshift values.

  • sizefac (float) – multiplier on figure size.

  • f_selection (function) – if not None, this ‘custom’ function hook is called to determine which subhalo IDs to plot for each sim. It must accept a single argument: the simulation object, and return a list of subhalo IDs to plot. If None, defaults to sim.zoomSubhaloID only.

  • f_pre (function) – if not None, this ‘custom’ function hook is called just before plotting. It must accept two arguments: the figure axis, and a list of simulation objects.

  • f_post (function) – if not None, this ‘custom’ function hook is called just after plotting. It must accept two arguments: the figure axis, and a list of simulation objects.

tracks1d(sims: list[simParams], quant: str, xlim: list[float] = None, ylim: list[float] = None, sfh_lin: bool = False, sfh_treebased: bool = False, plot_parent: bool = True, sizefac: float = 1.0, f_selection: Callable = None) None

Evolution of a quantity versus redshift.

Designed for comparison between many zoom runs, including the target subhalo (only) from each.

Parameters:
  • sims (list[simParams]) – list of simulation objects to compare.

  • quant (str) – name of quantity to plot.

  • xlim (list[float][2]) – if not None, override default x-axis (redshift) limits.

  • ylim (list[float][2]) – if not None, override default y-axis limits.

  • sfh_lin (bool) – show SFH with linear y-axis.

  • sfh_treebased (bool) – if True, use merger tree-based tracks even for SFH-related quantities.

  • plot_parent (bool) – if True, plot halos from the parent box for comparison.

  • sizefac (float) – multiplier on figure size.

  • f_selection (function) – if not None, this ‘custom’ function hook is called to determine which subhalo IDs to plot for each sim. It must accept a single argument: the simulation object, and return a list of subhalo IDs to plot. If None, defaults to sim.zoomSubhaloID only.

temet.plot.util

General helper and utility functions related to plotting.

getWhiteBlackColors(pStyle)

Plot style helper.

colorTriplets()

Some useful color triplets, i.e. plotting vs resolution (vis/ColorWheel-Base.png - outer/3rd/6th rings).

setAxisColors(ax, color2, color1=None)

Factor out common axis color commands.

setColorbarColors(cb, color2)

Factor out common colorbar color commands.

validColorTableNames()

Return a list of whitelisted colormap names.

loadColorTable(ctName, valMinMax=None, plawScale=None, cmapCenterVal=None, fracSubset=None, numColors=None)

Load a custom or built-in color table specified by name.

Parameters:
  • ctName (str) – requested color map by name. Note that appending ‘_r’ to most default colormap names

  • order (requests the colormap in reverse)

  • valMinMax (list[float][2]) – required for some custom colormaps, and for some adjustments.

  • plawScale (float) – return the colormap modified as cmap_new = cmap_old**plawScale.

  • cmapCenterVal (float) – return the colormap modified such that its middle point lands at the numerical value cmapCenterVal, given the bounds valMinMax (e.g. zero, for any symmetric colormap, say for positive/negative radial velocities).

  • fracSubset (list[float][2]) – a 2-tuple in [0,1] e.g. [0.2,0.8] to use only part of the original cmap range.

  • numColors (int or None) – if not None, integer number of discrete colors of the desired colortable (matplotlib colormaps only).

Returns:

requested colormap.

Return type:

matplotlib.colors.Colormap

sampleColorTable(ctName, num, bounds=None)

Grab a sequence of colors, evenly spaced, from a given colortable.

colored_line(x, y, c, ax, **lc_kwargs)

Plot a line with a color specified along the line by a third value.

Approach are line segments, each made up of two straight lines connecting the current (x, y) point to the midpoints of the lines connecting the current point with its two neighbors. This creates a smooth line with no gaps between the line segments.

Parameters:
  • x (ndarray[float]) – x-coordinates of the points.

  • y (ndarray[float]) – y-coordinates of the points.

  • c (ndarray[float]) – color values at each point.

  • ax (matplotlib.axes.Axes) – axis on which to plot the colored line.

  • **lc_kwargs – additional keyword arguments to pass to LineCollection.

Returns:

the generated line collection.

Return type:

matplotlib.collections.LineCollection

contourf(*args, **kwargs)

Wrap matplotlib.contourf() for a graphical fix in PDF output.

plothist(x, filename='out.pdf', nBins=50, norm=False, skipzeros=True)

Plot a quick 1D histogram of an array x and save it to a PDF.

plotxy(x, y, filename='plot.pdf')

Plot a quick 1D line plot of x vs. y and save it to a PDF.

plot2d(grid, label='', minmax=None, filename='plot.pdf')

Plot a quick image plot of a 2d array/grid and save it to a PDF.

add_resolution_lines(ax, sPs, radRelToVirRad=False, rvirs=None, corrMaxBox=False, labelMaxRad=False)

Helper: add some resolution lines to an x-axis of distance (i.e. radial profiles) at small radius.

add_halo_size_scales(ax, sP, field, xaxis, massBins, i, k, avg_rvir_code, avg_rhalf_code, avg_re_code, c)

Helper to draw lines at given fixed or adaptive sizes, i.e. rvir fractions, in radial profile plots.