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 margin each 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_MASKS on ax, one colour per molecule, and name them.

molecules selects a subset (default: all). names is “chemical” (“H2O”), “common” (“water”) or “both” (“H2O, water”). label is “text” (a label at the top of each molecule’s widest band), “legend” (one legend entry per molecule; call ax.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_model draws the native-resolution model as a line; show_points draws simulate_points(seed) with the per-bin error bars. The legend names the points “simulated (scenario, R=…)” and the line “model (scenario)”; with show_points=False the line is labelled by scenario. label replaces the scenario text in those entries. units is “percent”, “ppm” or “fraction”. **errorbar_kw goes to ax.errorbar; color/c also colours the model line. A title is set on a new figure or an empty Axes unless title is given. bands=True shades 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_err as binned, with n_transits included, 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; label names the set in both entries (useful when overlaying two). Several bands are stacked offset apart (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 unless title is 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.FuncAnimation of the transit, n_frames evenly spaced over the observation window; see plot_transit() for the layout. Save it with anim.save("transit.gif") (pillow) or anim.save("transit.mp4") (ffmpeg); in a notebook, display it with IPython.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_d days after mid-transit.

planet is a registry name, a SimulatedSpectrum or a dict (period_d, a_over_rs, inc_deg; optional ecc, w_deg, depth or k, name, T_eff_K). view is “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]

FuncAnimation of one full orbit, starting at mid-transit; see plot_orbit() for the arguments and anim.save("orbit.gif") to write it out.