refactor: Refactor plot_spectra function in app.py for improved readability and performance
Browse files
app.py
CHANGED
@@ -99,7 +99,7 @@ def send_and_receive(client, command_topic, msg, queue_timeout=60):
|
|
99 |
return sensor_data
|
100 |
|
101 |
|
102 |
-
#
|
103 |
def plot_spectra(sensor_data):
|
104 |
"""https://chatgpt.com/share/210d2fee-ca64-45a5-866e-e6df6e56bd1c"""
|
105 |
wavelengths = np.array([410, 440, 470, 510, 550, 583, 620, 670])
|
@@ -155,7 +155,7 @@ def plot_spectra(sensor_data):
|
|
155 |
ax.set_ylabel("Intensity")
|
156 |
ax.set_title("Spectral Intensity vs. Wavelength")
|
157 |
|
158 |
-
|
159 |
|
160 |
|
161 |
# Publish button
|
|
|
99 |
return sensor_data
|
100 |
|
101 |
|
102 |
+
# helper function to plot discrete spectral sensor data
|
103 |
def plot_spectra(sensor_data):
|
104 |
"""https://chatgpt.com/share/210d2fee-ca64-45a5-866e-e6df6e56bd1c"""
|
105 |
wavelengths = np.array([410, 440, 470, 510, 550, 583, 620, 670])
|
|
|
155 |
ax.set_ylabel("Intensity")
|
156 |
ax.set_title("Spectral Intensity vs. Wavelength")
|
157 |
|
158 |
+
st.pyplot(fig)
|
159 |
|
160 |
|
161 |
# Publish button
|