Skip to content

Commit

Permalink
change plot symbol selection, add 'letters' option
Browse files Browse the repository at this point in the history
  • Loading branch information
jgieseler committed Nov 3, 2023
1 parent cbf547b commit 8ef5317
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ numpy
parfive==1.5.1 # can be removed if https://github.com/Cadair/parfive/issues/132 is fixed
pyshorteners
scipy
speasy
solarmach>=0.2.3
speasy>=1.2.0
solarmach>=0.3.1
stqdm
streamlit
streamlit-analytics
Expand Down
26 changes: 21 additions & 5 deletions streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,20 @@ def obtain_vsw(body_list, date):
st.sidebar.checkbox('Transparent background', value=False, key='def_transparent') # , on_change=clear_url)
st.session_state["plot_trans"] = [1] if st.session_state.def_transparent else [0]

# catch old URL query parameter plot_nr for numberd_markers:
if ("plot_nr" in query_params) and int(query_params["plot_nr"][0]) == 1:
st.session_state.def_numbered = True
st.sidebar.checkbox('Numbered symbols', value=False, key='def_numbered') # , on_change=clear_url)
st.session_state["plot_nr"] = [1] if st.session_state.def_numbered else [0]
st.session_state.def_markers = "Numbers"
if ("plot_nr" in query_params) and int(query_params["plot_nr"][0]) == 0:
st.session_state.def_markers = "Squares"
#
if ("plot_markers" in query_params):
st.session_state.def_markers = st.session_state.plot_markers[0].capitalize()
# st.sidebar.checkbox('Numbered symbols', value=False, key='def_numbered')
st.sidebar.radio("Plot symbol style", ["Letters", "Numbers", "Squares"], index=1, key='def_markers', horizontal=True)
# st.session_state["plot_nr"] = [1] if st.session_state.def_numbered else [0]
st.session_state["plot_markers"] = [st.session_state.def_markers]



if ("long_offset" in query_params):
st.session_state.def_long_offset = int(st.session_state["long_offset"][0])
Expand Down Expand Up @@ -263,7 +273,7 @@ def obtain_vsw(body_list, date):
url = 'https://solar-mach.streamlit.app/?embedded=true&'

# Get all the parameters from st.session_state and store them in set_query_params so you can build the url
for p in ["date", "time", "coord_sys", "plot_spirals", "plot_sun_body_line", "plot_trans", "plot_nr",
for p in ["date", "time", "coord_sys", "plot_spirals", "plot_sun_body_line", "plot_trans", "plot_markers",
"long_offset", "reference_long", "reference_lat", "reference_vsw", "plot_reference", "bodies", "speeds"]:
if p in st.session_state:
set_query_params[p] = st.session_state[p]
Expand All @@ -290,12 +300,18 @@ def obtain_vsw(body_list, date):
# make the longitudinal constellation plot
filename = 'Solar-MACH_'+datetime.datetime.combine(st.session_state.date_input, st.session_state.time_input).strftime("%Y-%m-%d_%H-%M-%S")

if st.session_state.def_markers.lower()=='squares':
markers=False
else:
markers=st.session_state.def_markers.lower()

c.plot(
plot_spirals=st.session_state.def_plot_spirals, # plot Parker spirals for each body
plot_sun_body_line=st.session_state.def_plot_sun_body_line, # plot straight line between Sun and body
reference_vsw=st.session_state.def_reference_vsw, # define solar wind speed at reference
transparent=st.session_state.def_transparent,
numbered_markers=st.session_state.def_numbered,
# numbered_markers=st.session_state.def_numbered,
markers=markers,
long_offset=st.session_state.def_long_offset,
# outfile=filename+'.png' # output file (optional)
)
Expand Down

0 comments on commit 8ef5317

Please sign in to comment.