INNER CODE UNIT · Python
_normalize_outflow_source
QianyeSu/Skyborn · src/skyborn/calc/GPI/core.py:81
def _normalize_outflow_source(outflow_source: str) -> int:
"""Map the public outflow-source string to the Fortran flag."""
try:
return _OUTFLOW_SOURCE_FLAGS[outflow_source]
except KeyError as exc:
raise ValueError(
f"Invalid outflow_source={outflow_source!r}; expected 'cape_star' or 'cape_env'."
) from exc
def _sst_to_kelvin(sst: Any, sst_units: _SSTUnits) -> Any:
"""Convert sea-surface temperature to Kelvin."""
units = sst_units.upper()
if units == "K":
return sst
if units == "C":
return np.asarray(sst) + 273.15
raise ValueError(f"Unsupported sst_units={sst_units!r}; expected 'C' or 'K'.")