Extended Variogram Mode¶
This notebook shows how to enable TerraFlow's extended kriging variogram search on a small synthetic station network. Extended mode evaluates the default spherical, exponential, and Gaussian candidates plus nested variogram candidates, then records candidate LOOCV scores in interpolation_cv.
In [ ]:
Copied!
import numpy as np
import pandas as pd
from terraflow.climate import ClimateInterpolator
climate_df = pd.DataFrame(
{
"lat": [39.97, 39.97, 39.97, 39.97, 40.00, 40.00, 40.00, 40.00],
"lon": [-100.03, -100.01, -99.99, -99.97, -100.03, -100.01, -99.99, -99.97],
"mean_temp": [17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0],
"total_rain": [90.0, 100.0, 110.0, 120.0, 130.0, 140.0, 150.0, 160.0],
}
)
interpolator = ClimateInterpolator(
climate_df=climate_df,
strategy="spatial",
interpolation_method="kriging",
variogram_mode="extended",
)
interpolator.cv_metrics["candidate_scores"]
import numpy as np
import pandas as pd
from terraflow.climate import ClimateInterpolator
climate_df = pd.DataFrame(
{
"lat": [39.97, 39.97, 39.97, 39.97, 40.00, 40.00, 40.00, 40.00],
"lon": [-100.03, -100.01, -99.99, -99.97, -100.03, -100.01, -99.99, -99.97],
"mean_temp": [17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0],
"total_rain": [90.0, 100.0, 110.0, 120.0, 130.0, 140.0, 150.0, 160.0],
}
)
interpolator = ClimateInterpolator(
climate_df=climate_df,
strategy="spatial",
interpolation_method="kriging",
variogram_mode="extended",
)
interpolator.cv_metrics["candidate_scores"]
Use the default variogram_mode: standard for large station networks unless nested structures are specifically needed. Extended mode fits custom nested variograms before LOOCV, so it is intentionally more expensive than standard kriging.
In [ ]:
Copied!
cell_lats = np.array([39.985, 39.995])
cell_lons = np.array([-100.005, -99.985])
interpolator.interpolate(cell_lats, cell_lons)
cell_lats = np.array([39.985, 39.995])
cell_lons = np.array([-100.005, -99.985])
interpolator.interpolate(cell_lats, cell_lons)