Skip to content

Commit

Permalink
Merge pull request #186 from MichaelTiemannOSC/20230503-cleanup
Browse files Browse the repository at this point in the history
Clean up release issues (and will clean up pip-audit when new point release is available).
  • Loading branch information
MichaelTiemannOSC authored May 3, 2023
2 parents 47058bc + 1f23923 commit 6dbde11
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pip-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- name: Install
run: python -m pip install .
- name: Run pip-audit
uses: pypa/gh-action-pip-audit@v1.0.3
uses: pypa/gh-action-pip-audit@ww/pin-requests
6 changes: 5 additions & 1 deletion ITR/data/base_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,9 @@ def _extract_historic_df(self, companies: List[ICompanyData]) -> pd.DataFrame:
raise ValueError("No historic data anywhere")
df = pd.DataFrame.from_records(data).set_index(
[ColumnsConfig.COMPANY_ID, ColumnsConfig.VARIABLE, ColumnsConfig.SCOPE])

# Note that the first valid index may well be Quantity with a NaN value--that's fine
# We just need to fill in the pure NaNs that arise from very ragged data

with warnings.catch_warnings():
# TODO: need to investigate whether there is a more sane way to avoid unit warnings
warnings.simplefilter("ignore")
Expand Down Expand Up @@ -815,6 +815,8 @@ def _historic_ei_to_dicts(self, id: str, intensities_scopes: IHistoricEIScopes)
def _compute_missing_historic_ei(self, companies: List[ICompanyData], historic_df: pd.DataFrame):
scopes = [EScope[scope_name] for scope_name in EScope.get_scopes()]
missing_data = []
# https://github.com/pandas-dev/pandas/issues/53053
index_names = historic_df.index.names
for company in companies:
# Create keys to index historic_df DataFrame for readability
production_key = (company.company_id, VariablesConfig.PRODUCTIONS, 'Production')
Expand All @@ -839,6 +841,8 @@ def _compute_missing_historic_ei(self, companies: List[ICompanyData], historic_d
# This only happens if ALL scope data is missing. If ANY scope data is present, we'll work with what we get.
if this_missing_data and append_this_missing_data:
missing_data.extend(this_missing_data)
# https://github.com/pandas-dev/pandas/issues/53053
historic_df.index.names = index_names
if missing_data:
error_message = f"Provide either historic emissions intensity data, or historic emission and " \
f"production data for these company - scope combinations: {missing_data}"
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
This Python module implements the ITR methodology.

## Getting started with the user interface:
If you use Anaconda environments, open an Anaconda prompt window, navigate to the 'examples' directory and run:
If you use Anaconda environments, open an Anaconda prompt window, navigate to the root of the ITR release (ITR-develop) and run:
```
conda env create -f environment.yml
conda activate itr_ui
python ITR_UI.py
```

For virtual environments, open a command prompt/terminal window, navigate to the 'examples' directory and run:
For virtual environments, open a command prompt/terminal window, navigate to the root of the ITR release and run
```
python3 -m venv itr_ui
```
Expand All @@ -25,9 +24,17 @@ Next, run:
```
python3 -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
```

Now you are ready to change to the examples directory and run the tool:
```
cd examples
python3 ITR_UI.py
python3 ITR_UI.py "data/20230106 ITR V2 Sample Data.xlsx"
```
Note the python commands are ```python``` for windows and ``python3`` for linux/mac.

Note the python commands are ```python``` for windows and ``python3`` for linux/mac. If no file is specified, the tool uses a default, small ITR dataset. With a filename given, the ITR tool will load data from that dataset. The 20230106 data template has over 120 companies across nearly a dozen sectors.

Finally, open a browser window and navigate to `http://127.0.0.1:8050/` to access the user interface.

Expand Down
Binary file modified examples/data/20220927 ITR Tool Sample Data.xlsx
Binary file not shown.
Binary file modified examples/data/20220927 ITR V2 Sample Data.xlsx
Binary file not shown.
Binary file modified examples/data/20230106 ITR V2 Sample Data.xlsx
Binary file not shown.
21 changes: 11 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
python-dotenv==0.21.0
dash==2.7.1
dash_bootstrap_components==1.2.1
python-dotenv==1.0.0
dash==2.9.3
dash_bootstrap_components==1.4.1
multiprocess==0.70.14
diskcache==5.4.0
diskcache==5.6.1
iam-units==2022.10.27
jupyter==1.0.0
matplotlib==3.6.1
matplotlib==3.7.1
multiprocess==0.70.14
osc-ingest-tools==0.4.3
openpyxl==3.0.10
openscm-units==0.5.0
openscm-units==0.5.1
pandas==1.5.3
Pint==0.20.1
Pint-Pandas==0.3
pydantic==1.10.2
pydantic==1.10.7
pygithub==1.55
pytest==7.2.0
pytest==7.3.1
Sphinx==5.1.1
sphinx-autoapi==1.9.0
sphinx-autodoc-typehints==1.19.1
sphinx-rtd-theme==1.0.0
SQLAlchemy==1.4.42
trino==0.322.0
SQLAlchemy==1.4.48
trino==0.323.0
xlrd==2.0.1

0 comments on commit 6dbde11

Please sign in to comment.