import streamlit as st import pandas as pd import matplotlib import matplotlib.pyplot as plt import plotly.express as px import numpy as np import plotly.graph_objects as go import sqlite3 from typing import Optional, Dict, Any from datetime import datetime, timedelta import re from pathlib import Path # from blend_logic import run_dummy_prediction ##---- fucntions ------ # Load fuel data from CSV (create this file if it doesn't exist) FUEL_CSV_PATH = "fuel_properties.csv" def load_fuel_data(): """Load fuel data from CSV or create default if not exists""" try: df = pd.read_csv(FUEL_CSV_PATH, index_col=0) return df.to_dict('index') except FileNotFoundError: # Create default fuel properties if file doesn't exist default_fuels = { "Gasoline": {f"Property{i+1}": round(0.7 + (i*0.02), 1) for i in range(10)}, "Diesel": {f"Property{i+1}": round(0.8 + (i*0.02), 1) for i in range(10)}, "Ethanol": {f"Property{i+1}": round(0.75 + (i*0.02), 1) for i in range(10)}, "Biodiesel": {f"Property{i+1}": round(0.85 + (i*0.02), 1) for i in range(10)}, "Jet Fuel": {f"Property{i+1}": round(0.78 + (i*0.02), 1) for i in range(10)} } pd.DataFrame(default_fuels).T.to_csv(FUEL_CSV_PATH) return default_fuels # Initialize or load fuel data if 'FUEL_PROPERTIES' not in st.session_state: st.session_state.FUEL_PROPERTIES = load_fuel_data() def save_fuel_data(): """Save current fuel data to CSV""" pd.DataFrame(st.session_state.FUEL_PROPERTIES).T.to_csv(FUEL_CSV_PATH) # FUEL_PROPERTIES = st.session_state.FUEL_PROPERTIES # ---------------------- Page Config ---------------------- st.set_page_config( layout="wide", page_title="Eagle Blend Optimizer", page_icon="๐ฆ ", initial_sidebar_state="expanded" ) # ---------------------- Custom Styling ---------------------- ##e0e0e0; st.markdown(""" """, unsafe_allow_html=True) # ---------------------- App Header ---------------------- st.markdown("""
1. Name Your Blend: Start by giving your new blend a unique name.
2. Configure Components: For each of the 5 components, you can either:
3. Predict: Once all components are defined and their fractions sum to 1.0, click the Predict button. This will calculate the final blend's properties and cost.
4. Analyze Results: Review the KPI cards for the predicted properties and cost. Use the charts to visualize the blend's composition and compare component properties against the final blend.
5. Save & Download: If you are satisfied with the result, you can save the complete blend recipe to the database or download all the input and output data as a CSV file.