diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a163124..d2adb5f 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -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: | diff --git a/battdat/postprocess/integral.py b/battdat/postprocess/integral.py index 00df112..2600b01 100644 --- a/battdat/postprocess/integral.py +++ b/battdat/postprocess/integral.py @@ -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): """ @@ -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 @@ -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 @@ -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 diff --git a/battdat/postprocess/tagging.py b/battdat/postprocess/tagging.py index 5da1302..62ed8f8 100644 --- a/battdat/postprocess/tagging.py +++ b/battdat/postprocess/tagging.py @@ -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"]) @@ -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): @@ -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"):