Skip to content

Commit

Permalink
Add biologic data functionality (#59)
Browse files Browse the repository at this point in the history
* Added example BioLogic data file. Started working on Bode plot function

* Added loading of data from Biologic ECLab MPT format

* Added loading of data from Biologic ECLab MPT format

* Reverted plotting.py to commit ebdb855

* BioLogic Data files need latin-w specied as their encoding.
  • Loading branch information
lktsui authored and mdmurbach committed Nov 1, 2019
1 parent 7babd5a commit 66b389c
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 49 deletions.
104 changes: 104 additions & 0 deletions data/exampleDataBioLogic.mpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
EC-Lab ASCII FILE
Nb header lines : 61

Potentio Electrochemical Impedance Spectroscopy

Run on channel : 1 (SN 30924)
User :
CE vs. WE compliance from -10 V to 10 V
Electrode connection : standard
Ewe ctrl range : min = -2.50 V, max = 2.50 V
Safety Limits :
Do not start on E overload
Acquisition started on : 02/04/2018 10:02:46
Technique started on : 02/04/2018 10:02:46
Saved on :
File : EIS OCV after.mpr
Directory : C:\Users\shadd\OneDrive\Documents\EC-Lab\Data\Samples\LSC Thin Film Dynamic XAS\eis\
Host : 100.88.9.64
Device : SP-150 (SN 10791079)
Address : USB
EC-Lab for windows v11.18 (software)
Internet server v11.18 (firmware)
Command interpretor v11.16 (firmware)
Electrode material :
Initial state :
Electrolyte :
Comments :
Electrode surface area : 0.001 cm�
Characteristic mass : 0.001 g
Equivalent Weight : 0.000 g/eq.
Density : 0.000 g/cm3
Cycle Definition : Charge/Discharge alternance
Mode Single sine
E (V) 0.0000
vs. Ref
tE (h:m:s) 0:00:0.0000
record 0
dI 0.000
unit dI mA
dt (s) 0.000
fi 1.000
unit fi kHz
ff 10.000
unit ff mHz
Nd 9
Points per decade
spacing Logarithmic
Va (mV) 20.0
pw 0.10
Na 1
corr 0
E range min (V) -2.500
E range max (V) 2.500
I Range Auto
Bandwidth 5
nc cycles 0
goto Ns' 0
nr cycles 0
inc. cycle 0

freq/Hz Re(Z)/Ohm -Im(Z)/Ohm |Z|/Ohm Phase(Z)/deg time/s <Ewe>/V <I>/mA Cs/�F Cp/�F cycle number I Range |Ewe|/V |I|/A Re(Y)/Ohm-1 Im(Y)/Ohm-1 |Y|/Ohm-1 Phase(Y)/deg
1.0003201E+003 6.5470886E+001 3.8998979E-001 6.5472046E+001 -3.4128919E-001 7.836904905780102E-001 -2.8677555E-004 -4.8041187E-002 4.0796973E+002 1.4475133E-002 1.000000000000000E+000 11 2.0979473E-002 3.2043408E-004 1.5273423E-002 9.0979054E-005 1.5273694E-002 3.4128919E-001
7.7024658E+002 6.3611004E+001 1.3082615E+000 6.3624454E+001 -1.1782128E+000 1.023564581904793E+000 -1.5194454E-004 -4.6747018E-002 1.5794133E+002 6.6778518E-002 1.000000000000000E+000 11 2.0540658E-002 3.2284218E-004 1.5713904E-002 3.2318145E-004 1.5717227E-002 1.1782128E+000
5.9291284E+002 6.3786083E+001 -4.9220982E-001 6.3787983E+001 4.4211814E-001 1.263390459964285E+000 -7.4513012E-004 -4.3362688E-002 -5.4535461E+002 -3.2471459E-002 1.000000000000000E+000 11 2.0790689E-002 3.2593426E-004 1.5676467E-002 -1.2096857E-004 1.5676934E-002 -4.4211814E-001
4.5631409E+002 6.6016418E+001 1.1641068E+000 6.6026680E+001 -1.0102260E+000 1.501974258018890E+000 -3.0815601E-004 -4.5148868E-002 2.9961490E+002 9.3134411E-002 1.000000000000000E+000 11 2.1135710E-002 3.2010864E-004 1.5143039E-002 2.6702625E-004 1.5145393E-002 1.0102260E+000
3.5101083E+002 6.4581978E+001 -1.2355437E+000 6.4593796E+001 1.0960149E+000 1.740991762693739E+000 -4.4578550E-004 -4.4659656E-002 -3.6697925E+002 -1.3426912E-001 1.000000000000000E+000 11 2.0873591E-002 3.2315165E-004 1.5478531E-002 -2.9612597E-004 1.5481363E-002 -1.0960149E+000
2.7043265E+002 6.2677181E+001 2.4978859E+000 6.2726936E+001 -2.2822120E+000 1.980250014021294E+000 -3.5031990E-004 -4.3256257E-002 2.3560712E+002 3.7361598E-001 1.000000000000000E+000 11 2.0410474E-002 3.2538612E-004 1.5929470E-002 6.3484022E-004 1.5942115E-002 2.2822120E+000
2.0793719E+002 6.3067787E+001 -1.2588621E+000 6.3080349E+001 1.1434983E+000 2.221791572213988E+000 -8.1646649E-005 -4.5975298E-002 -6.0800867E+002 -2.4214636E-001 1.000000000000000E+000 11 2.0379290E-002 3.2306876E-004 1.5849641E-002 -3.1636612E-004 1.5852798E-002 -1.1434983E+000
1.6025639E+002 6.4594604E+001 1.8496882E+000 6.4621078E+001 -1.6402358E+000 2.461283556855051E+000 -3.8442411E-004 -4.3489099E-002 5.3691589E+002 4.3990093E-001 1.000000000000000E+000 11 2.0884346E-002 3.2318165E-004 1.5468487E-002 4.4294534E-004 1.5474827E-002 1.6402358E+000
1.2330331E+002 6.4560471E+001 -3.1567256E+000 6.4637596E+001 2.7992847E+000 2.703672688439838E+000 -4.8565463E-004 -4.6270505E-002 -4.0889194E+002 -9.7524077E-001 1.000000000000000E+000 11 2.0499757E-002 3.1714913E-004 1.5452412E-002 -7.5555564E-004 1.5470873E-002 -2.7992847E+000
9.4908844E+001 6.3480858E+001 1.6610308E+000 6.3502586E+001 -1.4988508E+000 2.942820539785316E+000 -3.8451736E-004 -4.4392087E-002 1.0095685E+003 6.9072998E-001 1.000000000000000E+000 11 2.0590926E-002 3.2425334E-004 1.5742002E-002 4.1190290E-004 1.5747391E-002 1.4988508E+000
7.3059525E+001 6.2966324E+001 5.2031708E-001 6.2968475E+001 -4.7344822E-001 3.188471964764176E+000 -2.7130955E-004 -4.5604751E-002 4.1867324E+003 2.8586766E-001 1.000000000000000E+000 11 2.0577567E-002 3.2679157E-004 1.5880421E-002 1.3122655E-004 1.5880963E-002 4.7344822E-001
5.6241814E+001 5.7859802E+001 9.9445152E-001 5.7868347E+001 -9.8466057E-001 3.422752882586792E+000 -1.0407178E-004 -4.4780090E-002 2.8456221E+003 8.4035397E-001 1.000000000000000E+000 11 2.0143228E-002 3.4808714E-004 1.7278053E-002 2.9696242E-004 1.7280605E-002 9.8466057E-001
4.3295860E+001 6.3966675E+001 1.3191714E+000 6.3980274E+001 -1.1814315E+000 3.671299161011120E+000 -2.6906142E-004 -4.4787843E-002 2.7865864E+003 1.1846302E+000 1.000000000000000E+000 11 2.0901790E-002 3.2669117E-004 1.5626494E-002 3.2226194E-004 1.5629817E-002 1.1814315E+000
3.3346024E+001 6.5947289E+001 9.2110091E-001 6.5953720E+001 -8.0021131E-001 3.921533039567294E+000 -2.2575019E-004 -4.3758258E-002 5.1816597E+003 1.0106591E+000 1.000000000000000E+000 11 2.0938896E-002 3.1747861E-004 1.5160668E-002 2.1175254E-004 1.5162147E-002 8.0021131E-001
2.5665239E+001 6.3702545E+001 1.7817245E+000 6.3727459E+001 -1.6021131E+000 4.154926330695162E+000 -9.5601783E-005 -4.6195067E-002 3.4804409E+003 2.7205839E+000 1.000000000000000E+000 11 2.0358242E-002 3.1945793E-004 1.5685689E-002 4.3871990E-004 1.5691822E-002 1.6021131E+000
1.9753477E+001 6.5081535E+001 2.1123164E+000 6.5115807E+001 -1.8589658E+000 4.397345302189933E+000 -2.1638442E-004 -4.1474000E-002 3.8143242E+003 4.0138645E+000 1.000000000000000E+000 11 2.0845771E-002 3.2013381E-004 1.5349172E-002 4.9817981E-004 1.5357254E-002 1.8589658E+000
1.5199414E+001 6.3539898E+001 4.5586529E+000 6.3703217E+001 -4.1036391E+000 4.633730913439649E+000 9.0237538E-004 -3.3789847E-002 2.2969775E+003 1.1762701E+001 1.000000000000000E+000 11 2.0587701E-002 3.2318151E-004 1.5657548E-002 1.1233466E-003 1.5697794E-002 4.1036391E+000
1.1695360E+001 6.3876205E+001 1.0484103E+000 6.3884808E+001 -9.4032025E-001 4.841729163323180E+000 -4.0071129E-004 -4.6839628E-002 1.2980017E+004 3.4957681E+000 1.000000000000000E+000 11 2.0466087E-002 3.2035922E-004 1.5651066E-002 2.5688342E-004 1.5653174E-002 9.4032025E-001
9.0005779E+000 6.4856674E+001 2.2519822E+000 6.4895760E+001 -1.9886506E+000 5.106054535863223E+000 -1.7444455E-004 -4.4451091E-002 7.8520815E+003 9.4554462E+000 1.000000000000000E+000 11 2.0855276E-002 3.2136578E-004 1.5400046E-002 5.3472724E-004 1.5409327E-002 1.9886506E+000
6.9382758E+000 6.6270004E+001 4.8155041E+000 6.6444733E+001 -4.1560884E+000 5.284150250983657E+000 -5.1673641E-004 -4.2596571E-002 4.7635073E+003 2.5020111E+001 1.000000000000000E+000 11 2.1021318E-002 3.1637299E-004 1.5010525E-002 1.0907386E-003 1.5050102E-002 4.1560884E+000
5.3364062E+000 6.0613422E+001 7.0270448E+000 6.1019394E+001 -6.6129022E+000 5.511760181805585E+000 -5.3050503E-004 -4.4840775E-002 4.2442261E+003 5.6287014E+001 1.000000000000000E+000 11 2.0068668E-002 3.2888999E-004 1.6279198E-002 1.8872826E-003 1.6388232E-002 6.6129022E+000
4.1118407E+000 6.5389824E+001 5.1409044E+000 6.5591599E+001 -4.4953094E+000 5.799166702112416E+000 -2.5830572E-004 -4.4575538E-002 7.5291216E+003 4.6251621E+001 1.000000000000000E+000 11 2.0706074E-002 3.1568180E-004 1.5198955E-002 1.1949317E-003 1.5245855E-002 4.4953094E+000
3.1603959E+000 6.5957474E+001 6.4717007E+000 6.6274216E+001 -5.6038833E+000 6.165715492876188E+000 -2.5586769E-004 -4.1634265E-002 7.7814443E+003 7.4200676E+001 1.000000000000000E+000 11 2.0657677E-002 3.1170005E-004 1.5016712E-002 1.4734290E-003 1.5088825E-002 5.6038833E+000
2.4353178E+000 6.6105698E+001 8.3983793E+000 6.6637047E+001 -7.2403388E+000 7.091491243481869E+000 -2.5227055E-004 -4.5968611E-002 7.7816021E+003 1.2360285E+002 1.000000000000000E+000 12 2.0532459E-002 3.0812377E-004 1.4887007E-002 1.8913157E-003 1.5006667E-002 7.2403388E+000
1.8735006E+000 6.7790421E+001 9.3406420E+000 6.8430908E+001 -7.8452168E+000 7.695733512213337E+000 -2.3840250E-004 -4.9602441E-002 9.0947256E+003 1.6944878E+002 1.000000000000000E+000 12 2.0631243E-002 3.0149010E-004 1.4476506E-002 1.9946748E-003 1.4613280E-002 7.8452168E+000
1.4435508E+000 6.8793274E+001 1.2584828E+001 6.9934914E+001 -1.0366881E+001 8.474704402549833E+000 -2.6629356E-004 -4.8265681E-002 8.7607393E+003 2.8369214E+002 1.000000000000000E+000 12 2.0631682E-002 2.9501261E-004 1.4065588E-002 2.5731151E-003 1.4299010E-002 1.0366881E+001
1.1097296E+000 7.0818695E+001 1.4015121E+001 7.2192184E+001 -1.1194271E+001 9.482888423750410E+000 -2.8385382E-004 -4.6256147E-002 1.0233073E+004 3.8567319E+002 1.000000000000000E+000 12 2.0676859E-002 2.8641408E-004 1.3588376E-002 2.6891590E-003 1.3851915E-002 1.1194271E+001
8.5569519E-001 7.3593681E+001 1.6304792E+001 7.5378220E+001 -1.2492184E+001 1.078522027222789E+001 -2.2798174E-004 -4.4691723E-002 1.1407376E+004 5.3373364E+002 1.000000000000000E+000 12 2.0671895E-002 2.7424228E-004 1.2952357E-002 2.8696144E-003 1.3266432E-002 1.2492184E+001
6.5806097E-001 7.7258682E+001 1.8608200E+001 7.9468040E+001 -1.3542087E+001 1.247328605907387E+001 -2.3022603E-004 -4.4709988E-002 1.2997194E+004 7.1264520E+002 1.000000000000000E+000 12 2.0611921E-002 2.5937372E-004 1.2233825E-002 2.9465877E-003 1.2583675E-002 1.3542087E+001
5.0638443E-001 8.1968651E+001 2.0657204E+001 8.4531532E+001 -1.4144769E+001 1.466198717639782E+001 -2.6393970E-004 -4.5334160E-002 1.5214870E+004 9.0860236E+002 1.000000000000000E+000 12 2.0720711E-002 2.4512404E-004 1.1471239E-002 2.8909065E-003 1.1829905E-002 1.4144769E+001
3.8965085E-001 8.6686745E+001 2.1498911E+001 8.9312904E+001 -1.3928714E+001 1.750188021795475E+001 -3.2005640E-004 -4.5885794E-002 1.8998883E+004 1.1008612E+003 1.000000000000000E+000 12 2.0682929E-002 2.3157828E-004 1.0867365E-002 2.6951814E-003 1.1196590E-002 1.3928714E+001
2.9992697E-001 9.2175919E+001 2.1338537E+001 9.4613602E+001 -1.3034252E+001 2.118497017957270E+001 -2.4967210E-004 -4.5876503E-002 2.4867949E+004 1.2649172E+003 1.000000000000000E+000 12 2.0666899E-002 2.1843475E-004 1.0296991E-002 2.3837325E-003 1.0569305E-002 1.3034252E+001
2.3078397E-001 9.6659569E+001 1.9389862E+001 9.8585190E+001 -1.1342957E+001 2.596847926007467E+001 -2.1849413E-004 -4.5806799E-002 3.5566387E+004 1.3758334E+003 1.000000000000000E+000 12 2.0514278E-002 2.0808681E-004 9.9453824E-003 1.9950387E-003 1.0143511E-002 1.1342957E+001
1.7773455E-001 1.0135281E+002 1.7685032E+001 1.0288417E+002 -9.8978796E+000 3.217531640824745E+001 -2.7801958E-004 -4.5361456E-002 5.0634020E+004 1.4960874E+003 1.000000000000000E+000 12 2.0630637E-002 2.0052295E-004 9.5749972E-003 1.6707394E-003 9.7196680E-003 9.8978796E+000
1.3685971E-001 1.0487324E+002 1.4734948E+001 1.0590333E+002 -7.9978442E+000 4.023156292419299E+001 -2.8862839E-004 -4.5373376E-002 7.8921602E+004 1.5278259E+003 1.000000000000000E+000 12 2.0701602E-002 1.9547640E-004 9.3507292E-003 1.3138006E-003 9.4425743E-003 7.9978442E+000
1.0535786E-001 1.0643014E+002 1.2445711E+001 1.0715536E+002 -6.6697531E+000 5.069225056775031E+001 -3.2512844E-004 -4.6334777E-002 1.2137618E+005 1.6373636E+003 1.000000000000000E+000 12 2.0622525E-002 1.9245445E-004 9.2690848E-003 1.0839067E-003 9.3322443E-003 6.6697531E+000
8.1177264E-002 1.0825275E+002 9.8288803E+000 1.0869805E+002 -5.1879830E+000 6.426458385228761E+001 -2.7158897E-004 -4.6403907E-002 1.9947188E+005 1.6309711E+003 1.000000000000000E+000 12 2.0676991E-002 1.9022412E-004 9.1621093E-003 8.3187973E-004 9.1997972E-003 5.1879830E+000
6.2444042E-002 1.0905769E+002 7.8290782E+000 1.0933835E+002 -4.1061287E+000 8.190427154357894E+001 -2.9753472E-004 -4.6381809E-002 3.2555059E+005 1.6691476E+003 1.000000000000000E+000 12 2.0652365E-002 1.8888492E-004 9.1224452E-003 6.5488584E-004 9.1459220E-003 4.1061287E+000
4.8106518E-002 1.0965545E+002 5.8287849E+000 1.0981026E+002 -3.0427196E+000 1.047969864975894E+002 -2.7181290E-004 -4.6593346E-002 5.6759450E+005 1.5992208E+003 1.000000000000000E+000 12 2.0665042E-002 1.8818863E-004 9.0937791E-003 4.8338398E-004 9.1066174E-003 3.0427196E+000
3.7039053E-002 1.1001928E+002 4.7268991E+000 1.1012077E+002 -2.4601591E+000 1.345257991363178E+002 -2.6343847E-004 -4.6538346E-002 9.0904188E+005 1.6749355E+003 1.000000000000000E+000 12 2.0656547E-002 1.8758084E-004 9.0725692E-003 3.8979642E-004 9.0809390E-003 2.4601591E+000
2.8483247E-002 1.1061794E+002 3.7406499E+000 1.1068118E+002 -1.9367727E+000 1.731803454789624E+002 -2.9081272E-004 -4.6354901E-002 1.4937694E+006 1.7062009E+003 1.000000000000000E+000 12 2.0677306E-002 1.8681864E-004 9.0297991E-003 3.0535116E-004 9.0349605E-003 1.9367727E+000
2.1945218E-002 1.1078029E+002 2.8922150E+000 1.1081804E+002 -1.4955194E+000 2.233466787150901E+002 -2.8049920E-004 -4.5970257E-002 2.5075503E+006 1.7080079E+003 1.000000000000000E+000 12 2.0674316E-002 1.8656092E-004 9.0207281E-003 2.3551015E-004 9.0238014E-003 1.4955194E+000
1.6895540E-002 1.1097003E+002 2.3458567E+000 1.1099483E+002 -1.2110267E+000 2.885022309564229E+002 -2.8034937E-004 -4.5939464E-002 4.0155640E+006 1.7936761E+003 1.000000000000000E+000 12 2.0680824E-002 1.8632242E-004 9.0074167E-003 1.9041274E-004 9.0094293E-003 1.2110267E+000
42 changes: 41 additions & 1 deletion impedance/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def readFile(filename, instrument=None):
"""

supported_types = ['gamry', 'autolab', 'parstat', 'zplot', 'versastudio'
'powersuite']
'powersuite', 'biologic']

if instrument is not None:
assert instrument in supported_types,\
Expand All @@ -36,6 +36,8 @@ def readFile(filename, instrument=None):
f, Z = readGamry(filename)
elif instrument == 'autolab':
f, Z = readAutolab(filename)
elif instrument == 'biologic':
f, Z = readBioLogic(filename)
elif instrument == 'parstat':
f, Z = readParstat(filename)
elif instrument == 'zplot':
Expand Down Expand Up @@ -114,6 +116,44 @@ def readAutolab(filename):
return np.array(f), np.array(Z)


def readBioLogic(filename):
""" function for reading the .mpt file from Biologic
EC-lab software
Parameters
----------
filename: string
Filename of .csv file to extract impedance data from
Returns
-------
frequencies : np.ndarray
Array of frequencies
impedance : np.ndarray of complex numbers
Array of complex impedances
"""

with open(filename, 'r', encoding="latin-1") as input_file:
lines = input_file.readlines()

header_line = lines[1]

# MPT data format has variable number of header lines
number_header_lines = int(header_line.split(":")[1])

raw_data = lines[number_header_lines:]
f, Z = [], []
for line in raw_data:
each = line.split('\t')
f.append(float(each[0]))

# MPT data format saves the imaginary portion as -Im(Z) not Im(Z)
Z.append(complex(float(each[1]), -1*float(each[2])))

return np.array(f), np.array(Z)


def readParstat(filename):
""" function for reading the .txt file from Parstat
Expand Down
Loading

0 comments on commit 66b389c

Please sign in to comment.