Skip to content

Commit

Permalink
Use Black for code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebannis committed Jan 22, 2025
1 parent 99e777f commit e3fcfd5
Show file tree
Hide file tree
Showing 16 changed files with 1,157 additions and 756 deletions.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"black-formatter.args": ["--line-length", "100"]
}
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Python files and Jupyter notebooks for processing the Annual Technology Baseline (ATB) electricity data and determining LCOE and other metrics. All documentation and data for the ATB is available at the [ATB website](https://atb.nrel.gov).

## Installation and Requirements

The pipeline requires [Python](https://www.python.org) 3.10 or newer. Dependancies can be installed using `pip`:

```
Expand All @@ -21,6 +22,7 @@ $ pytest
Tests take about a minute and should complete without errors. The ATB pipeline uses [xlwings](https://www.xlwings.org/) for accessing the ATB data workbook and requires a copy of Microsoft Excel. Currently the full pipeline will only run on MacOS and Windows. Linux support may be added in the future.

## Running the ATB Electricity Pipeline

Running the pipeline requires downloaded the most current data in `xlsx` format from the
[ATB website](https://atb.nrel.gov). The pipeline may be ran for one or all ATB electricity technologies.
Data may be exported in several formats. Below are several example workflows. It is assumed that all
Expand Down Expand Up @@ -54,6 +56,7 @@ $ python -m lcoe_calculator.process_all --help
```

## Debt Fraction Calculator

The debt fraction calculator uses [PySAM](https://nrel-pysam.readthedocs.io/en/main/) to calculate
debt fractions for one or all ATB technologies. To calculate debt fractions for all technologies run
the following from the repository root directory:
Expand Down Expand Up @@ -81,6 +84,7 @@ $ python -m debt_fraction_calculator.debt_fraction_calc --help
```

## Example Jupyter Notebooks

The `./example_notebooks` directory has several [Jupyter](https://jupyter.org/) notebooks showing
how to perform various tasks. The notebooks are a good way to understand how to use the code and
experiment with the ATB pipeline code. Jupyter must first be installed before use:
Expand All @@ -98,14 +102,20 @@ $ jupyter-notebook
in the root repository directory.

## Notable Directories

- `./lcoe_calculator` Extract technology metrics from the data workbook `xlsx` file and calculate LCOE
using Python.
using Python.
- `./debt_fraction_calculator` Given data and assumptions in the data workbook xlsx file, calculate
debt fractions using PySAM.
debt fractions using PySAM.
- `./example_notebooks` Example Jupyter notebooks showing how to perform various operations.
- `./tests` Tests for code in this repository.

## Citing this package
## Citing this Package

Mirletz, Brian, Bannister, Michael, Vimmerstedt, Laura, Stright, Dana, and Heine, Matthew.
"ATB-calc (Annual Technology Baseline Calculators) [SWR-23-60]." Computer software. August 02, 2023.
https://github.com/NREL/ATB-calc. https://doi.org/10.11578/dc.20230914.2.
https://github.com/NREL/ATB-calc. https://doi.org/10.11578/dc.20230914.2.

## Code Formatting

This project uses the [Black](https://black.readthedocs.io/en/stable/index.html) code formatting VS Code [plugin](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter). Please install and run the plugin before making commits or a pull request.
240 changes: 156 additions & 84 deletions debt_fraction_calculator/debt_fraction_calc.py

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions lcoe_calculator/abstract_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ class AbstractExtractor(ABC):
"""

@abstractmethod
def __init__(self, data_workbook_fname: str, sheet_name: str, case: str, crp: CrpChoiceType,
scenarios: List[str], base_year: int):
def __init__(
self,
data_workbook_fname: str,
sheet_name: str,
case: str,
crp: CrpChoiceType,
scenarios: List[str],
base_year: int,
):
"""
@param data_workbook_fname - file name of data workbook
@param sheet_name - name of sheet to process
Expand All @@ -29,8 +36,9 @@ def __init__(self, data_workbook_fname: str, sheet_name: str, case: str, crp: Cr
"""

@abstractmethod
def get_metric_values(self, metric: str, num_tds: int, split_metrics: bool = False)\
-> pd.DataFrame:
def get_metric_values(
self, metric: str, num_tds: int, split_metrics: bool = False
) -> pd.DataFrame:
"""
Grab metric values table.
Expand All @@ -42,7 +50,7 @@ def get_metric_values(self, metric: str, num_tds: int, split_metrics: bool = Fal

@abstractmethod
def get_tax_credits(self) -> pd.DataFrame:
""" Get tax credit """
"""Get tax credit"""

@abstractmethod
def get_cff(self, cff_name: str, rows: int) -> pd.DataFrame:
Expand All @@ -64,7 +72,9 @@ def get_fin_assump(self) -> pd.DataFrame:
"""

@abstractmethod
def get_wacc(self, tech_name: str | None = None) -> Tuple[pd.DataFrame, pd.DataFrame]:
def get_wacc(
self, tech_name: str | None = None
) -> Tuple[pd.DataFrame, pd.DataFrame]:
"""
Extract values for tech and case from WACC sheet.
Expand Down
Loading

0 comments on commit e3fcfd5

Please sign in to comment.