Skip to content

Commit

Permalink
Merge pull request #46 from bcliang/impl-class-props
Browse files Browse the repository at this point in the history
Change: class property methods
  • Loading branch information
bcliang committed Jan 10, 2022
2 parents c1dfcf7 + 221966d commit b2efe0c
Show file tree
Hide file tree
Showing 22 changed files with 383 additions and 403 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
-

### Changed
-
- [#46](https://github.com/bcliang/gamry-parser/pull/46) Change: class property methods

### Added
-
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ python setup.py install

### Usage

The provided Usage example loads a CV DTA file two ways, and demonstrates the utility of custom functions within the CyclicVoltammetry subclass (`get_v_range`, `get_scan_rate`)
The provided Usage example loads a CV DTA file two ways, and demonstrates the utility of class properties within the CyclicVoltammetry subclass (`v_range`, `scan_rate`)

```bash
$ python usage.py
Expand All @@ -51,12 +51,12 @@ file = '/enter/the/file/path.dta'
gp = parser.GamryParser()
gp.load(filename=file)

print("experiment type: {}".format(gp.get_experiment_type()))
print("loaded curves: {}".format(gp.get_curve_count()))
print("experiment type: {}".format(gp.experiment_type))
print("loaded curves: {}".format(gp.curve_count))

curve_index = random.randint(1,gp.get_curve_count())
curve_index = random.randint(1,gp.curve_count)
print("showing curve #{}".format(curve_index))
print(gp.get_curve_data(curve_index))
print(gp.curve(curve_index))
```

#### ChronoAmperometry Example
Expand All @@ -72,7 +72,7 @@ import random
file = '/enter/the/file/path.dta'
ca = parser.ChronoAmperometry(to_timestamp=True)
ca.load(filename=file)
print(ca.get_curve_data())
print(ca.curve())
```

#### Demos
Expand All @@ -90,7 +90,7 @@ ipython notebook demonstration scripts are included in the `demo` folder.

#### Additional Examples

Similar procedure should be followed for using the `gamry_parser.CyclicVoltammetry()`, `gamry_parser.Impedance()`, `gamry_parser.OpenCircuitPotential()`, and `gamry_parser.VFP600()` parser subclasses. Take a look at `usage.py` and in `tests/` for some additional usage examples.
Similar procedure should be followed for using the `gamry_parser.CyclicVoltammetry()`, `gamry_parser.Impedance()`, `gamry_parser.OpenCircuitPotential()`, `gamry_parser.SquareWaveVoltammetry()` and `gamry_parser.VFP600()` parser subclasses. Take a look at `usage.py` and in `tests/` for some additional usage examples.

## Development

Expand All @@ -104,6 +104,7 @@ Similar procedure should be followed for using the `gamry_parser.CyclicVoltammet
│ ├── eispot.py # Impedance() experiment parser
| ├── gamryparser.py # GamryParser: generic DTA file parser
│ ├── ocp.py # OpenCircuitPotential() experiment parser
│ ├── squarewave.py # SquareWaveVoltammetry() experiment parser
| └── vfp600.py # VFP600() parses experiment data generated by the Gamry VFP600 LabView Frontend.
├── tests # unit tests and test data
| └── ...
Expand Down
151 changes: 73 additions & 78 deletions demo/notebook_cyclicvoltammetry.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"nbformat_minor": 2,
"metadata": {
"colab": {
"name": "Gamry-Parser CyclicVoltammetry Example",
Expand All @@ -16,13 +16,8 @@
},
"cells": [
{
"metadata": {
"id": "WF08aBjO8Lvh",
"colab_type": "code",
"cellView": "form",
"colab": {}
},
"cell_type": "code",
"execution_count": null,
"source": [
"#@title Imports, initial setup (Ctrl+F9 to run all)\n",
"from google.colab import files \n",
Expand All @@ -43,17 +38,17 @@
" \n",
"print('Done.')"
],
"execution_count": 0,
"outputs": []
},
{
"outputs": [],
"metadata": {
"id": "qPt8TDQgA0h6",
"id": "WF08aBjO8Lvh",
"colab_type": "code",
"cellView": "code",
"cellView": "form",
"colab": {}
},
}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"\"\"\"\n",
"### SCRIPT CONFIGURATION SETTINGS ###\n",
Expand All @@ -74,17 +69,17 @@
"\n",
"print('Done.')"
],
"execution_count": 0,
"outputs": []
},
{
"outputs": [],
"metadata": {
"id": "3cK_P2Clmksm",
"id": "qPt8TDQgA0h6",
"colab_type": "code",
"cellView": "form",
"cellView": "code",
"colab": {}
},
}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"#@title DTA File\n",
"if upload_files:\n",
Expand All @@ -94,86 +89,83 @@
" experiment = [\"cv_data.dta\"]\n",
"\n"
],
"execution_count": 0,
"outputs": []
},
{
"outputs": [],
"metadata": {
"id": "mxwEyYWICCYs",
"id": "3cK_P2Clmksm",
"colab_type": "code",
"cellView": "form",
"colab": {}
},
}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"#@title Load and Plot Curve Data\n",
"\n",
"for f in experiment:\n",
" p.load(f)\n",
" \n",
" # generate a plot based on the first curve listed in the file.\n",
" curve_count = p.get_curve_count()\n",
" data = p.get_curve_data(curve_count) \n",
" \n",
" # print to screen\n",
" print('Data Preview: Last Curve')\n",
" print(data.iloc[:5])\n",
" \n",
" # matplotlib fig\n",
" if show_plots:\n",
" fig, ax = plt.subplots(figsize=(18,8))\n",
" for i in range(curve_count):\n",
" data = p.get_curve_data(i)\n",
" trace = ax.plot(data['Vf'], data['Im']*1e6, label=\"curve {}\".format(i))\n",
" \n",
" \n",
" ax.set_title(\"{}, {} curves\".format(f, curve_count), fontsize=18)\n",
" ax.set_xlabel('Potential (V)')\n",
" ax.set_ylabel('Current (A)', fontsize=14)\n",
" plt.show()"
" p.load(f)\n",
" \n",
" # generate a plot based on the first curve listed in the file.\n",
" data = p.curve(p.curve_count) \n",
" \n",
" # print to screen\n",
" print('Data Preview: Last Curve')\n",
" print(data.iloc[:5])\n",
" \n",
" # matplotlib fig\n",
" if show_plots:\n",
" fig, ax = plt.subplots(figsize=(18,8))\n",
" for i in range(p.curve_count):\n",
" data = p.curve(i)\n",
" trace = ax.plot(data['Vf'], data['Im']*1e6, label=\"curve {}\".format(i))\n",
" \n",
" ax.set_title(\"{}, {} curves\".format(f, p.curve_count), fontsize=18)\n",
" ax.set_xlabel('Potential (V)')\n",
" ax.set_ylabel('Current (A)', fontsize=14)\n",
" plt.show()"
],
"execution_count": 0,
"outputs": []
},
{
"outputs": [],
"metadata": {
"id": "AQc4jnhlURDV",
"id": "mxwEyYWICCYs",
"colab_type": "code",
"colab": {},
"cellView": "form"
},
"cellView": "form",
"colab": {}
}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"#@title Compare a specific curve across loaded files\n",
"\n",
"fig, ax = plt.subplots(figsize=(18,8))\n",
" \n",
"for f in experiment:\n",
" p.load(f)\n",
" \n",
" # generate a plot based on the first curve listed in the file.\n",
" curve_count = p.get_curve_count()\n",
" if curve_count > compare_curves:\n",
" data = p.get_curve_data(compare_curves) \n",
" trace = ax.plot(data['Vf'], data['Im']*1e6, label=\"file {}\".format(f))\n",
" p.load(f)\n",
" \n",
" # generate a plot based on the first curve listed in the file.\n",
" if p.curve_count > compare_curves:\n",
" data = p.curve(compare_curves) \n",
" trace = ax.plot(data['Vf'], data['Im']*1e6, label=\"file {}\".format(f))\n",
" \n",
"ax.set_title(\"CyclicVoltammetry Test, Compare Curve #{}\".format(compare_curves), fontsize=18)\n",
"ax.set_xlabel('Potential (V)')\n",
"ax.set_ylabel('Current (A)', fontsize=14)\n",
"ax.legend()\n",
"plt.show()"
],
"execution_count": 0,
"outputs": []
},
{
"outputs": [],
"metadata": {
"id": "ZPXwezuvmgZ0",
"id": "AQc4jnhlURDV",
"colab_type": "code",
"cellView": "form",
"colab": {}
},
"colab": {},
"cellView": "form"
}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"#@title Download All Curves, All Experiments\n",
"\n",
Expand All @@ -182,18 +174,21 @@
"for f in experiment:\n",
" p.load(f)\n",
" \n",
" # use get_curves() to retrieve all curves\n",
" data = p.get_curves()\n",
" \n",
" for df in data:\n",
" # use the curves @property to retrieve all curve data\n",
" for df in p.curves:\n",
" aggreg = aggreg.append(df)\n",
" \n",
" \n",
"aggreg.to_csv('results.csv')\n",
"files.download('results.csv')"
],
"execution_count": 0,
"outputs": []
"outputs": [],
"metadata": {
"id": "ZPXwezuvmgZ0",
"colab_type": "code",
"cellView": "form",
"colab": {}
}
}
]
}
Loading

0 comments on commit b2efe0c

Please sign in to comment.