[1]:
%reload_ext eradiate.tutorials
Last updated: 2025-08-28 18:04 (eradiate v0.31.0.dev1)
A better notebook experienceΒΆ
Overview
This tutorial demonstrates features which make the experience of using Eradiate in a Jupyter notebook more enjoyable.
What you will learn
How to load the Eradiate IPython extension.
How it improves the notebook experience.
First, we load Eradiate and select the CKD mode.
[2]:
import eradiate
from eradiate import unit_registry as ureg
eradiate.set_mode("ckd")
Letβs define a very simulation with a single spectral bin, then visualize it:
[3]:
# Basic behaviour: looks bad
exp = eradiate.experiments.AtmosphereExperiment(
measures={
"type": "mdistant",
"construct": "hplane",
"zeniths": [-30, 0, 30],
"azimuth": 0,
"srf": {
"type": "delta",
"wavelengths": 550.0 * ureg.nm,
},
}
)
exp
[3]:
AtmosphereExperiment(measures=MeasureRegistry(_measures=[MultiDistantMeasure(id='measure', mi_results={}, srf=DeltaSRF(wavelengths=[550.] nm), sampler='independent', rfilter='box', spp=1000, target=TargetPoint(xyz=[0.0 0.0 0.0] m), ray_offset=None, direction_layout=HemispherePlaneLayout(azimuth_convention=<AzimuthConvention.EAST_RIGHT: (0.0, 1)>, zeniths=[-30 0 30] deg, azimuth=0 deg))]), integrator=VolPathIntegrator(id='integrator', timeout=None, moment=False, stokes=False, meridian_align=True, max_depth=None, rr_depth=None, hide_emitters=None), ckd_quad_config=CKDQuadConfig(type=<QuadType.GAUSS_LEGENDRE: 'gauss_legendre'>, ng_max=16, policy=<CKDQuadPolicy.FIXED: 'fixed'>), extra_objects={}, illumination=DirectionalIllumination(id='illumination', zenith=0.0 deg, azimuth=0.0 deg, azimuth_convention=<AzimuthConvention.EAST_RIGHT: (0.0, 1)>, irradiance=SolarIrradianceSpectrum(id=None, dataset=<xarray.Dataset | source='/home/leroyv/.cache/eradiate/installed/eradiate-v0.31.0.dev1/solar_irradiance/coddington_2021-1_nm.nc'>, scale=1.0, datetime=None)), kdict=KernelDict(data={}), kpmap=KernelSceneParameterMap(data=KernelSceneParameterMap(data={})), geometry=PlaneParallelGeometry(toa_altitude=120.0 km, ground_altitude=0.0 km, zgrid=ZGrid(levels=[0.0 100.0 200.0 ... 119800.0 119900.0 120000.0] m, _layers=[50.0 150.0 250.0 ... 119750.0 119850.0 119950.0] m, _layer_height=100.0 m, _total_height=120000.0 m), width=1000000.0 km), atmosphere=HomogeneousAtmosphere(id='atmosphere', geometry=PlaneParallelGeometry(toa_altitude=120.0 km, ground_altitude=0.0 km, zgrid=ZGrid(levels=[0.0 100.0 200.0 ... 119800.0 119900.0 120000.0] m, _layers=[50.0 150.0 250.0 ... 119750.0 119850.0 119950.0] m, _layer_height=100.0 m, _total_height=120000.0 m), width=1000000.0 km), sigma_s=AirScatteringCoefficientSpectrum(id=None), sigma_a=UniformSpectrum(id=None, quantity=COLLISION_COEFFICIENT, value=0.0 1/m), _phase=RayleighPhaseFunction(id='phase_atmosphere', depolarization=array([0.]), geometry=None)), surface=BasicSurface(id='surface', shape=None, bsdf=LambertianBSDF(id='surface_bsdf', reflectance=UniformSpectrum(id=None, quantity=REFLECTANCE, value=0.5))))
Arguably, this ouput is impractical and makes the process of inspecting the contents of the AtmosphereExperiment instance quite challenging. Anyway, letβs run the corresponding simulation:
[4]:
eradiate.run(exp);
The produced output is uncontrolled and mixes progress information coming from Eradiate (the βSpectral loopβ progress bar), but also from the Mitsuba radiometric kernel (the βRenderingβ progress bar). A notable consequence is that changing the progress level using config.progress to suppress Mitsubaβs progress will not have the expected effect.
This can be improved by loading Eradiateβs IPython extension as follows:
[5]:
%load_ext eradiate
This automatically loads Richβs βprettyβ and βtracebackβ extensions, and it redirects Mitsubaβs logs and progress to, respectively, the standard Python logging framework and the tqdm library.
A first noticeable effect is that all objects created using the attrs framework are pretty-printed and are consequently much more readable:
[6]:
exp
[6]:
AtmosphereExperiment(
measures=MeasureRegistry(
_measures=[
MultiDistantMeasure(
id='measure',
mi_results=dict<16 items>({(550.0, 0.0052995383739471436): {...} , ... }),
srf=DeltaSRF(wavelengths=[550.] nm),
sampler='independent',
rfilter='box',
spp=1000,
target=TargetPoint(xyz=[0.0 0.0 0.0] m),
ray_offset=None,
direction_layout=HemispherePlaneLayout(
azimuth_convention=<AzimuthConvention.EAST_RIGHT: (0.0, 1)>,
zeniths=[-30 0 30] deg,
azimuth=0 deg
)
)
]
),
integrator=VolPathIntegrator(
id='integrator',
timeout=None,
moment=False,
stokes=False,
meridian_align=True,
max_depth=None,
rr_depth=None,
hide_emitters=None
),
ckd_quad_config=CKDQuadConfig(
type=<QuadType.GAUSS_LEGENDRE: 'gauss_legendre'>,
ng_max=16,
policy=<CKDQuadPolicy.FIXED: 'fixed'>
),
extra_objects={},
illumination=DirectionalIllumination(
id='illumination',
zenith=0.0 deg,
azimuth=0.0 deg,
azimuth_convention=<AzimuthConvention.EAST_RIGHT: (0.0, 1)>,
irradiance=SolarIrradianceSpectrum(
id=None,
dataset=<xarray.Dataset | source='/home/leroyv/.cache/eradiate/installed/eradiate-v0.31.0.dev1/solar_irradiance/coddington_2021-1_nm.nc'>,
scale=1.0,
datetime=None
)
),
kdict=KernelDict(data={}),
kpmap=KernelSceneParameterMap(data=KernelSceneParameterMap(data={})),
geometry=PlaneParallelGeometry(
toa_altitude=120.0 km,
ground_altitude=0.0 km,
zgrid=ZGrid(
levels=[0.0 100.0 200.0 ... 119800.0 119900.0 120000.0] m,
_layers=[50.0 150.0 250.0 ... 119750.0 119850.0 119950.0] m,
_layer_height=100.0 m,
_total_height=120000.0 m
),
width=1000000.0 km
),
atmosphere=HomogeneousAtmosphere(
id='atmosphere',
geometry=PlaneParallelGeometry(
toa_altitude=120.0 km,
ground_altitude=0.0 km,
zgrid=ZGrid(
levels=[0.0 100.0 200.0 ... 119800.0 119900.0 120000.0] m,
_layers=[50.0 150.0 250.0 ... 119750.0 119850.0 119950.0] m,
_layer_height=100.0 m,
_total_height=120000.0 m
),
width=1000000.0 km
),
sigma_s=AirScatteringCoefficientSpectrum(id=None),
sigma_a=UniformSpectrum(id=None, quantity=COLLISION_COEFFICIENT, value=0.0 1/m),
_phase=RayleighPhaseFunction(
id='phase_atmosphere',
depolarization=array([0.]),
geometry=None
)
),
surface=BasicSurface(
id='surface',
shape=None,
bsdf=LambertianBSDF(
id='surface_bsdf',
reflectance=UniformSpectrum(id=None, quantity=REFLECTANCE, value=0.5)
)
)
)
A second consequence is that progress display control now works as expected:
[7]:
eradiate.config.settings.set("progress", "KERNEL")
eradiate.run(exp);
[8]:
eradiate.config.settings.set("progress", "SPECTRAL_LOOP")
eradiate.run(exp);
Further readingΒΆ
The extension can also be activated by an explicit call to eradiate.notebook.install(), which allows for further customization.