model.parameterization.pft_lookup¶
Override rules¶
Parameters whose resolved source is
pft_baseduse the LUT.Data-provided parameters and explicit parameterization entries exclude the same parameter from LUT-based lookup.
PFT-based lookup-table parameterization for ADELM.
The canonical per-PFT values live in PFT_LOOKUP.txt (same directory),
formatted as a tab-separated table:
- Column 1 : parameter name
- Column 2 : units (informational only)
- Columns 3+: one column per PFT, named by the header row
PFTBasedParams reads the table at import time, then at runtime computes
effective parameter values as a PFT-fraction-weighted average:
param_eff[location] = sum_i( pft_fraction[location, i] * lut_value[i] )
Module Contents¶
Classes¶
PFT lookup-table parameterization. |
Functions¶
Load a custom PFT lookup table and return |
|
Return an ordered list of LUT values for |
API¶
- model.parameterization.pft_lookup.load_pft_lut(path) tuple[list[str], dict[str, dict[str, float]]]¶
Load a custom PFT lookup table and return
(pft_names, lut).The file must follow the same tab-separated format as the built-in
PFT_LOOKUP.txt. Call this whenconfig.data.resources.pft_lut_pathis set.- Parameters:
path (str or Path)
- Returns:
Same structure as the module-level
PFT_NAMESandPFT_LUT.- Return type:
pft_names, lut
- model.parameterization.pft_lookup.get_pft_values(param_name: str, pft_names: list[str]) list[float]¶
Return an ordered list of LUT values for
param_name.- Parameters:
param_name (str) – Must be a key in
PFT_LUT.pft_names (list[str]) – Ordered PFT names matching
attris["pft_fraction"]columns. Every name must appear as a column inPFT_LOOKUP.txt.
- Return type:
list[float]
- Raises:
KeyError – If
param_nameis not in the table or a PFT name is unknown.
- class model.parameterization.pft_lookup.PFTBasedParams(lut: dict[str, dict[str, float]], active_params: list[str])¶
PFT lookup-table parameterization.
Given entity-level PFT area fractions (
attris["pft_fraction"], shape[n_entities, n_pfts]) and a fixed per-PFT lookup table loaded frompft_lut.txt, computes effective parameter values as a PFT-fraction-weighted average.Parameters
pft_lut : dict[str, list[float]] Mapping of parameter name to a list of per-PFT values. The list order must match the column order declared in
config.pft.pft_names.Examples
pft_params = PFTBasedParams.from_runtime_config(config) updates = pft_params(attris) # attris[“pft_fraction”]: [n_entities, n_pfts] updates[“canopy_height”] # Tensor of shape [n_entities]
Initialization
- classmethod from_runtime_config(config)¶
Build a
PFTBasedParamsinstance from the LUT and runtime config.PFT names and their column order are not taken from config; they are read from
attris["pft_names"]at call time, after the attris data have been loaded from the NetCDF file.This method only resolves:
Which lookup table to use (built-in or custom
pft_lut_path).Which parameters are overridden by config and therefore excluded from LUT-based lookup.
Returns
Nonewhen allpft_basedparameters are overridden in config (i.e. the LUT would be a no-op).Parameters
config : RuntimeConfig
Returns
PFTBasedParams or None
- __call__(fcover: dict) dict[str, torch.Tensor]¶
Compute effective parameter values from site PFT cover fractions.
Parameters
fcover : dict[str, Tensor[n_entities]] Fractional land cover per PFT. Keys are PFT names (e.g.
"PFT_TREES-NE"); values are[n_entities]tensors. Values may be in percent (summing to ~100) or fraction (summing to ~1); the weighted average is the same either way.Returns
dict[str, torch.Tensor] Mapping of parameter name to a tensor of shape
[n_entities].