Skip to content

Commit

Permalink
removed np.loadtxt converters
Browse files Browse the repository at this point in the history
  • Loading branch information
mlietzow committed Aug 26, 2024
1 parent 0dca35a commit 3398400
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
12 changes: 3 additions & 9 deletions miex_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
import streamlit as st


def conv(line):
# Converter for lambda/n/k database files
return line.replace(b"D", b"e")


st.set_page_config(page_title="MIEX", page_icon=None)
st.title("MIEX App")
st.write("This app is a Mie scattering code for large grains written in Python and based on [MIEX](https://ui.adsabs.harvard.edu/abs/2018ascl.soft10019W) by [Wolf & Voshchinnikov (2004)](https://ui.adsabs.harvard.edu/abs/2004CoPhC.162..113W).")
Expand Down Expand Up @@ -175,7 +170,7 @@ def conv(line):
format="%d",
step=2,
min_value=1,
disabled=not doSA,
disabled=(not doSA),
)

st.divider()
Expand Down Expand Up @@ -236,9 +231,8 @@ def conv(line):
if fnames[icomp] is None:
st.error("Error: Dust data file missing!")
st.stop()
w, n, k = np.loadtxt(
fnames[icomp], unpack=True, comments="#", converters=conv
)

w, n, k = np.loadtxt(fnames[icomp], comments="#", unpack=True)

if isinstance(w, float):
if nlam == 1:
Expand Down
9 changes: 2 additions & 7 deletions miex_notebook_2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
"# import packages and define functions\n",
"import miex.miex as miex\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"\n",
"def conv(line):\n",
" # converter for lambda/n/k database files\n",
" return line.replace(b\"D\", b\"e\")"
"import matplotlib.pyplot as plt"
]
},
{
Expand All @@ -45,7 +40,7 @@
"\n",
"# OR use a dust data file (three columns: wavelength/micron real imag)\n",
"filename = \"ri-data/silicate\"\n",
"wavelength, ri_real, ri_imag = np.loadtxt(filename, unpack=True, comments=\"#\", converters=conv)\n",
"wavelength, ri_real, ri_imag = np.loadtxt(filename, unpack=True, comments=\"#\")\n",
"\n",
"nlam = len(wavelength)"
]
Expand Down
6 changes: 0 additions & 6 deletions run_miex.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
# ====================================================================================================


def conv(line):
# Converter for lambda/n/k database files
return line.replace(b"D", b"e")


def main(input_filename):
# ---------------------------------------------------------------------------------------------------
# 0. General settings
Expand Down Expand Up @@ -169,7 +164,6 @@ def main(input_filename):
"ri-data/" + fnames[icomp],
comments="#",
unpack=True,
converters=conv,
)
if icomp > 0 and not np.array_equal(wavelength, w[:nlam]):
raise Exception("Wavelength distribution in dust data files do not match.")
Expand Down

0 comments on commit 3398400

Please sign in to comment.