Skip to content

Commit

Permalink
Update key mapping for US-SPP (#1530)
Browse files Browse the repository at this point in the history
* Update key mapping for US-SPP

* Create new mock data and update tests for SPP
  • Loading branch information
systemcatch authored and corradio committed Jul 27, 2018
1 parent 19f8041 commit c5e5b51
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
7 changes: 3 additions & 4 deletions parsers/US_SPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
'Solar': 'solar',
'Natural Gas': 'gas',
'Diesel Fuel Oil': 'oil',
'Waste Disposal Services': 'biomass'
'Waste Disposal Services': 'biomass',
'Coal': 'coal'
}

TIE_MAPPING = {'US-MISO->US-SPP': ['AMRN', 'DPC', 'GRE', 'MDU', 'MEC', 'NSP', 'OTP']}
Expand Down Expand Up @@ -50,8 +51,7 @@ def data_processor(df, logger):
# Remove leading whitespace in column headers.
df.columns = df.columns.str.strip()

keys_to_remove = {'Coal Market', 'Coal Self', 'GMT MKT Interval', 'Average Actual Load',
'Other', 'Waste Heat'}
keys_to_remove = {'GMT MKT Interval', 'Average Actual Load', 'Other', 'Waste Heat'}

# Check for new generation columns.
known_keys = MAPPING.keys() | keys_to_remove
Expand All @@ -68,7 +68,6 @@ def data_processor(df, logger):
processed_data = []
for index, row in df.iterrows():
production = row.to_dict()
production['coal'] = production['Coal Market'] + production['Coal Self']

extra_unknowns = sum([production[k] for k in unknown_keys])
production['unknown'] = production['Other'] + production['Waste Heat'] + extra_unknowns
Expand Down
Binary file modified parsers/test/mocks/US_SPP_Gen_Mix.pkl
Binary file not shown.
8 changes: 2 additions & 6 deletions parsers/test/test_US_SPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ def test_fetch_production(self):
with self.subTest():
self.assertEqual(len(data), 23)

# Multiple coal keys in data source, ensure they are summed correctly.
with self.subTest():
self.assertEqual(round(datapoint['production']['coal'], 2), 15963.60)

# Unknown keys must be assigned and summed.
with self.subTest():
self.assertEqual(round(datapoint['production']['unknown'], 2), 63.67)
self.assertEqual(round(datapoint['production']['unknown'], 2), 33.1)

with self.subTest():
expected_dt = get(datetime(2018, 2, 23, 12, 25), 'UTC').datetime
expected_dt = get(datetime(2018, 7, 27, 11, 45), 'UTC').datetime
self.assertEqual(datapoint['datetime'], expected_dt)

with self.subTest():
Expand Down

0 comments on commit c5e5b51

Please sign in to comment.