Load a .pssession file into python for local processing. I do a bunch of Cyclic Voltammetry and Square Wave Voltammetry experiments regularly and wrote this Python script to extact my data for some post-processing. The main purpose is to skip additional export steps from the .pssession file, but I added plotting and baseline tools. I use this device for my measurements.
- Square wave voltammetry (primary)
- Cyclic voltammetry
- Electrical impedance spectroscopy
- PSData.py : this parses the .pssession data
- SimplePSData.py : this is an example file to use the PSData object
- PSDataPlot.py : this is the additional plotting functionality
- SimpleNamespace
- simplejson
- matplotlib (Only if you use PSDataPlot.py)
Download and install the dependencies if required. Place PSData.py and SimplePSData.py in the same directory. Open SimplePSData.py Replace the file directory in .jparse('') with the .pssession example provided. Run the code and you will be able to access the parsed data with:
print(simpleData.experimentList) # list the experiments
print(simpleData.data['SWV 1'].xvalues) # access the x values of the first experiment
and that is about all you need to get started!
Assuming you use the following line of code to get your parsed data:
simpleData = PS.jparse([r'C:\A.pssession',r'C:\B.pssession'])
-
List your experiments:
simpleData.experimentList
These are listed as the program finds them.
-
Find out where the experiment data comes from:
simpleData.inFile('SWV 1')
The experiment tags come from the experimentList.
-
SWV and CV x and y values can be accessed like this:
simpleData.data['SWV 1'].xvalues
andsimpleData.data['SWV 1'].yvalues
-
EIS has the following parameters:
.freq
.zdash
.potential
.zdashneg
.Z
.phase
.npoints
.tint
.ymean
.debugtext
.Y
.YRe
(Ydash).YIm
(Ydashdash)
These can be accessed in a similar way:
simpleData.data['EIS 1'].potential
They will not necessarily be available, depending on your experiment
If you want to use the plotting 'library', create the plot object from the simpleData:
plot = PSP.PSPlot(simpleData)
And then you can plot the data using:
plot.show()
The graphs are joined by type, but if you want to split the experiments, set the following:
plot.splitGraphs = True
You can set the titles of the graphs by populating the plot.titles
list. If there are three graphs, you obviously need three titles:
plot.titles = ['Title 1', 'Title 2', 'Title 3']
You can filter on method to plot only a specific method:
plot.methodFilter = 'EIS'
You can set a baseline for SWV graphs by setting the beginning and end points for the baseline. It creates a linear baseline between the two points and subtracts it from the measured values:
plot.baseline.startPosition = 5
plot.baseline.endPosition = 65
If you want to reset the baseline (if you repeadedly use the .show()
command), then you can between the graphs use the reset statement:
plot.baseline.startPosition = 5
plot.show(['SWV 1'])
plot.baseline.resetBaseline = True
plot.show(['SWV 1'])
Something experimental, you can group the experiments using the grouping tag and adding a dictionary of the groups to it:
plot.groups = {'G1':{'SWV 1','SWV 2'},'G2':{'SWV 3', 'SWV 4'},'G3':{'CV 1'},'G4':{'CV 2'}}
the group tags are not used except for lookups.
I use the SWV analysis to compare the peaks of two experiments. If you group two SWV experiments together, the peak ratio will be calculated based on the minimum value of the experiment. If you grouped SWV 1 and 2, and SWV 3 and 4, the output will also print the following:
Ratio: SWV 2/SWV 1 = 180.51%
Ratio: SWV 3/SWV 4 = 658.99%
Lastly, if you want to plot specific experiments instead, fill in the experiment labels of the required experiments:
plot.show(['SWV 1', 'CV 3'])
I use Jupyter Notebooks for my work. If you use this, the variables are stored per plot object. This means if you set a variable (like the baseline) in a cell and you run the cell above it again with the same plot object the baseline variable will be used in that cell as well.
You can overcome this by creating a new plot object per cell (which is tedious) or you can execute the cells in sequential order if you need to run cells above the current working cell. You are able to use the .show()
command in different cells, so if you analyse your data in this way just make sure that you either reset the variables you have used before, or run everything sequentially.
I will have a look around to overcome this some time in the future :)
SWV and Cyclic voltammetry:
Here is an example of an EIS experiment:
Let me know if you have ideas for additional basic functionality.
ToDo:
-
Curve smoothing with Savitzky–Golay filter - Peak detection
-
Dynamic baseline by using the first and second derivatives - Method summary printout and experiment grouping
- % peak comparison printout for grouped experiments