Skip to content

Commit

Permalink
re-arranged elements
Browse files Browse the repository at this point in the history
  • Loading branch information
mlietzow committed Aug 27, 2024
1 parent f6cb1a4 commit 8e4a543
Showing 1 changed file with 57 additions and 42 deletions.
99 changes: 57 additions & 42 deletions miex_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
ncomp = 1
abun = np.array([1.0])

col1, col2 = st.columns(2)
if radio_wavelength == "single":
col1, col2 = st.columns(2)
with col1:
Expand All @@ -56,6 +55,15 @@
min_value=0.0,
)
)
input_ri_imag = float(
st.number_input(
"Imaginary part of refractive index:",
value=0.0,
format="%.6e",
min_value=0.0,
)
)
with col2:
lammin = float(
st.number_input(
"Wavelength $\\lambda$ [micron]:",
Expand All @@ -66,19 +74,12 @@
)
)
lammax = lammin
with col2:
input_ri_imag = float(
st.number_input(
"Imaginary part of refractive index:",
value=0.0,
format="%.6e",
min_value=0.0,
)
)

else:
st.info(
"All data files have to contain three columns (wavelength/micron real imag). Values are log-linearly interpolated and mixed with the Bruggeman formula. See https://github.com/mlietzow/MIEX-Python/tree/main/ri-data for exemplary files."
)
col1, col2 = st.columns(2)
with col1:
lammin = float(
st.number_input(
Expand All @@ -87,23 +88,14 @@
format="%.6e",
)
)
ncomp = int(
st.number_input(
"Number of chemical components:",
value=1,
format="%d",
step=1,
min_value=1
)
)
with col2:
lammax = float(
st.number_input(
"Maximum wavelength $\\lambda_{\\rm max}$ [micron]:",
value=10.0,
format="%.6e",
)
)
with col2:
nlam = int(
st.number_input(
"Number of wavelength bins:",
Expand All @@ -113,7 +105,18 @@
min_value=1
)
)
st.write("")
ncomp = int(
st.number_input(
"Number of chemical components:",
value=1,
format="%d",
step=1,
min_value=1
)
)

st.divider()
col1, col2 = st.columns(2)

abun = np.ones(ncomp) * 100.0
for icomp in range(ncomp):
Expand Down Expand Up @@ -156,7 +159,7 @@
exponent = 0.0
parameter2 = 1.0
nrad = 1
dist_type = ""
dist_type = "Power law"

col1, col2 = st.columns(2)
if radio_grain == "single":
Expand All @@ -178,8 +181,8 @@
horizontal=True,
)
)
st.caption("Power law: $n(r) \\propto r^q$")
st.caption("Power law with exponential decay: $n(r) \\propto r^q \\times \\exp(-r / p)$")
st.write("Power law: $n(r) \\propto r^q$")
st.write("Power law with exponential decay: $n(r) \\propto r^q \\times \\exp(-r / p)$")
with col1:
radmin = float(
st.number_input(
Expand All @@ -188,31 +191,14 @@
format="%.6e",
)
)
exponent = float(
st.number_input(
"Size distribtion exponent $q$",
value=-3.5,
format="%.2f",
max_value=0.0,
)
)
if "exponential" in dist_type:
parameter2 = float(
st.number_input(
"Exponential decay parameter $p$",
value=1.0,
format="%.6e",
min_value=0.0,
)
)
with col2:
radmax = float(
st.number_input(
"Maximum grain size $r_{\\rm max}$ [micron]:",
value=1.0,
format="%.6e",
)
)
with col2:
nrad = int(
st.number_input(
"Number of size bins:",
Expand All @@ -222,6 +208,23 @@
min_value=1
)
)
exponent = float(
st.number_input(
"Size distribtion exponent $q$",
value=-3.5,
format="%.2f",
max_value=0.0,
)
)
parameter2 = float(
st.number_input(
"Exponential decay parameter $p$",
value=1.0,
format="%.6e",
min_value=0.0,
disabled=("exponential" not in dist_type),
)
)

st.divider()

Expand Down Expand Up @@ -597,6 +600,10 @@ def bruggeman_mix(x):

import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams.update({
"xtick.top": True,
"ytick.right": True,
})

if nlam == 1:
data_dict = {
Expand Down Expand Up @@ -654,6 +661,7 @@ def bruggeman_mix(x):
# ax[2].set_yscale("log")
ax[2].set_xlabel("wavelength [micron]")
ax[2].set_xscale("log")
ax[2].set_xlim(wavelength[0], wavelength[-1])
ax[2].legend()

st.pyplot(fig, use_container_width=True)
Expand Down Expand Up @@ -686,6 +694,9 @@ def bruggeman_mix(x):
ax[1, 1].yaxis.set_label_position("right")
ax[1, 1].yaxis.tick_right()

ax[1, 1].set_xlim(0, 180)
ax[1, 1].set_xticks(np.arange(0, 181, 45))

else:
fig, ax = plt.subplots(
2,
Expand Down Expand Up @@ -747,6 +758,10 @@ def bruggeman_mix(x):
ax[1, 1].set_xlabel("scattering angle [deg]")
fig.colorbar(im, ax=ax[1, 1])

ax[1, 1].set_xlim(0, 180)
ax[1, 1].set_xticks(np.arange(0, 181, 45))
ax[1, 1].set_ylim(wavelength[0], wavelength[-1])

st.pyplot(fig, use_container_width=True)

with placeholder.container():
Expand Down

0 comments on commit 8e4a543

Please sign in to comment.