Skip to content

Commit

Permalink
update example template
Browse files Browse the repository at this point in the history
  • Loading branch information
jepegit committed Feb 28, 2024
1 parent 75a39da commit 051890a
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"project_name": "cellpy_project",
"session_id": "experiment_001",
"cellpy_version": "1.0.1",
"author_name": "Your Name",
"date": "{% now 'local' %}",
"experiment_folder_name": "{{cookiecutter.date.replace('-','_')}}_{{cookiecutter.session_id}}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
import os
import sys

print(f"setting up project in the following directory: {os.getcwd()}")

MIN_CELLPY_MAJOR, MIN_CELLPY_MINOR = 1, 0
cellpy_version = "{{ cookiecutter.cellpy_version }}"
major, minor = cellpy_version.split(".")[:2]
major, minor = int(major), int(minor)
too_old = False

if major < MIN_CELLPY_MAJOR:
too_old = True

if major == MIN_CELLPY_MAJOR:
if minor < MIN_CELLPY_MINOR:
too_old = True

# additional test for patch version since v.1.0.0 -> v.1.0.1 introduced a new batch method.
if major == MIN_CELLPY_MAJOR and minor == MIN_CELLPY_MINOR:
patch = cellpy_version.split(".")[2]
if patch.startswith("0"):
print()
print(" ERROR ".center(80, "="))
print()
print(" Cellpy Cookie says: 'OH NO!!!!'")
print(" Cellpy Cookie says: 'Your version of cellpy is too old - aborting!'")
print(" Cellpy Cookie says: 'Please update cellpy to the latest version'")
print()
print(" $ python -m pip install cellpy --upgrade")
print()
print(" Cellpy Cookie says: 'or use the cookie standard_1_0_0 instead!'")
print()
print(" $ cellpy new --template starndard_1_0_0")
print()
print(80 * "=")
print()
sys.exit(1)

# end of additional test

