energy_methods.climate_zones#

Portable climate classifications and bounded, frozen cluster prediction.

Zero is always missing; positive IDs are local to a scheme/model version. Distances and training-range flags are diagnostics, not probabilities.

class energy_methods.climate_zones.ClimateProvenance(source, period, resolution, status='application')[source]#

Bases: object

Caller-declared source support, retained in every result and fitted state.

Parameters:
  • source (str)

  • period (str)

  • resolution (str)

  • status (str)

source: str#
period: str#
resolution: str#
status: str = 'application'#
class energy_methods.climate_zones.ClimateZones(scheme, class_id, codes, labels, provenance, reference_ids, outside_training_range=None)[source]#

Bases: object

Class IDs, scientific codes, readable labels and source metadata.

Parameters:
  • scheme (str)

  • class_id (ndarray[tuple[Any, ...], dtype[int64]])

  • codes (tuple[str, ...])

  • labels (tuple[str, ...])

  • provenance (ClimateProvenance)

  • reference_ids (tuple[str, ...])

  • outside_training_range (ndarray[tuple[Any, ...], dtype[bool]] | None)

scheme: str#
class_id: ndarray[tuple[Any, ...], dtype[int64]]#
codes: tuple[str, ...]#
labels: tuple[str, ...]#
provenance: ClimateProvenance#
reference_ids: tuple[str, ...]#
outside_training_range: ndarray[tuple[Any, ...], dtype[bool]] | None = None#
property zone: ndarray[tuple[Any, ...], dtype[str_]]#

Scientific code for each cell; empty string means unclassified.

class energy_methods.climate_zones.ClimateClusterModel(scheme, features, offset, scale, weights, centers, lower, upper, codes, labels, provenance, reference_ids, settings)[source]#

Bases: object

Validated numerical state; no executable pickle or runtime estimator needed.

Input columns must follow features and the recorded training convention. NaN prediction rows stay unclassified; infinity is rejected. Training bounds diagnose extrapolation but do not measure cluster confidence.

Parameters:
  • scheme (str)

  • features (tuple[str, ...])

  • offset (ndarray[tuple[Any, ...], dtype[float64]])

  • scale (ndarray[tuple[Any, ...], dtype[float64]])

  • weights (ndarray[tuple[Any, ...], dtype[float64]])

  • centers (ndarray[tuple[Any, ...], dtype[float64]])

  • lower (ndarray[tuple[Any, ...], dtype[float64]])

  • upper (ndarray[tuple[Any, ...], dtype[float64]])

  • codes (tuple[str, ...])

  • labels (tuple[str, ...])

  • provenance (ClimateProvenance)

  • reference_ids (tuple[str, ...])

  • settings (dict[str, Any])

scheme: str#
features: tuple[str, ...]#
offset: ndarray[tuple[Any, ...], dtype[float64]]#
scale: ndarray[tuple[Any, ...], dtype[float64]]#
weights: ndarray[tuple[Any, ...], dtype[float64]]#
centers: ndarray[tuple[Any, ...], dtype[float64]]#
lower: ndarray[tuple[Any, ...], dtype[float64]]#
upper: ndarray[tuple[Any, ...], dtype[float64]]#
codes: tuple[str, ...]#
labels: tuple[str, ...]#
provenance: ClimateProvenance#
reference_ids: tuple[str, ...]#
settings: dict[str, Any]#
predict(values, *, batch_size=8192)[source]#

Predict without refitting; memory is bounded by batch size by cluster count.

Parameters:
  • values (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

  • batch_size (int)

Return type:

ClimateZones

to_dict()[source]#

JSON-compatible state including scaling, units/conventions and attribution.

Return type:

dict[str, Any]

classmethod from_dict(state)[source]#

Restore and validate a versioned numerical model.

Parameters:

state (dict[str, Any])

Return type:

ClimateClusterModel

energy_methods.climate_zones.validate_training(values, features, clusters)[source]#

Require explicit complete training rows and enough distinct locations.

Parameters:
  • values (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

  • features (int)

  • clusters (int)

Return type:

ndarray[tuple[Any, …], dtype[float64]]

energy_methods.climate_zones.class_target_rmse(zones, target, sample_weight=None)[source]#

Weighted within-class target dispersion, not held-out prediction accuracy.

Compare on the same locations/period and also at equal class counts. Missing target values and class zero are excluded; no area weighting is inferred.

Parameters:
  • zones (ClimateZones)

  • target (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

  • sample_weight (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None)

Return type:

float