API Reference

Calibration API

Calibration API

UQPyL.calibration

The calibration module calibrates simulation models represented by ModelProblem.

Import

python
from UQPyL.calibration import GLUE, SUFI2, ES, IES
from UQPyL.calibration import CalReader, CalResult

Public Objects

ObjectRole
CalibrationABCBase class for calibration methods.
GLUEGeneralized likelihood uncertainty estimation.
SUFI2Sequential uncertainty fitting version 2.
ESEnsemble smoother.
IESIterative ensemble smoother.
CalResultStandard result object returned by calibration runs.
CalHistoryRuntime history stored inside CalResult.
CalReaderReader for sqlite results saved with saveFlag=True.

Calibration Workflow

Calibration methods only accept ModelProblem.

python
result = method.run(problem, ...)

The ModelProblem must include:

RequirementMeaning
simFuncBatched simulation function.
obs2D observation array with shape (n_time, n_series).
maskOptional boolean mask with the same shape as obs.

problem.simFunc(X) must return simulation output whose first dimension is n_samples. Calibration methods flatten simulations and observations into a shared observation vector for scoring.

Shared constructor controls:

ParameterMeaning
verboseFlagPrint final summary when enabled.
verboseFreqRuntime summary frequency for methods that record iterative history.
saveFlagPersist final result and artifacts to sqlite.
logFlagWrite a text log when enabled.
metricCalibration metric name or callable.

Supported metric names:

MetricBetter direction
mseLower is better
maeLower is better
rmseLower is better
nseHigher is better
r2Higher is better
pbiasLower is better
pearson_rHigher is better
kgeHigher is better

Example:

python
import numpy as np

from UQPyL.calibration import GLUE
from UQPyL.problem import ModelProblem


obs = np.array([[1.0], [2.0]])


def simFunc(X):
    X = np.atleast_2d(X)
    sim = np.zeros((X.shape[0], 2, 1))
    sim[:, 0, 0] = X[:, 0]
    sim[:, 1, 0] = X[:, 1]
    return sim


problem = ModelProblem(
    nInput=2,
    ub=3.0,
    lb=0.0,
    simFunc=simFunc,
    obs=obs,
    simLabels=["Q"],
)

X = np.array([
    [1.0, 2.0],
    [1.0, 2.4],
    [0.0, 0.0],
])

result = GLUE(metric="rmse", verboseFlag=False).run(problem, X, threshold=0.3)
print(result.bestDecs)
print(result.behavioralDecs)

CalResult

CalResult is returned by every calibration method.

FieldTypeMeaning
runIdstr or NoneSaved run id when saveFlag=True.
methodstrCalibration method name.
problemNamestrProblem name.
nInputintNumber of input variables.
nTimeintNumber of observation time steps.
nSeriesintNumber of observation series.
nObsintTotal observation count.
settingsdictMethod settings.
runtimefloatRuntime in seconds.
createdAtstrCreation timestamp.
obsnp.ndarrayObservation array.
masknp.ndarrayBoolean mask array.
simLabelslist[str]Simulation series labels.
bestDecsnp.ndarray or NoneBest decision variables.
bestSimnp.ndarray or NoneSimulation output for the best decision.
posteriorDecsnp.ndarray or NonePosterior decision ensemble.
posteriorSimsnp.ndarray or NonePosterior simulation ensemble.
behavioralDecsnp.ndarray or NoneBehavioral samples retained by GLUE.
behavioralSimsnp.ndarray or NoneBehavioral simulations retained by GLUE.
eliteDecsnp.ndarray or NoneElite samples retained by SUFI2.
eliteSimsnp.ndarray or NoneElite simulations retained by SUFI2.
diagnosticsdictMethod diagnostics.
historyCalHistoryIterative metric history.
extradictExtra method-specific payload.

Method:

APIReturnsMeaning
summary()dictCompact runtime summary.

CalHistory

CalHistory stores method progress.

FieldMeaning
metricsHistoryList of per-iteration metric summaries.

GLUE

Generalized likelihood uncertainty estimation.

