Skip to content

Commit

Permalink
Merge pull request #8 from centrefornetzero/release/v0.0.0
Browse files Browse the repository at this point in the history
Release/v0.0.0
  • Loading branch information
Ianlmgoddard authored Jul 30, 2024
2 parents 58054ab + ce7fbad commit 2f9cddd
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ __pycache__/
env
build
dist
smart_buildings_rating_calculator.egg-info
smart_building_rating_calculator.egg-info
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[packages]
smart_building_rating_calculator = {editable = true, path = "."}
pandas = "*"

[dev-packages]
Expand Down
82 changes: 31 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,50 @@
# Smart building rating calculator
The calculation to generate a Smart Building Rating (SBR) and SBR 'archetype'
This package allows users to calculate Smart Building Ratings (SBR) and their associated SBR 'archetype'. In brief, the smart building rating is a metric that measures a building’s potential to flex its energy demand. More information on the concept and methodology used to compute the SBR can be found on our [website](https://www.centrefornetzero.org/impact/smart-building-rating).

## python-template
## Installation

Centre for Net Zero's template for Python projects.
To install this package, run

Tools:

* [Pipenv](https://github.com/pypa/pipenv) for dependency management
* [Pytest](https://github.com/pytest-dev/pytest/) for testing
* [Mypy](https://mypy.readthedocs.io/en/stable/) for type checking
* [Flake8](https://flake8.pycqa.org/en/latest/) for linting
* [isort](https://github.com/PyCQA/isort) and [black](https://github.com/psf/black) for formatting

Github Actions workflows:
* `test_and_lint.yaml` runs checks on a Ubuntu Github-hosted runner.

## Python Setup

You need to [set up your Python environment](https://docs.google.com/document/d/1Tg0eKalqOp-IJEeH7aShc9fYF5zn95H6jxEk25BLLUE/) first.

1. Clone this repo.
2. Run `make setup` in your terminal.

In step 2 this will:

* Run `pipenv sync --dev` to install dependencies.
* Install your local pre-commit environment which will be used to maintain code standards
* Check the tests work by running `pipenv run pytest`
```
pip install smart-building-rating-calculator
```

## Performing SBR calculation
## Performing the SBR calculation

Main SBR calcuation is done with the `sbr_score` (`src/smart_building_rating_calculator/calculate_sbr_score.py`) function which takes in user inputs, and outputs:
The main SBR calculation is done with the [`sbr_score`](src/smart_building_rating_calculator/calculate_sbr_score.py) function which takes in user inputs, and outputs:
1) SBR value (between 0 and 100)
2) SBR rating (A-G)
3) Flex Archetype (see `src/smart_building_rating_calculator/flexer_enums.py`).
3) Flex Archetype (see [`flexer_enums.py`](`src/smart_building_rating_calculator/flexer_enums.py`)).

Inputs must have datatypes as defined in `src/smart_building_rating_calculator/inputs.py`
- Most inputs are `bool` type (True/False)
- Others are StrEnum type e.g., `charger_power` must have a value of `EVChargerPower("3 kW")`, `EVChargerPower("7 kW")`, `EVChargerPower("22 kW")`, or `EVChargerPower("None")`
- Upon calling `sbr_score`, correct input datatypes are automatically checked for. An error is raised if input datatypes are incorrect.
Inputs must have datatypes as defined in [`inputs.py`](src/smart_building_rating_calculator/inputs.py`)
- Most inputs are `bool` type (`True`/`False`)
- Others are `StrEnum` type e.g., `charger_power` must have a value of `EVChargerPower("3 kW")`, `EVChargerPower("7 kW")`, `EVChargerPower("22 kW")`, or `EVChargerPower("None")`
- Upon calling `sbr_score`, correct input datatypes are automatically checked. An error is raised if input datatypes are incorrect.

Example of how to call `sbr_score` in python:
Here's an example of how to compute the SBR for a given set of inputs, using the `sbr_score` function.

```ruby
from src.smart_building_rating_calculator.calculate_sbr_score import sbr_score
from src.smart_building_rating_calculator.inputs import (
```python
from smart_building_rating_calculator.calculate_sbr_score import sbr_score
from smart_building_rating_calculator.inputs import (
BatterySize,
EVChargerPower,
HeatingSource,
HotWaterSource,
SolarInverterSize,
)
sbr_val, sbr, flex_archetype = sbr_score(
smart_meter=True,
smart_ev_charger=True,
charger_power=EVChargerPower("7 kW"),
smart_v2g_enabled=True,
home_battery=True,
battery_size=BatterySize("8kWh or greater"),
solar_pv=True,
pv_inverter_size=SolarInverterSize("4 kW or less"),
electric_heating=True,
heating_source=HeatingSource("Heat Pump"),
hot_water_source=HotWaterSource("Heat Battery / Electric Hot Water Tank"),
secondary_heating=True,
secondary_hot_water=True,
integrated_control_sys=True)
smart_meter=True,
smart_ev_charger=True,
charger_power=EVChargerPower("7 kW"),
smart_v2g_enabled=True,
home_battery=True,
battery_size=BatterySize("8kWh or greater"),
solar_pv=True,
pv_inverter_size=SolarInverterSize("4 kW or less"),
electric_heating=True,
heating_source=HeatingSource("Heat Pump"),
hot_water_source=HotWaterSource("Heat Battery / Electric Hot Water Tank"),
secondary_heating=True,
secondary_hot_water=True,
integrated_control_sys=True)
```
14 changes: 10 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
from setuptools import setup
from setuptools import find_packages, setup

VERSION = "v0.0.0"

install_requires = ["pandas>=2.2"]

setup(
name="smart-buildings-rating-calculator",
version="0.2.0",
name="smart-building-rating-calculator",
version=VERSION,
author="Centre for Net Zero",
author_email="[email protected]",
description="The calculation to generate a smart building rating",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url="https://github.com/centrefornetzero/smart-building-rating-calculator",
package_dir={"": "src"},
packages=find_packages(where="src"),
install_requires=install_requires,
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires="==3.11",
python_requires=">=3.11",
)
17 changes: 17 additions & 0 deletions src/smart_building_rating_calculator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from smart_building_rating_calculator.calculate_sbr_score import sbr_score
from smart_building_rating_calculator.inputs import (
BatterySize,
EVChargerPower,
HeatingSource,
HotWaterSource,
SolarInverterSize,
)

__all__ = [
"sbr_score",
"BatterySize",
"EVChargerPower",
"HeatingSource",
"HotWaterSource",
"SolarInverterSize",
]
8 changes: 4 additions & 4 deletions src/smart_building_rating_calculator/calculate_sbr_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import pandas as pd

from src.smart_building_rating_calculator.flex_archetype import calc_flex_archetype
from src.smart_building_rating_calculator.initiate_user_inputs import prep_user_inputs
from src.smart_building_rating_calculator.inputs import (
from smart_building_rating_calculator.flex_archetype import calc_flex_archetype
from smart_building_rating_calculator.initiate_user_inputs import prep_user_inputs
from smart_building_rating_calculator.inputs import (
BatterySize,
EVChargerPower,
HeatingSource,
HotWaterSource,
SolarInverterSize,
UserInputs,
)
from src.smart_building_rating_calculator.intermediate_scoring import calc_sbr_score
from smart_building_rating_calculator.intermediate_scoring import calc_sbr_score


def calc_sbr(sbr_val: float) -> str:
Expand Down
4 changes: 2 additions & 2 deletions src/smart_building_rating_calculator/flex_archetype.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Based on Andy's calcuations, this module calculates the flex archetype of a building based on the user inputs and the SBR value.
"""

from src.smart_building_rating_calculator.flexer_enums import FlexArchetype
from src.smart_building_rating_calculator.inputs import (
from smart_building_rating_calculator.flexer_enums import FlexArchetype
from smart_building_rating_calculator.inputs import (
HeatingSource,
HotWaterSource,
UserInputs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.smart_building_rating_calculator.inputs import (
from smart_building_rating_calculator.inputs import (
BatterySize,
EVChargerPower,
HeatingSource,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import replace
from typing import List

from src.smart_building_rating_calculator.inputs import (
from smart_building_rating_calculator.inputs import (
BatterySize,
EVChargerPower,
HeatingSource,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_sbr_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

import pytest

from src.smart_building_rating_calculator.calculate_sbr_score import (
from smart_building_rating_calculator.calculate_sbr_score import (
get_sbr_scores,
sbr_score,
)
from src.smart_building_rating_calculator.flex_archetype import FlexArchetype
from src.smart_building_rating_calculator.initiate_user_inputs import prep_user_inputs
from src.smart_building_rating_calculator.inputs import (
from smart_building_rating_calculator.flex_archetype import FlexArchetype
from smart_building_rating_calculator.initiate_user_inputs import prep_user_inputs
from smart_building_rating_calculator.inputs import (
BatterySize,
EVChargerPower,
HeatingSource,
HotWaterSource,
SolarInverterSize,
UserInputs,
)
from src.smart_building_rating_calculator.intermediate_scoring import (
from smart_building_rating_calculator.intermediate_scoring import (
calc_alternative_heating_score,
calc_alternative_hot_water_score,
calc_elec_heating_score,
Expand Down

0 comments on commit 2f9cddd

Please sign in to comment.