Source code for energy_data_retrieval.bess_oem_catalogue.alphaess

"""Offline staging of the reviewed SMILE G3 V2.3 battery table (PDF page 10)."""

import re
from typing import Any

MODELS = ("SMILE-G3-BAT-3.8S", "SMILE-G3-BAT-4.5S", "SMILE-G3-BAT-9.3S")
LABELS = (
    "Nominal Capacity",
    "Usable Capacity",
    "Depth of Discharge (DoD)",
    "Nominal Voltage",
    "Max. Charging/Discharging Current",
    "Operating Temperature Range",
    "Cycle Life",
    "Modular Connection",
    "IP Protection",
    "Dimensions (W x D x H)",
    "Weight",
    "Noise",
    "Fire-Fighting",
)


[docs] def parse_battery_table(table: list[list[str | None]], *, revision: str) -> list[dict[str, Any]]: """Stage exact modules, never optional stacks or inverter specifications. Input is the final pdfplumber table on PDF page 10. Review original rights, merged cells and footnotes first. Cycle conditions remain unresolved; this routine neither infers active power nor writes canonical records. """ if revision != "V2.3": raise ValueError("Unreviewed revision") if len(table) != 15 or any(len(row) != 4 for row in table): raise ValueError("Expected complete four-column battery table") if table[0] != ["Battery Technical Specifications", None, None, None]: raise ValueError("Wrong component boundary") if table[1] != ["Model", *MODELS] or [r[0] for r in table[2:]] != list(LABELS): raise ValueError("Changed model identities, order or field labels") result = [] for column, model in enumerate(MODELS, 1): native = {label: table[i + 2][column] for i, label in enumerate(LABELS)} if any(not isinstance(v, str) or not v.strip() for v in native.values()): raise ValueError("Missing module observation") def number(label: str, unit: str, values: dict[str, str | None] = native) -> float: match = re.fullmatch(r"([0-9]+(?:\.[0-9]+)?)\s*" + re.escape(unit), str(values[label])) if not match or float(match[1]) <= 0: raise ValueError(f"Invalid value/unit for {label}") return float(match[1]) nominal = number("Nominal Capacity", "kWh") usable = number("Usable Capacity", "kWh") if usable > nominal: raise ValueError("Usable energy exceeds nominal energy") result.append( { "model": model, "nominal_energy_kwh": nominal, "usable_energy_kwh": usable, "nominal_voltage_v": number("Nominal Voltage", "V"), "maximum_charge_discharge_current_a": number( "Max. Charging/Discharging Current", "A" ), "weight_kg": number("Weight", "kg"), "native_observations": native, "locator": f"PDF page 10 Battery Technical Specifications column {column}", "revision": revision, } ) return result