Created
August 3, 2022 22:25
-
-
Save erichare/75201b710cf03888b15c8edde9996698 to your computer and use it in GitHub Desktop.
UI code for the NOAA daisi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
st.title("NOAA Weather API Interface") | |
st.write("This Daisi, powered by the `noaa-sdk` Python package, allows for an interaction with the NOAA API for pulling weather forecast data.") | |
with st.sidebar: | |
cc = st.text_input("Country Code", value="US") | |
pc = st.text_input("Postal Code", value="77001") | |
wx_keys, wx_dat = available_wx_data(cc, pc) | |
vars = st.multiselect("Weather Metrics", options=wx_keys, default=["temperature", "dewpoint"]) | |
tab1, tab2 = st.tabs(["Forecast", "Observations"]) | |
with tab1: | |
with st.spinner(f"Fetching weather forecast for {cc}, please wait..."): | |
my_forc = forecast(country_code=cc, postal_code=pc, vars=vars, dat=None) | |
with st.expander("Inference with PyDaisi", expanded=True): | |
st.markdown(f""" | |
```python | |
import pydaisi as pyd | |
noaa = pyd.Daisi("erichare/NOAA Weather") | |
noaa.forecast(country_code="{cc}", postal_code="{pc}", vars={str(vars)}) | |
``` | |
""") | |
st.json(my_forc) | |
with tab2: | |
with st.spinner(f"Fetching weather observations for {cc}: {pc}, please wait..."): | |
my_obs = observations(country_code=cc, postal_code=pc, vars=vars, dat=None) | |
with st.expander("Inference with PyDaisi", expanded=True): | |
st.markdown(f""" | |
```python | |
import pydaisi as pyd | |
noaa = pyd.Daisi("erichare/NOAA Weather") | |
noaa.observations(country_code="{cc}", postal_code="{pc}", vars={str(vars)}) | |
``` | |
""") | |
st.json(my_obs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment