martes, 20 de octubre de 2026

app_template.py

import streamlit as st

from utils import retrieve

import json

import pandas as pd


st.set_page_config(page_title="Monitoring System", layout="centered")

st.title("Rabbit Monitoring System")

st.logo("logo.jpg")


data=retrieve.retrieve()

with open("data.json","w",encoding="utf-8") as f:

    json.dump(data,f,indent=4)

timestamp = data["timestamp"]


sht = data["SHT"] 

hc = data["HCSR04"]

temp = sht["temperature"]

hum = sht["humidity"]

dist = hc["distance"]


df = pd.DataFrame({

    "timestamp": timestamp,

    "distance": dist,

    "humidity": hum,

    "temperature": temp,

})


st.header("Temperature and Humidity")


st.text("""To monitor the Ranch rabbits we need to analyze the different situations on the variable. In this case we see how an increase in temperature tends to cause a reduction of humidities, while also we can see that there are two different humidity trends on lower temperatures, one with high humidity, one with low humidity, while the coldest temperatures measured are always on the higher trend.""")

with st.container(border=True,width=600,height=400,horizontal_alignment="center"):

    st.scatter_chart(sht,x="temperature", y="humidity")



st.header("Temperature and Humidity vs. Distance")

st.text("""In this case the HCSR04 can't really directly measure the behavior of rabbits. With our limited implementation, it can't even give us data in real time of when the rabbit passes through places! What we can do with it is measure tendencies of location preference. In the graph we analyze how temperature affects the preference of the rabbits. If the temperature is too cold, or too hot, rabbits won't like the spot. However, with a temperature of around 19ºC rabbits seem to be pretty content.""")


with st.container(border=True,width=600,height=400,horizontal_alignment="center"):

    st.scatter_chart({"temperature":temp,"distance":dist},x="temperature", y="distance")


st.header("Variables changing with time")


st.text("The variation with time of the three variables we considered can be seen next:")


with st.container(border=True, width=600, height=400, horizontal_alignment="center"):

    st.subheader("Temperature over Time")

    st.line_chart(df, x="timestamp", y="temperature")



No hay comentarios:

Publicar un comentario