Spaces:
Build error
Build error
| import streamlit as st | |
| import pandas as pd | |
| import random | |
| import time | |
| st.title("π Astronaut Survival Monitor") | |
| # Simulating real-time data updates | |
| def get_real_time_data(): | |
| return { | |
| "Heart Rate (BPM)": random.randint(60, 120), | |
| "Oxygen Saturation (%)": round(random.uniform(85, 100), 1), | |
| "Blood Pressure (mmHg)": f"{random.randint(90, 120)}/{random.randint(60, 80)}", | |
| "Respiratory Rate (BPM)": random.randint(12, 20), | |
| "Hydration Level (%)": round(random.uniform(40, 100), 1), | |
| "Battery Level (%)": random.randint(10, 100), | |
| "Food Supply (Days)": random.randint(1, 10), | |
| "Water Supply (Liters)": random.randint(1, 50), | |
| } | |
| # Survival Time Prediction | |
| def predict_survival_time(data): | |
| oxygen_factor = data["Oxygen Saturation (%)"] / 100 | |
| hydration_factor = data["Hydration Level (%)"] / 100 | |
| battery_factor = data["Battery Level (%)"] / 100 | |
| food_factor = data["Food Supply (Days)"] / 10 | |
| survival_hours = (oxygen_factor + hydration_factor + battery_factor + food_factor) * 10 | |
| return round(survival_hours, 2) | |
| # Real-time simulation | |
| data = get_real_time_data() | |
| survival_time = predict_survival_time(data) | |
| st.metric("Predicted Survival Time", f"{survival_time} Hours") | |
| # Display real-time health and resource data | |
| st.write("### Health Metrics") | |
| for key, value in data.items(): | |
| st.metric(key, value) | |
| if data["Oxygen Saturation (%)"] < 90 or data["Battery Level (%)"] < 20: | |
| st.warning("π¨ Alert: Low Oxygen or Power Levels Detected!") | |