Plotting (lazuli_exo.plotting)
Note
Requires the [plot] extra. matplotlib is imported lazily inside
these functions, so it is never needed at package import time.
Matplotlib plotting for SimulatedSpectrum and LightCurveSet ([plot] extra).
Every function takes an optional ax and returns the Axes it drew on, so
plots compose: pass the same ax to overlay scenarios, or pass one Axes of
a subplot grid. matplotlib is imported inside the functions, never at module
import. The functions do not touch the global style; set
plt.style.use(...) yourself if you want one.
- lazuli_exo.plotting.wavelength_axis(ax, ticks=(0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.7), margin=1.03)[source]
Log wavelength axis with the Lazuli band ticks and a plain-number formatter.
Call it after plotting: the x-limits are fitted to the lines on the Axes and on any Axes sharing its x axis (times
margineach side), which sidesteps matplotlib’s errorbar data limits on a log axis and keeps shared panels on one range.
- lazuli_exo.plotting.shade_bands(ax, molecules=None, names='both', alpha=0.15, label='text')[source]
Shade the wavelength bands of
lazuli_exo.detect.BAND_MASKSonax, one colour per molecule, and name them.moleculesselects a subset (default: all).namesis “chemical” (“H2O”), “common” (“water”) or “both” (“H2O, water”).labelis “text” (a label at the top of each molecule’s widest band), “legend” (one legend entry per molecule; callax.legend()afterwards) or None. Returns the list of shaded patches. The bands overlap (H2O and CH4 near 1.15 µm) and are the masks of the template statistic, not line lists.
- lazuli_exo.plotting.plot_spectrum(obs, ax=None, seed=0, show_model=True, show_points=True, units='percent', label=None, title=None, bands=False, **errorbar_kw)[source]
Model spectrum and one noisy realization of the binned observation.
show_modeldraws the native-resolution model as a line;show_pointsdrawssimulate_points(seed)with the per-bin error bars. The legend names the points “simulated (scenario, R=…)” and the line “model (scenario)”; withshow_points=Falsethe line is labelled by scenario.labelreplaces the scenario text in those entries.unitsis “percent”, “ppm” or “fraction”.**errorbar_kwgoes toax.errorbar;color/calso colours the model line. A title is set on a new figure or an empty Axes unlesstitleis given.bands=Trueshades the molecular bands (shade_bands()); a list of molecule names shades only those.
- lazuli_exo.plotting.plot_noise(obs, ax=None, units='ppm', label=None, **plot_kw)[source]
Per-bin 1-sigma depth uncertainty against wavelength (log y).
This is
obs.depth_erras binned, withn_transitsincluded, so two observations at different R or N compare directly on one Axes.
- lazuli_exo.plotting.plot_light_curves(lc, ax=None, offset=None, show_points=True, show_model=True, label=None, title=None)[source]
Light curves of a LightCurveSet, one per band, stacked by
offset.A single band (white light) draws the noisy realization as points and the noiseless model as a line in a second colour, with a legend;
labelnames the set in both entries (useful when overlaying two). Several bands are stackedoffsetapart (default 1.25 x the largest depth, or the flux range if no depth is positive), points and model in one colour per band, each annotated with its wavelength range at the left edge. A title is set on a new figure or an empty Axes unlesstitleis given.
- lazuli_exo.plotting.plot_transit(lc, t_hr=0.0, offset=None, cmap='plasma', npix=241, show_points=True)[source]
Figure of the transit at time
t_hr(hours from mid-transit), one limb-darkened stellar disk per band with the planet on it, over the band light curves drawn up to that time. Returns the Figure.Registry planets use their orbit and limb darkening; a custom planet (trapezoid light curves) gets a uniform disk and a central chord. Bands are tinted by wavelength through
cmap.
- lazuli_exo.plotting.animate_transit(lc, n_frames=60, fps=12, offset=None, cmap='plasma', npix=241, show_points=True)[source]
matplotlib.animation.FuncAnimationof the transit,n_framesevenly spaced over the observation window; seeplot_transit()for the layout. Save it withanim.save("transit.gif")(pillow) oranim.save("transit.mp4")(ffmpeg); in a notebook, display it withIPython.display.HTML(anim.to_jshtml())or save and show the GIF.
- lazuli_exo.plotting.plot_orbit(planet, t_d=0.0, view='observer', n_frames=360, npix=201)[source]
Figure of the planet on its orbit
t_ddays after mid-transit.planetis a registry name, aSimulatedSpectrumor a dict (period_d,a_over_rs,inc_deg; optionalecc,w_deg,depthork,name,T_eff_K).viewis “observer” (Earth’s line of sight, the registry inclination), “top” (face-on) or an inclination in degrees. Star and planet are to scale in stellar radii; the star’s colour follows its temperature.
- lazuli_exo.plotting.animate_orbit(planet, n_frames=120, fps=15, view='observer', npix=201)[source]
FuncAnimationof one full orbit, starting at mid-transit; seeplot_orbit()for the arguments andanim.save("orbit.gif")to write it out.