Skip to content
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
3 changes: 2 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ jobs:
- name: Coveralls
run: |
pip install coveralls
coveralls --service=github
coveralls --service=github-actions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: Test example notebooks
if: ${{ runner.os == 'Linux' }}
run: |
Expand Down
15 changes: 7 additions & 8 deletions battdat/postprocess/integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class StateOfCharge(RawDataEnhancer):
Output dataframe has 3 new columns:
- ``cycled_charge``: Amount of observed charge cycled since the beginning of the cycle, in A-hr
- ``cycled_energy``: Amount of observed energy cycled since the beginning of the cycle, in W-hr
- ``CE_charge``: Amount of charge in the battery relative to the beginning of the cycle, accounting for Coulombic
Efficiency, in A-hr
- ``CE_adjusted_charge``: Amount of charge in the battery relative to the beginning of the cycle, accounting for
Coulombic Efficiency (CE), in A-hr
"""
def __init__(self, coulombic_efficiency: float = 1.0):
"""
Expand All @@ -157,7 +157,7 @@ def coulombic_efficiency(self, value: float):

@property
def column_names(self) -> List[str]:
return ['cycled_charge', 'cycled_energy', 'CE_charge']
return ['cycled_charge', 'cycled_energy', 'CE_adjusted_charge']

def _get_CE_adjusted_curr(self, current: np.ndarray) -> np.ndarray:
"""Adjust the current based on the coulombic efficiency
Expand All @@ -168,14 +168,13 @@ def _get_CE_adjusted_curr(self, current: np.ndarray) -> np.ndarray:
Returns:
Adjusted current array in A
"""
adjusted_current = current.copy()
adjusted_current[current > 0] *= self.coulombic_efficiency
return adjusted_current
adjusted_current = np.where(current > 0, self.coulombic_efficiency * current, current)
return adjusted_current.flatten()

def enhance(self, data: pd.DataFrame):
# Add columns for the capacity and energy
for c in self.column_names:
data[c] = np.nan
data.loc[:, (c,)] = np.nan

# Compute the capacity and energy for each cycle
ordered_copy = data.reset_index() # Ensure a sequential ordering from 0
Expand All @@ -193,5 +192,5 @@ def enhance(self, data: pd.DataFrame):

# Store them in the raw data
data.loc[cycle_subset['index'], 'cycled_charge'] = capacity_change / 3600 # To A-hr
data.loc[cycle_subset['index'], 'CE_charge'] = ce_charge / 3600 # To A-hr
data.loc[cycle_subset['index'], 'CE_adjusted_charge'] = ce_charge / 3600 # To A-hr
data.loc[cycle_subset['index'], 'cycled_energy'] = energy_change / 3600 # To W-hr
6 changes: 3 additions & 3 deletions battdat/postprocess/tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def column_names(self) -> List[str]:

def enhance(self, df: pd.DataFrame):
# Insert a new column into the dataframe, starting with everything marked as other
df['method'] = ControlMethod.other
df.loc[:, ('method',)] = ControlMethod.other

# array of indexes
cycles = df.groupby(["cycle_number", "step_index"])
Expand Down Expand Up @@ -148,7 +148,7 @@ def column_names(self) -> List[str]:

def enhance(self, data: pd.DataFrame) -> None:
logger.debug('Adding states')
data['state'] = data.apply(_determine_state, axis=1, args=(self.rest_curr_threshold,))
data.loc[:, ('state',)] = data.apply(_determine_state, axis=1, args=(self.rest_curr_threshold,))


class AddSteps(RawDataEnhancer):
Expand Down Expand Up @@ -192,7 +192,7 @@ def _determine_steps(df: DataFrame, column: str, output_col: str):

# The step number is equal to the number of changes observed previously in a batch
# Step 1: Compute the changes since the beginning of file
df[output_col] = change.cumsum()
df.loc[:, (output_col,)] = change.cumsum()

# Step 2: Adjust so that each cycle starts with step 0
for _, cycle in df.groupby("cycle_number"):
Expand Down
Loading