Source code for energy_data_retrieval.bess_oem_catalogue.narada

"""Bounded offline staging of Narada's reviewed Spanish 313K model table."""

from math import isfinite

from energy_data_retrieval.bess_oem_catalogue.bsb import _Table

MODELS_313K = (
    "HTB-200F",
    "HTB-300F",
    "HTB-400F",
    "HTB-500F",
    "HTB-600F",
    "HTB-800F",
    "HTB-1000F",
    "HTB-1200F",
    "HTB-1500F",
    "HTB-2000F",
    "12HTB100",
    "12HTB150",
    "12HTB170",
    "12HTB100F",
    "12HTB150F",
    "12HTB170F",
    "12HTB190F",
    "12HTB200F",
    "12HTB150FT",
)


[docs] def stage_313k(html: str) -> list[dict]: """Stage exact model facts without inferring dimension units or stored energy. The live table states C10 but no reference temperature or final voltage. Dimensions deliberately remain native numbers with unknown units. Series prose, rights, editions and natural identities require separate human review. """ parser = _Table() parser.feed(html) rows = parser.rows def compact(value: str) -> str: return "".join(value.split()) if ( len(rows) != 21 or [compact(x) for x in rows[0]] != ["Modelo", "VoltajeNominal(V)", "CapacidadNominal(Ah,C10)", "Tamaño", "Terminales"] or rows[1] != ["Largo", "Ancho", "Alto"] ): raise ValueError("Unreviewed Narada table headers, units or row count") if tuple(r[0] for r in rows[2:] if r) != MODELS_313K: raise ValueError("Missing, duplicate or unreviewed exact model") out = [] for number, row in enumerate(rows[2:], 3): if len(row) != 7: raise ValueError("Unreviewed model row shape") voltage, capacity, length, width, height = map(float, row[1:6]) expected_voltage = 12 if row[0].startswith("12") else 2 expected_terminal = "M6" if expected_voltage == 12 else "M8" if ( voltage != expected_voltage or row[6] != expected_terminal or not all(isfinite(x) and x > 0 for x in (capacity, length, width, height)) ): raise ValueError("Invalid or unreviewed rating/terminal") out.append( { "model": row[0], "voltage_v": voltage, "capacity_ah": capacity, "capacity_rate": "C10", "capacity_temperature_c": None, "capacity_endpoint_v": None, "dimensions_native": { "length": length, "width": width, "height": height, "unit": None, }, "terminal": row[6], "table_row": number, } ) return out