Skip to content

Commit

Permalink
Merge pull request #3053 from SEED-platform/Fix-electricity-meter-imp…
Browse files Browse the repository at this point in the history
…ort-from-ESPM-custom-report

Fix: electricity meter import from ESPM custom report
  • Loading branch information
macintoshpie committed Dec 22, 2021
2 parents db0e14e + 9135f0e commit 56f2000
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions seed/data_importer/meters_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,10 @@ class with the data.
return []

TYPE_AND_UNITS_REGEX = re.compile(r'(?P<meter_type>.*)\s+\((?P<units>.*)\)')
meter_type_lookup = dict(Meter.ENERGY_TYPES)
METER_TYPE_MAPPING = {
'Electricity Use': 'Electric - Unknown',
'Natural Gas Use': 'Natural Gas',
'Electricity Use (Grid)': meter_type_lookup[Meter.ELECTRICITY_GRID],
'Natural Gas Use': meter_type_lookup[Meter.NATURAL_GAS],
}
METER_UNITS_MAPPING = {
'kBtu': 'kBtu (thousand Btu)',
Expand Down
Binary file not shown.
28 changes: 28 additions & 0 deletions seed/data_importer/tests/test_meters_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
FakePropertyStateFactory,
)
from seed.utils.organizations import create_organization
from pathlib import Path
from seed.lib.mcm import reader


class ThermalConversionTests(TestCase):
Expand Down Expand Up @@ -87,6 +89,32 @@ def setUp(self):

self.tz_obj = timezone(TIME_ZONE)

def test_parse_meter_preprocess_raw_pm_data_request(self):
with open(Path(__file__).resolve().parent / "data/example-pm-data-request-with-meters.xlsx") as meters_file:
parser = reader.MCMParser(meters_file, sheet_name='Monthly Usage')

raw_meter_data = MetersParser.preprocess_raw_pm_data_request(parser.data)
self.assertEqual(raw_meter_data, [
{
'Start Date': '2016-01-01 00:00:00',
'End Date': '2016-02-01 00:00:00',
'Portfolio Manager ID': '4544232',
'Portfolio Manager Meter ID': 'Unknown',
'Meter Type': 'Electric - Grid',
'Usage/Quantity': '85887.1',
'Usage Units': 'kBtu (thousand Btu)'
},
{
'Start Date': '2016-02-01 00:00:00',
'End Date': '2016-03-01 00:00:00',
'Portfolio Manager ID': '4544232',
'Portfolio Manager Meter ID': 'Unknown',
'Meter Type': 'Electric - Grid',
'Usage/Quantity': '175697.3',
'Usage Units': 'kBtu (thousand Btu)'
}
])

def test_parse_meter_details_splits_monthly_info_into_meter_data_and_readings_even_with_DST_changing(self):
raw_meters = [
{
Expand Down

0 comments on commit 56f2000

Please sign in to comment.