Skip to content

Commit

Permalink
Catch neware reader warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Feb 8, 2024
1 parent 7c21592 commit 54de421
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion navani/echem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from NewareNDA.NewareNDA import read
import pandas as pd
import numpy as np
import warnings
from scipy.signal import savgol_filter
import sqlite3
import os
Expand Down Expand Up @@ -343,7 +344,13 @@ def arbin_state(x):

def neware_reader(filename: Union[str, Path]) -> pd.DataFrame:
filename = str(filename)
df = read(filename)
# capture any warnings from NewareNDA and handle the ones about autoscaling
with warnings.catch_warnings(record=True) as w:
df = read(filename, error_on_missing=False)
if w:
for warning in w:
if "autoscale" in str(warning.message):
print(f"Warning: {warning.message}")

# remap to expected navani columns and units
df.set_index("Index", inplace=True)
Expand Down

0 comments on commit 54de421

Please sign in to comment.