Skip to content

Commit

Permalink
renamed eia_api.py to eia_api_v1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jdechalendar committed Jul 6, 2024
1 parent 5236409 commit 5d632eb
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"\n",
"import pandas as pd\n",
"from gridemissions.load import BaData\n",
"from gridemissions.eia_api import BAs, KEYS, SRC\n",
"from gridemissions.eia_api_v1 import BAs, KEYS, SRC\n",
"import gridemissions\n",
"import re\n",
"import numpy as np"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"\n",
"import pandas as pd\n",
"from gridemissions.load import BaData\n",
"from gridemissions.eia_api import BAs, KEYS, SRC\n",
"from gridemissions.eia_api_v1 import BAs, KEYS, SRC\n",
"import gridemissions\n",
"import re\n",
"import numpy as np"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name="gridemissions",
package_dir={"": "src"},
packages=find_packages("src"),
version="0.1.8.dev3",
version="0.1.8.dev4",
python_requires=">=3.7",
install_requires=["requests", "pandas>=2.0", "matplotlib>=3.4.2"],
extras_require={
Expand Down
12 changes: 6 additions & 6 deletions src/gridemissions/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd

import gridemissions
from gridemissions import eia_api
from gridemissions import eia_api_v1

DATETIME_FMT = "%Y%m%dT%H%MZ"
DATASET_TO_VARIABLE = {"raw": "E", "co2": "CO2", "elec": "E", "co2i": "CO2i"}
Expand Down Expand Up @@ -73,15 +73,15 @@ def retrieve(dataset, start=None, end=None, return_type="dataframe", **kwargs):
elec = retrieve(
dataset="elec", start=start, end=end, return_type="dataframe", **kwargs
)
key_E = eia_api.get_key("E")
key_CO2 = eia_api.get_key("CO2")
key_CO2i = eia_api.get_key("CO2i")
key_E = eia_api_v1.get_key("E")
key_CO2 = eia_api_v1.get_key("CO2")
key_CO2i = eia_api_v1.get_key("CO2i")
field = kwargs["field"]
co2.columns = co2.columns.map(
lambda x: eia_api.column_name_to_region(x, key_CO2[field])
lambda x: eia_api_v1.column_name_to_region(x, key_CO2[field])
)
elec.columns = elec.columns.map(
lambda x: eia_api.column_name_to_region(x, key_E[field])
lambda x: eia_api_v1.column_name_to_region(x, key_E[field])
)
co2i = co2 / elec
co2i.columns = co2i.columns.map(lambda x: key_CO2i[field] % x)
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/gridemissions/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import json
import re
import warnings
from gridemissions import config, eia_api, eia_api_v2
from gridemissions.eia_api import KEYS, EIA_ALLOWED_SERIES_ID
from gridemissions import config, eia_api_v1, eia_api_v2
from gridemissions.eia_api_v1 import KEYS, EIA_ALLOWED_SERIES_ID

RTOL = 1e-05
ATOL = 1e-08
Expand Down Expand Up @@ -449,13 +449,13 @@ def __init__(self, fileNm=None, df=None, variable="E", dataset="EBA", step=None)
self.df = pd.read_csv(fileNm, index_col=0, parse_dates=True)

# Infer variable from first data column
self.variable = eia_api.column_name_to_variable(self.df.columns[0])
self.variable = eia_api_v1.column_name_to_variable(self.df.columns[0])
self.regions = self._parse_data_cols()
self.fileNm = fileNm
if variable in KEYS:
self.KEY = KEYS[variable]
else:
self.KEY = eia_api.generic_key(variable)
self.KEY = eia_api_v1.generic_key(variable)

def get_cols(self, r=None, field="D"):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/gridemissions/papers/physics_informed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd

from gridemissions.viz.base import PAGE_WIDTH, ROW_HEIGHT, COLORS
from gridemissions.eia_api import SRC
from gridemissions.eia_api_v1 import SRC


def figure1(ba, ba_data_A, ba_data_D, ba_data_C=None, scale=1e-3, save_fig=False):
Expand Down
6 changes: 3 additions & 3 deletions test/test_compat_eia_api_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import gridemissions as ge
from gridemissions import eia_api, emissions
from gridemissions import eia_api_v1, emissions

from .eia_samples import get_path

Expand All @@ -11,10 +11,10 @@
def test_compat():
# Check we can still load data in the old format (EIA v1 API)
# I still have some of those files lying around from old papers...
elec = ge.read_csv(get_path("EBA_elec.csv"), api_module=eia_api)
elec = ge.read_csv(get_path("EBA_elec.csv"), api_module=eia_api_v1)
EF = emissions.EMISSIONS_FACTORS["CO2"].copy()
EF["NG"] = EF["GAS"]
del EF["GAS"]

co2_calc = ge.EmissionsCalc(elec, api_module=eia_api, EF=EF)
co2_calc = ge.EmissionsCalc(elec, api_module=eia_api_v1, EF=EF)
co2_calc.process()
2 changes: 1 addition & 1 deletion test/test_eia_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from gridemissions.eia_api import (
from gridemissions.eia_api_v1 import (
column_name_to_region,
column_name_to_variable,
parse_column,
Expand Down

0 comments on commit 5d632eb

Please sign in to comment.