if too_old:
print()
print(" ERROR ".center(80, "="))
print()
print(" Cellpy Cookie says: 'OH NO!!!!'")
print(" Cellpy Cookie says: 'Your version of cellpy is too old - aborting!'")
print()
print(80 * "=")
print()
sys.exit(1)
print(" Cellpy Cookie says: 'using cookie from the cellpy_cookies repository'")
print(" Cellpy Cookie says: 'setting up project in the following directory:'")
print(f" {os.getcwd()}'")
print()
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note! This template was made for `cellpy` version 0.4.1.a3"
"Note! This template was made for `cellpy` version 1.0.1"
]
},
{
Expand Down Expand Up @@ -84,21 +84,43 @@
"metadata": {},
"outputs": [],
"source": [
"# Parameters for the batch\n",
"project = \"{{cookiecutter.project_name}}\"\n",
"name = \"{{cookiecutter.session_id}}\"\n",
"batch_col = \"b01\" # edit this if you are not using the standard batch column\n",
"\n",
"# Create the batch object\n",
"b = batch.init(name, project, batch_col=batch_col)"
"b = batch.load(\n",
" project=\"{{cookiecutter.project_name}}\",\n",
" name=\"{{cookiecutter.session_id}}\",\n",
" batch_col=\"b01\", # edit this if you are not using the standard batch column\n",
" allow_from_journal=True, # allow to load from journal\n",
" force_cellpy=False, # set to True if you would like to force loading cellpy files\n",
" export_ica=False, # set to True if you would like to force loading cellpy files\n",
" export_cycles=False, # set to True if you would like to force loading cellpy files\n",
" export_raw=False, # set to True if you would like to force loading cellpy files\n",
" force_raw_file=False, # set to True if you would like to force loading raw files\n",
" force_reload=False, # set to True if you would like to force loading files even if journal exists\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Show the journal pages\n",
"b.pages"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Initial investigation of the batch experiment"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Set optional parameters\n",
"You should set overall parameters before creating the journal and lodaing the data. The most common ones are given below (uncomment what you need)."
"### 3.1 Summaries"
]
},
{
Expand All @@ -107,17 +129,15 @@
"metadata": {},
"outputs": [],
"source": [
"## Setting some prms if default values are not OK for you\n",
"b.experiment.export_raw = False\n",
"b.experiment.export_cycles = True\n",
"b.experiment.export_ica = False"
"# Plot the charge capacity and the C.E. (and resistance and rate) vs. cycle number (standard plot)\n",
"b.plot(rate=True, ir=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create the journal and appropriate folder structure"
"### 3.2 Remove bad cells"
]
},
{
Expand All @@ -126,11 +146,15 @@
"metadata": {},
"outputs": [],
"source": [
"# load info from your db and write the journal pages\n",
"b.create_journal()\n",
"\n",
"# Create the apropriate folders\n",
"b.paginate()"
"# Get a report summarising the data\n",
"b.report()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Modify the pages"
]
},
{
Expand All @@ -139,15 +163,21 @@
"metadata": {},
"outputs": [],
"source": [
"# Show the journal pages\n",
"b.pages"
"# # make a copy of pages (in case you do something stupid)\n",
"# npages = b.pages.copy()"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## 2. Loading data"
"# # set the updated dataframe as your new pages\n",
"# b.pages = npages\n",
"# # if you have made any changes to your journal pages, you should save it again.\n",
"# b.save_journal()\n",
"# b.duplicate_journal()"
]
},
{
Expand All @@ -156,26 +186,24 @@
"metadata": {},
"outputs": [],
"source": [
"# load the data (and save .csv-files if you have set export_(raw/cycles/ica) = True)\n",
"# (this might take some time)\n",
"b.update()"
"# # If you have changed parameters that cellpy uses internally in its calculations, such as nominal capacity or mass, \n",
"# # you will have to do a recalculation. If you have removed cells, you will need to do a new linking.\n",
"# b.recalc()\n",
"# b.link()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Initial investigation of the batch experiment"
"### 3.3 Raw data"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"# Collect summary-data (e.g. charge capacity vs cycle number) from each cell and export to .csv-file(s).\n",
"b.combine_summaries()"
"#### Quick look"
]
},
{
Expand All @@ -184,18 +212,17 @@
"metadata": {},
"outputs": [],
"source": [
"# Plot the charge capacity and the C.E. (and resistance) vs. cycle number (standard plot)\n",
"b.plot_summaries()"
"# label = b.cell_names[0]\n",
"# c = b.experiment.data[label]\n",
"# plotutils.raw_plot(c)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Packaging data\n",
"The notebooks are set up such that they read the journal from the current folder. This is not the default location of the journal files. To be able to load the journal easily, you should duplicate it (run the cell below).\n",
"\n",
"If you also would like to share the experiment with others, you should run the `duplicate_cellpy_files` method so that all the cellpy-files will be copied to the `data/interim folder`."
"#### Cycle information\n",
"Gives additional information (rate, steps, etc)."
]
},
{
Expand All @@ -204,18 +231,19 @@
"metadata": {},
"outputs": [],
"source": [
"## If you have made any changes to your journal pages, you should save it again.\n",
"# b.save_journal()"
"# label = b.cell_names[0]\n",
"# c = b.cells[label]\n",
"# plotutils.cycle_info_plot(c, info_level=1, show_it=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"# Copy the journal to the notebook working folder\n",
"b.duplicate_journal()"
"## 4. Packaging data\n",
"The notebooks are set up such that they read the journal from the current folder. This is not the default location of the journal files. To be able to load the journal easily, you should duplicate it (run the cell below).\n",
"\n",
"If you also would like to share the experiment with others, you should run the `duplicate_cellpy_files` method so that all the cellpy-files will be copied to the `data/interim folder`."
]
},
{
Expand Down Expand Up @@ -245,7 +273,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 051890a

Please sign in to comment.