Make BATSMALL-read more general and import decimal = ,
This commit is contained in:
parent
df5190667e
commit
cd0eaff25b
2 changed files with 24 additions and 7 deletions
|
|
@ -70,7 +70,9 @@ def read_batsmall(path):
|
||||||
Output:
|
Output:
|
||||||
df: pandas DataFrame containing the data as-is, but without additional NaN-columns.'''
|
df: pandas DataFrame containing the data as-is, but without additional NaN-columns.'''
|
||||||
|
|
||||||
df = pd.read_csv(path, skiprows=2, sep='\t')
|
|
||||||
|
# FIXME Now it is hardcoded that the decimal is a comma. It should do a check, as datasets can vary depending on the system settings of the machine that does the data conversion
|
||||||
|
df = pd.read_csv(path, skiprows=2, sep='\t', decimal=',')
|
||||||
df = df.loc[:, ~df.columns.str.contains('^Unnamed')]
|
df = df.loc[:, ~df.columns.str.contains('^Unnamed')]
|
||||||
|
|
||||||
return df
|
return df
|
||||||
|
|
@ -133,9 +135,11 @@ def process_batsmall_data(df, options=None):
|
||||||
|
|
||||||
df = unit_conversion(df=df, options=options)
|
df = unit_conversion(df=df, options=options)
|
||||||
|
|
||||||
|
|
||||||
if options['splice_cycles']:
|
if options['splice_cycles']:
|
||||||
df = splice_cycles(df=df, options=options)
|
df = splice_cycles(df=df, options=options)
|
||||||
|
|
||||||
|
|
||||||
# Replace NaN with empty string in the Comment-column and then remove all steps where the program changes - this is due to inconsistent values for current
|
# Replace NaN with empty string in the Comment-column and then remove all steps where the program changes - this is due to inconsistent values for current
|
||||||
df[["comment"]] = df[["comment"]].fillna(value={'comment': ''})
|
df[["comment"]] = df[["comment"]].fillna(value={'comment': ''})
|
||||||
df = df[df["comment"].str.contains("program")==False]
|
df = df[df["comment"].str.contains("program")==False]
|
||||||
|
|
@ -694,11 +698,23 @@ def get_old_units(df: pd.DataFrame, options: dict) -> dict:
|
||||||
|
|
||||||
if options['kind'] == 'batsmall':
|
if options['kind'] == 'batsmall':
|
||||||
|
|
||||||
time = df.columns[0].split()[-1].strip('[]')
|
old_units = {}
|
||||||
voltage = df.columns[1].split()[-1].strip('[]')
|
|
||||||
current = df.columns[2].split()[-1].strip('[]')
|
for column in df.columns:
|
||||||
capacity, mass = df.columns[4].split()[-1].strip('[]').split('/')
|
if 'TT [' in column:
|
||||||
old_units = {'time': time, 'current': current, 'voltage': voltage, 'capacity': capacity, 'mass': mass}
|
old_units['time'] = column.split()[-1].strip('[]')
|
||||||
|
elif 'U [' in column:
|
||||||
|
old_units['voltage'] = column.split()[-1].strip('[]')
|
||||||
|
elif 'I [' in column:
|
||||||
|
old_units['current'] = column.split()[-1].strip('[]')
|
||||||
|
elif 'C [' in column:
|
||||||
|
old_units['capacity'], old_units['mass'] = column.split()[-1].strip('[]').split('/')
|
||||||
|
|
||||||
|
# time = df.columns[0].split()[-1].strip('[]')
|
||||||
|
# voltage = df.columns[1].split()[-1].strip('[]')
|
||||||
|
# current = df.columns[2].split()[-1].strip('[]')
|
||||||
|
# capacity, mass = df.columns[4].split()[-1].strip('[]').split('/')
|
||||||
|
# old_units = {'time': time, 'current': current, 'voltage': voltage, 'capacity': capacity, 'mass': mass}
|
||||||
|
|
||||||
if options['kind']=='neware':
|
if options['kind']=='neware':
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ def plot_gc(data, options=None):
|
||||||
|
|
||||||
|
|
||||||
# Update options
|
# Update options
|
||||||
required_options = ['force_reload', 'x_vals', 'y_vals', 'which_cycles', 'limit', 'exclude_cycles', 'show_plot', 'charge', 'discharge', 'colours', 'differentiate_charge_discharge', 'gradient', 'interactive', 'interactive_session_active', 'rc_params', 'format_params', 'save_gif', 'save_path', 'fps']
|
required_options = ['force_reload', 'x_vals', 'y_vals', 'which_cycles', 'limit', 'exclude_cycles', 'show_plot', 'summary', 'charge', 'discharge', 'colours', 'differentiate_charge_discharge', 'gradient', 'interactive', 'interactive_session_active', 'rc_params', 'format_params', 'save_gif', 'save_path', 'fps']
|
||||||
default_options = {
|
default_options = {
|
||||||
'force_reload': False,
|
'force_reload': False,
|
||||||
'x_vals': 'capacity', 'y_vals': 'voltage',
|
'x_vals': 'capacity', 'y_vals': 'voltage',
|
||||||
|
|
@ -31,6 +31,7 @@ def plot_gc(data, options=None):
|
||||||
'limit': None, # Limit line to be drawn
|
'limit': None, # Limit line to be drawn
|
||||||
'exclude_cycles': [],
|
'exclude_cycles': [],
|
||||||
'show_plot': True,
|
'show_plot': True,
|
||||||
|
'summary': False,
|
||||||
'charge': True, 'discharge': True,
|
'charge': True, 'discharge': True,
|
||||||
'colours': None,
|
'colours': None,
|
||||||
'differentiate_charge_discharge': True,
|
'differentiate_charge_discharge': True,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue