Skip to content

Commit b31f9b1

Browse files
committed
Fixing bio new file format
1 parent 64c0296 commit b31f9b1

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

navani/echem.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ def biologic_processing(df):
144144
# Dealing with the different column layouts for biologic files
145145

146146
def bio_state(x):
147-
if x > 0:
148-
return 0
149-
elif x < 0:
150-
return 1
151-
elif x == 0:
152-
return 'R'
153-
else:
154-
print(x)
155-
raise ValueError('Unexpected value in current - not a number')
147+
if x > 0:
148+
return 0
149+
elif x < 0:
150+
return 1
151+
elif x == 0:
152+
return 'R'
153+
else:
154+
print(x)
155+
raise ValueError('Unexpected value in current - not a number')
156156

157157
# Adding current column that galvani can't export for some reason
158158
if ('time/s' in df.columns) and ('dQ/mA.h' in df.columns):
@@ -174,9 +174,10 @@ def bio_state(x):
174174

175175
df['state'] = df['Current'].map(lambda x: bio_state(x))
176176

177-
elif('I/mA' in df.columns):
177+
elif('I/mA' in df.columns) and ('Q charge/discharge/mA.h' not in df.columns) and ('dQ/mA.h' not in df.columns) and ('Ewe/V' in df.columns):
178178
df['Current'] = df['I/mA']
179-
df['state'] = df['Current'].map(lambda x: bio_state(x))
179+
df['dV'] = np.diff(df['Ewe/V'], prepend=df['Ewe/V'][0])
180+
df['state'] = df['dV'].map(lambda x: bio_state(x))
180181

181182
not_rest_idx = df[df['state'] != 'R'].index
182183
df['cycle change'] = False
@@ -202,7 +203,13 @@ def bio_state(x):
202203
df.rename(columns = {'Half cycle cap':'Capacity'}, inplace = True)
203204
df.rename(columns = {'Ewe/V':'Voltage'}, inplace = True)
204205
return df
205-
206+
elif ('(Q-Qo)/C' in df.columns) and ('half cycle') in df.columns:
207+
for cycle in df['half cycle'].unique():
208+
mask = df['half cycle'] == cycle
209+
cycle_idx = df.index[mask]
210+
df.loc[cycle_idx, 'Capacity'] = df.loc[cycle_idx, '(Q-Qo)/C'] - df.loc[cycle_idx[0], '(Q-Qo)/C']
211+
df.rename(columns = {'Ewe/V':'Voltage'}, inplace = True)
212+
return df
206213
else:
207214
print('Unknown column layout')
208215
return None

0 commit comments

Comments
 (0)