Binning (lazuli_exo.binning)

Constant-R wavelength binning for model spectra and noise channels.

lazuli_exo.binning.constant_R_edges(wl_min, wl_max, R)[source]

Wavelength bin edges for constant resolving power R.

The grid keeps only complete bins, so coverage may stop up to one bin short of wl_max (the last partial bin is dropped).

lazuli_exo.binning.bin_centers(edges)[source]
lazuli_exo.binning.bin_model(wl, depth, edges)[source]
lazuli_exo.binning.bin_sigma(wl, sigma, edges)[source]
lazuli_exo.binning.channel_edges(wl_chan)[source]

Pixel edges from channel centres: geometric midpoints, ends extended.

lazuli_exo.binning.R_instr(wl_chan, resolution_px=2.3)[source]

Instrument resolving power per channel, lambda / (resolution_px * dlambda_px).

lazuli_exo.binning.snap_edges_to_channels(edges, wl_chan)[source]

Move each bin edge to the nearest channel edge (bins = whole pixels).

lazuli_exo.binning.instrument_response(wl_model, depth_model, wl_chan, lsf_sigma_px=1.15, f_phot=None, oversample=100)[source]

Per-channel transit depth seen through the spectrograph.

Channels are contiguous pixels. The model and the stellar photon flux f_phot(lambda_um) (per unit wavelength; uniform if None) are put on a fine grid uniform in pixel coordinate, F*(1-d) and F are convolved with the Gaussian LSF (sigma in pixels) and integrated per pixel; the depth is 1 - sum_in / sum_out. The absolute scale of f_phot cancels.

lazuli_exo.binning.bin_weighted(wl, depth, sigma, edges)[source]

Inverse-variance-weighted mean of per-channel depths: the same combination whose uncertainty bin_sigma returns.

lazuli_exo.binning.bin_observation(wl_model, depth_model, wl_chan, sigma_chan, R, f_phot=None, noise_meta=None)[source]

Constant-R bins snapped to channel edges, LSF/photon-weighted per-channel depths combined with the 1/sigma^2 weights, and the matching sigma.

Returns (edges, depth, sigma, info). Warns (does not raise) when R exceeds the instrument resolving power over the binned range, so oversampled display is still possible; bins narrower than a resolution element are then correlated by the LSF.