Skip to content

Commit 5ef5337

Browse files
authored
Merge branch 'BenSmithGreyGroup:main' into main
2 parents 51267ea + b31f9b1 commit 5ef5337

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

navani/echem.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,18 @@ def arbin_state(x):
142142

143143
def biologic_processing(df):
144144
# Dealing with the different column layouts for biologic files
145-
145+
146+
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')
156+
146157
# Adding current column that galvani can't export for some reason
147158
if ('time/s' in df.columns) and ('dQ/mA.h' in df.columns):
148159
df['dt'] = np.diff(df['time/s'], prepend=0)
@@ -151,17 +162,6 @@ def biologic_processing(df):
151162
if np.isnan(df['Current'].iloc[0]):
152163
df.loc[df.index[0], 'Current'] = 0
153164

154-
def bio_state(x):
155-
if x > 0:
156-
return 0
157-
elif x < 0:
158-
return 1
159-
elif x == 0:
160-
return 'R'
161-
else:
162-
print(x)
163-
raise ValueError('Unexpected value in current - not a number')
164-
165165
df['state'] = df['Current'].map(lambda x: bio_state(x))
166166

167167
elif ('time/s' in df.columns) and ('Q charge/discharge/mA.h' in df.columns):
@@ -172,19 +172,13 @@ def bio_state(x):
172172
if np.isnan(df['Current'].iloc[0]):
173173
df.loc[df.index[0], 'Current'] = 0
174174

175-
def bio_state(x):
176-
if x > 0:
177-
return 0
178-
elif x < 0:
179-
return 1
180-
elif x == 0:
181-
return 'R'
182-
else:
183-
print(x)
184-
raise ValueError('Unexpected value in current - not a number')
185-
186175
df['state'] = df['Current'].map(lambda x: bio_state(x))
187176

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):
178+
df['Current'] = df['I/mA']
179+
df['dV'] = np.diff(df['Ewe/V'], prepend=df['Ewe/V'][0])
180+
df['state'] = df['dV'].map(lambda x: bio_state(x))
181+
188182
not_rest_idx = df[df['state'] != 'R'].index
189183
df['cycle change'] = False
190184
df.loc[not_rest_idx, 'cycle change'] = df.loc[not_rest_idx, 'state'].ne(df.loc[not_rest_idx, 'state'].shift())
@@ -209,7 +203,13 @@ def bio_state(x):
209203
df.rename(columns = {'Half cycle cap':'Capacity'}, inplace = True)
210204
df.rename(columns = {'Ewe/V':'Voltage'}, inplace = True)
211205
return df
212-
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
213213
else:
214214
print('Unknown column layout')
215215
return None

0 commit comments

Comments
 (0)