From eb38832c3fc3ac70eb04a472c3f9899ee92a9f2e Mon Sep 17 00:00:00 2001 From: domna Date: Thu, 10 Aug 2023 19:21:47 +0200 Subject: [PATCH] Adds fix for wvase import when dpolE is present --- src/elli/importer/woollam.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/elli/importer/woollam.py b/src/elli/importer/woollam.py index ce345844..e6d0d286 100644 --- a/src/elli/importer/woollam.py +++ b/src/elli/importer/woollam.py @@ -69,7 +69,7 @@ def scale_to_nm(unit: str, dataframe: pd.DataFrame) -> pd.DataFrame: try: scaling = ureg(unit).to("nm").magnitude dataframe.index = dataframe.index.set_levels( - dataframe.index.levels[1] * scaling, level=1 + dataframe.index.levels[1].astype(float) * scaling, level=1 ) return dataframe @@ -107,10 +107,13 @@ def _read_wvase_dataframe(file_object: TextIO) -> pd.DataFrame: file_object, sep="\t", header=None, - names=["Ψ", "Δ", "Ψ_err", "Δ_err"], - index_col=(1, 0), + names=["Wavelength", "Angle of Incidence", "Ψ", "Δ", "Ψ_err", "Δ_err"], + ) + dframe = ( + dframe[dframe.iloc[:, 0] != "dpolE"] + .set_index(["Wavelength", "Angle of Incidence"]) + .swaplevel(0, 1) ) - dframe.index.names = ("Angle of Incidence", "Wavelength") return dframe