Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divide examples into folders #559

Merged
merged 7 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- [#282](https://github.com/pybop-team/PyBOP/issues/282) - Restructures the examples directory.
- [#396](https://github.com/pybop-team/PyBOP/issues/396) - Adds `ecm_with_tau.py` example script.
- [#452](https://github.com/pybop-team/PyBOP/issues/452) - Extends `cell_mass` and `approximate_capacity` for half-cell models.
- [#544](https://github.com/pybop-team/PyBOP/issues/544) - Allows iterative plotting using `StandardPlot`.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"source": [
"## Importing Parameters\n",
"\n",
"This can be completed by importing a JSON representation, such as the one in the PyBOP [examples](https://github.com/pybop-team/PyBOP/blob/develop/examples/scripts/parameters/initial_ecm_parameters.json). To import via JSON, either download the example file, or create your own and update the path below to reference the corresponding file."
"This can be completed by importing a JSON representation, such as the one in the PyBOP [examples](https://github.com/pybop-team/PyBOP/blob/develop/examples/parameters/initial_ecm_parameters.json). To import via JSON, either download the example file, or create your own and update the path below to reference the corresponding file."
]
},
{
Expand All @@ -115,7 +115,7 @@
"outputs": [],
"source": [
"# parameter_set = pybop.ParameterSet(\n",
"# json_path=\"examples/scripts/parameters/initial_ecm_parameters.json\"\n",
"# json_path=\"examples/parameters/initial_ecm_parameters.json\"\n",
"# )\n",
"# parameter_set.import_parameters()"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"metadata": {},
"outputs": [],
"source": [
"file_loc = r\"../data/Samsung_INR21700/sample_hppc_pulse.xlsx\"\n",
"file_loc = r\"../../data/Samsung_INR21700/sample_hppc_pulse.xlsx\"\n",
"df = pd.read_excel(file_loc, index_col=None, na_values=[\"NA\"])\n",
"df = df.drop_duplicates(subset=[\"Time\"], keep=\"first\")\n",
"\n",
Expand Down Expand Up @@ -459,7 +459,7 @@
"metadata": {},
"outputs": [],
"source": [
"file_loc = r\"../data/Samsung_INR21700/sample_drive_cycle.xlsx\"\n",
"file_loc = r\"../../data/Samsung_INR21700/sample_drive_cycle.xlsx\"\n",
"df = pd.read_excel(file_loc, sheet_name=\"Sheet3\", index_col=None, na_values=[\"NA\"])\n",
"\n",
"# Remove duplicate rows, keeping the first occurrence\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"metadata": {},
"outputs": [],
"source": [
"file_loc = r\"../data/Samsung_INR21700/multipulse_hppc.xlsx\"\n",
"file_loc = r\"../../data/Samsung_INR21700/multipulse_hppc.xlsx\"\n",
"df = pd.read_excel(file_loc, index_col=None, na_values=[\"NA\"])\n",
"df = df.drop_duplicates(subset=[\"Time\"], keep=\"first\")\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"outputs": [],
"source": [
"ocv_df = pd.read_csv(\n",
" \"../data/Tesla_4680/T-cell_pOCV_data.txt\",\n",
" \"../../data/Tesla_4680/T-cell_pOCV_data.txt\",\n",
" sep=\"\\t\",\n",
" decimal=\",\",\n",
")"
Expand Down Expand Up @@ -217,7 +217,7 @@
],
"source": [
"cycling_df = pd.read_csv(\n",
" \"../data/Tesla_4680/601-828_Capacity_03_MB_CB1_subset.txt\",\n",
" \"../../data/Tesla_4680/601-828_Capacity_03_MB_CB1_subset.txt\",\n",
" sep=\"\\t\",\n",
")\n",
"filter_cycling = cycling_df.loc[54811:61000].copy() # Full cycle is [54811:127689]\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@
"outputs": [],
"source": [
"ocp = loadmat(\n",
" \"../data/LG_M50_ECM/data/LGM50_5Ah_OCV.mat\", simplify_cells=True, mat_dtype=False\n",
" \"../../data/LG_M50_ECM/data/LGM50_5Ah_OCV.mat\", simplify_cells=True, mat_dtype=False\n",
")\n",
"pulse_data = loadmat(\n",
" \"../data/LG_M50_ECM/data/LGM50_5Ah_Pulse.mat\", simplify_cells=True, mat_dtype=False\n",
" \"../../data/LG_M50_ECM/data/LGM50_5Ah_Pulse.mat\",\n",
" simplify_cells=True,\n",
" mat_dtype=False,\n",
")\n",
"rate_data = loadmat(\n",
" \"../data/LG_M50_ECM/data/LGM50_5Ah_RateTest.mat\",\n",
" \"../../data/LG_M50_ECM/data/LGM50_5Ah_RateTest.mat\",\n",
" simplify_cells=True,\n",
" mat_dtype=False,\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"source": [
"# Load the parameters\n",
"parameter_set = pybop.ParameterSet(\n",
" json_path=\"../scripts/parameters/initial_ecm_parameters.json\"\n",
" json_path=\"../../parameters/initial_ecm_parameters.json\"\n",
")\n",
"parameter_set.import_parameters()\n",
"# Define the model\n",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pybop

# Form dataset
Measurements = pd.read_csv("examples/scripts/Chen_example.csv", comment="#").to_numpy()
Measurements = pd.read_csv("examples/data/Chen_example.csv", comment="#").to_numpy()
dataset = pybop.Dataset(
{
"Time [s]": Measurements[:, 0],
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_monte_carlo_thevenin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def setup(self):
@pytest.fixture
def model(self):
parameter_set = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
parameter_set.import_parameters()
parameter_set.params.update(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_thevenin_parameterisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup(self):
@pytest.fixture
def model(self):
parameter_set = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
parameter_set.import_parameters()
parameter_set.params.update(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setup(self):
@pytest.fixture
def model(self):
parameter_set = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
parameter_set.import_parameters()
parameter_set.params.update(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_basemodel(self):
@pytest.mark.unit
def test_thevenin_model(self):
parameter_set = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
parameter_set.import_parameters()
assert parameter_set["Open-circuit voltage [V]"] == "default"
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_parameter_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_ecm_parameter_sets(self):
json_params.import_parameters()

json_params = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
json_params.import_parameters()

Expand Down Expand Up @@ -94,14 +94,14 @@ def test_ecm_parameter_sets(self):
),
)
params.export_parameters(
"examples/scripts/parameters/fit_ecm_parameters.json", fit_params=parameters
"examples/parameters/fit_ecm_parameters.json", fit_params=parameters
)

# Test error when there no parameters to export
empty_params = pybop.ParameterSet()
with pytest.raises(ValueError):
empty_params.export_parameters(
"examples/scripts/parameters/fit_ecm_parameters.json"
"examples/parameters/fit_ecm_parameters.json"
)

@pytest.mark.unit
Expand All @@ -115,7 +115,7 @@ def test_bpx_parameter_sets(self):
bpx_parameters.import_from_bpx()

bpx_parameters = pybop.ParameterSet(
json_path="examples/scripts/parameters/example_BPX.json"
json_path="examples/parameters/example_BPX.json"
)
bpx_parameters.import_from_bpx()

Expand Down
Loading