|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def calculate_eaf(
|
|
|
|
def calculate_eaf(
|
|
|
|
available_hours: float,
|
|
|
|
available_hours: float,
|
|
|
|
period_hours: float,
|
|
|
|
period_hours: float,
|
|
|
|
actual_production: float,
|
|
|
|
actual_production: float,
|
|
|
|
ideal_production: float,
|
|
|
|
ideal_production: float,
|
|
|
|
downtime_hours,
|
|
|
|
downtime_hours,
|
|
|
|
plot_data
|
|
|
|
|
|
|
|
):
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Calculate EAF using the time-based method from PLN document
|
|
|
|
Calculate EAF using the time-based method from PLN document
|
|
|
|
@ -24,7 +26,7 @@ def calculate_eaf(
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# Calculate lost production
|
|
|
|
# Calculate lost production
|
|
|
|
lost_production = ideal_production - actual_production
|
|
|
|
lost_production = ideal_production - actual_production
|
|
|
|
max_capacity = plot_data.max_flow_rate
|
|
|
|
max_capacity = 660
|
|
|
|
# Calculate total equivalent derate and outage hours
|
|
|
|
# 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_and_outage_hours = lost_production / max_capacity if max_capacity > 0 else 0
|
|
|
|
total_equivalent_derate = total_equivalent_derate_and_outage_hours - downtime_hours
|
|
|
|
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
|
|
|
|
total_time_below_max += time_interval
|
|
|
|
print(f"Derating hours: {time_interval:.2f}")
|
|
|
|
print(f"Derating hours: {time_interval:.2f}")
|
|
|
|
|
|
|
|
|
|
|
|
return total_time_below_max
|
|
|
|
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
|