python
GLUE(
    verboseFlag=False,
    verboseFreq=1,
    saveFlag=False,
    logFlag=False,
    metric="rmse",
)

Run signature:

python
result = method.run(problem, X, threshold)
ParameterMeaning
XCandidate parameter matrix.
thresholdBehavioral threshold under the configured metric.

For higher-is-better metrics such as nse, behavioral samples satisfy score >= threshold. For lower-is-better metrics such as rmse, behavioral samples satisfy score <= threshold.

Recorded outputs:

OutputMeaning
bestDecs, bestSimBest sample under the configured metric.
behavioralDecs, behavioralSimsSamples passing the threshold.
diagnostics["scores"]Scores for all candidate samples.
diagnostics["behavioralMask"]Boolean mask for retained samples.

SUFI2

Sequential uncertainty fitting version 2.

python
SUFI2(
    verboseFlag=False,
    verboseFreq=1,
    saveFlag=False,
    logFlag=False,
    maxIters=1,
    nSamples=None,
    metric="rmse",
)

Run signature:

python
result = method.run(problem, X=None, eliteSize=5, seed=None)
ParameterMeaning
XOptional sample matrix. If omitted, nSamples must be set and samples are generated internally by LHS.
eliteSizeNumber of elite samples retained each iteration.
seedOptional seed used for internally generated samples.
maxItersNumber of SUFI2 iterations.
nSamplesInternal sample count when X is omitted.

Recorded outputs:

OutputMeaning
bestDecs, bestSimBest sample from the final iteration.
posteriorDecs, posteriorSimsFinal sampled population and simulations.
eliteDecs, eliteSimsFinal elite samples and simulations.
diagnostics["updatedLb"]Updated lower bounds from elite samples.
diagnostics["updatedUb"]Updated upper bounds from elite samples.
diagnostics["pfactor"]P-factor from the final elite set.
diagnostics["rfactor"]R-factor from the final elite set.

ES

Single-pass ensemble smoother.

python
ES(
    verboseFlag=False,
    verboseFreq=1,
    saveFlag=False,
    logFlag=False,
    metric="rmse",
)

Run signature:

python
result = method.run(problem, X, r=None)
ParameterMeaning
XInitial ensemble matrix with shape (n_samples, n_input).
rOptional observation error covariance matrix with shape (n_valid_obs, n_valid_obs). If omitted, zeros are used.

Recorded outputs:

OutputMeaning
posteriorDecs, posteriorSimsUpdated ensemble and simulations.
bestDecs, bestSimBest posterior member under the configured metric.
diagnostics["priorMean"]Prior ensemble mean.
diagnostics["posteriorMean"]Posterior ensemble mean.
diagnostics["scores"]Posterior scores.

IES

Iterative ensemble smoother.

python
IES(
    verboseFlag=False,
    verboseFreq=1,
    saveFlag=False,
    logFlag=False,
    maxIters=5,
    lam=0.0,
    metric="rmse",
)

Run signature:

python
result = method.run(problem, X, r=None)
ParameterMeaning
XInitial ensemble matrix with shape (n_samples, n_input).
rOptional observation error covariance matrix with shape (n_valid_obs, n_valid_obs).
maxItersNumber of smoother iterations.
lamDiagonal regularization strength added to C_yy + R.

Recorded outputs are the same shape as ES, with per-iteration summaries in result.history.metricsHistory.

CalReader

Use CalReader to read sqlite results saved with saveFlag=True.

python
from UQPyL.calibration import CalReader


with CalReader("Result/glue_ToyModel_20260509_1200_0000.sqlite3") as reader:
    result = reader.load_result()
    print(result.summary())
MethodReturnsMeaning
CalReader.list_runs(result_dir)table-like dataList saved calibration runs in a result directory.
get_run()dict or NoneReturn raw run metadata.
get_run_params()dictReturn stored method parameters.
get_run_summary()dictReturn compact run summary.
get_artifacts()dictLoad saved artifacts.
load_problem()problem objectLoad the saved ModelProblem.
load_result()CalResultLoad the saved final calibration result.
close()NoneClose the sqlite connection.