diff --git a/src/aeros_simulation/model.py b/src/aeros_simulation/model.py index 0c3ecd0..c5d533b 100644 --- a/src/aeros_simulation/model.py +++ b/src/aeros_simulation/model.py @@ -12,7 +12,6 @@ class AerosSimulation(Base, DefaultMixin): started_at = Column(DateTime, nullable=True) completed_at = Column(DateTime, nullable=True) input = Column(JSON, nullable=True) - result = Column(JSON, nullable=True) error = Column(JSON, nullable=True) simulation_name = Column(String, nullable=False) schematic_name = Column(String, nullable=False) diff --git a/src/aeros_simulation/utils.py b/src/aeros_simulation/utils.py index 2f8dd62..11f14a0 100644 --- a/src/aeros_simulation/utils.py +++ b/src/aeros_simulation/utils.py @@ -1,10 +1,12 @@ +import json + + def calculate_eaf( available_hours: float, period_hours: float, actual_production: float, ideal_production: float, downtime_hours, - plot_data ): """ Calculate EAF using the time-based method from PLN document @@ -24,7 +26,7 @@ def calculate_eaf( try: # Calculate lost production lost_production = ideal_production - actual_production - max_capacity = plot_data.max_flow_rate + max_capacity = 660 # Calculate total equivalent derate and outage hours total_equivalent_derate_and_outage_hours = lost_production / max_capacity if max_capacity > 0 else 0 total_equivalent_derate = total_equivalent_derate_and_outage_hours - downtime_hours @@ -86,4 +88,44 @@ def calculate_derating(data_list, max_flow_rate: float = 660) -> float: total_time_below_max += time_interval print(f"Derating hours: {time_interval:.2f}") - return total_time_below_max \ No newline at end of file + return total_time_below_max + + +def stream_large_array(filepath, key): + with open(filepath, "r") as f: + buffer = "" + depth = 0 + inside_string = False + in_target_array = False + + while True: + chunk = f.read(8192) + if not chunk: + break + + for char in chunk: + buffer += char + + if not in_target_array and f'"{key}": [' in buffer: + in_target_array = True + buffer = "" + continue + + if in_target_array: + if char == '"' and (len(buffer) < 2 or buffer[-2] != '\\'): + inside_string = not inside_string + if not inside_string: + if char == '{': + depth += 1 + elif char == '}': + depth -= 1 + if depth == 0: + try: + obj = json.loads(buffer) + yield obj + except Exception: + pass + buffer = "" + + if char == ']' and depth == 0: + return \ No newline at end of file