Emulator API

The Emulator class provides a neural-network surrogate for fast spectral albedo prediction.

from biosnicar.emulator import Emulator
from biosnicar import run_emulator

Emulator.build()

Train an emulator on Latin hypercube samples of the forward model.

Emulator.build(params, n_samples=10000, solver="adding-doubling",
               input_file="default", progress=True, seed=42,
               **fixed_overrides) -> Emulator
ParameterTypeDefaultDescription
paramsdictrequired{name: (min, max)} for each free parameter
n_samplesint10000Number of LHS training samples
solverstr"adding-doubling"RT solver
input_filestr"default"YAML config path
progressboolTrueShow progress bar
seedint42Random seed
**fixed_overrideskwargsFixed parameters for every run

Requires scikit-learn>=1.0.

Emulator.predict()

Predict 480-band spectral albedo. Pure numpy, ~microseconds.

emu.predict(**params) -> np.ndarray  # shape (480,)

All emulator parameters must be provided as keyword arguments.

Emulator.predict_batch()

Predict for N parameter combinations.

emu.predict_batch(points) -> np.ndarray  # shape (N, 480)
ParameterTypeDescription
pointsndarray (N, n_params)Rows are parameter sets in param_names order

Emulator.verify()

Measure accuracy against the full forward model.

emu.verify(n_points=20, seed=123) -> VerificationResult

VerificationResult

AttributeTypeDescription
maefloatMean absolute spectral error
max_errfloatWorst-case absolute error
mae_bbafloatMean absolute broadband-albedo error
r2floatR² over all predicted vs reference values
n_pointsintNumber of benchmark points

result.summary() returns a human-readable string.

Emulator.save() / Emulator.load()

emu.save("path.npz")
emu = Emulator.load("path.npz")

No sklearn required for loading.

Properties

PropertyTypeDescription
param_nameslist[str]Ordered parameter names
boundsdict{name: (min, max)} from training
n_pca_componentsintPCA components retained
training_scorefloatR² on training data
flx_slrndarray (480,)Solar flux spectrum

run_emulator()

Wrapper that returns an Outputs object with .albedo, .BBA, .BBAVIS, .BBANIR, .flx_slr, and .to_platform().

from biosnicar import run_emulator
 
outputs = run_emulator(emu, rds=1000, rho=600, black_carbon=5000,
                       snow_algae=0, dust=1000, glacier_algae=50000,
                       direct=1, solzen=50)
print(outputs.BBA)
outputs.to_platform("sentinel2")

Fields only available from the full RT solver (heat_rt, absorbed_flux_per_layer) are None.