diff --git a/.gitignore b/.gitignore index 7f5bbb3..a44a251 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ __pycache__/ env build dist -smart_buildings_rating_calculator.egg-info +smart_building_rating_calculator.egg-info diff --git a/Pipfile b/Pipfile index cb8052d..ca383be 100644 --- a/Pipfile +++ b/Pipfile @@ -1,4 +1,5 @@ [packages] +smart_building_rating_calculator = {editable = true, path = "."} pandas = "*" [dev-packages] diff --git a/README.md b/README.md index 88c4b78..803548b 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,31 @@ # 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, @@ -53,18 +33,18 @@ from src.smart_building_rating_calculator.inputs import ( 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) ``` diff --git a/setup.py b/setup.py index 558555f..7db6f58 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,12 @@ -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="data@centrefornetzero.org", description="The calculation to generate a smart building rating", @@ -10,10 +14,12 @@ 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", ) diff --git a/src/smart_building_rating_calculator/__init__.py b/src/smart_building_rating_calculator/__init__.py index e69de29..f42e651 100644 --- a/src/smart_building_rating_calculator/__init__.py +++ b/src/smart_building_rating_calculator/__init__.py @@ -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", +] diff --git a/src/smart_building_rating_calculator/calculate_sbr_score.py b/src/smart_building_rating_calculator/calculate_sbr_score.py index 2946a7d..ecd02c5 100644 --- a/src/smart_building_rating_calculator/calculate_sbr_score.py +++ b/src/smart_building_rating_calculator/calculate_sbr_score.py @@ -2,9 +2,9 @@ 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, @@ -12,7 +12,7 @@ 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: diff --git a/src/smart_building_rating_calculator/flex_archetype.py b/src/smart_building_rating_calculator/flex_archetype.py index 219cf32..98c234a 100644 --- a/src/smart_building_rating_calculator/flex_archetype.py +++ b/src/smart_building_rating_calculator/flex_archetype.py @@ -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, diff --git a/src/smart_building_rating_calculator/initiate_user_inputs.py b/src/smart_building_rating_calculator/initiate_user_inputs.py index ca1789a..ef4b441 100644 --- a/src/smart_building_rating_calculator/initiate_user_inputs.py +++ b/src/smart_building_rating_calculator/initiate_user_inputs.py @@ -1,4 +1,4 @@ -from src.smart_building_rating_calculator.inputs import ( +from smart_building_rating_calculator.inputs import ( BatterySize, EVChargerPower, HeatingSource, diff --git a/src/smart_building_rating_calculator/intermediate_scoring.py b/src/smart_building_rating_calculator/intermediate_scoring.py index 3803189..c729ff5 100644 --- a/src/smart_building_rating_calculator/intermediate_scoring.py +++ b/src/smart_building_rating_calculator/intermediate_scoring.py @@ -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, diff --git a/tests/test_sbr_calculator.py b/tests/test_sbr_calculator.py index b2b1590..b81e436 100644 --- a/tests/test_sbr_calculator.py +++ b/tests/test_sbr_calculator.py @@ -5,13 +5,13 @@ 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, @@ -19,7 +19,7 @@ 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,