Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meters #1853

Merged
merged 105 commits into from
May 6, 2019
Merged

Meters #1853

merged 105 commits into from
May 6, 2019

Conversation

adrian-lara
Copy link
Contributor

@adrian-lara adrian-lara commented Apr 1, 2019

Implementation of Meter uploads using a time-series enhanced database (Postgres + TimescaleDB extension).

Any background context you want to provide?

Notable details/caveats:

  • Documentation for how Thermal Conversions are brought into app has been shared with NREL via 'NREL-Devetry' shared directory.
  • As a reminder, it's been decided that this Meters implementation needs to be supplemented with a follow up script and code update to allow PropertyState models to be associated to each other by Property models.
  • Successfully imported meter files, importfiles, show up in importrecord detail without associated cycles as their data is not bounded by cycles.
  • An issue exists when/if duplicate times are provided in GreenButton import across different batches. This comes from batch upserting meters in groups of 1000, where duplicate meter entries could exist in different batches. One of the duplicate readings will be chosen according to which batch finishes last (randomly). If duplicates exist with the same batch, the app correctly identifies this as an error and does not upload these entries since it isn't known which entry should take precedence. (This is an edge/corner case that I decided to punt on for now due to time constraints.)
  • GreenButton types are assumed to be either "Electricity" or "Natural Gas". Corresponding units are parsed to the best of our ability. Only units known in Portfolio Manager imports (and their metric conversions, m, d, k, M, G etc.) are accepted from GreenButton as these are the only ones for which we have thermal conversions.

Assumptions:

  • A GreenButton meter import contains data for one meter of a single property.
  • There cannot be 2 different meters of the same type for a single property.

What's this PR do?

Key features include:

  • the ability to import Portfolio Manager monthly meter data
  • the ability to import GreenButton (sub-monthly) meter data
  • the ability to view exact meter data (w/ start and end times) as well as monthly and annually aggregated meter data

How should this be manually tested?

Import PM monthly meters for multiple properties and GB meters for single properties. View the uploaded meters using the new "Energy" tab in the property detail pages.

What are the relevant tickets?

Screenshots (if appropriate)

Adrian Lara and others added 30 commits February 12, 2019 10:30
* TravisCI - install timescaledb

* flake8 linter
adrian-lara and others added 2 commits April 29, 2019 16:57
* Update TimescaleDB OSX install instructions
Copy link
Member

@nllong nllong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @adrian-lara can you verify the timestamp imports for GreenButton? It looks like the data are in epoch time, but when importing and converting, it looks like that we are at least 1 hour off.

Raw file (example-GreenButton-data.xml)

<IntervalReading>
          <timePeriod>
            <duration>900</duration>
            <start>1299387600</start>
          </timePeriod>
          <value>1790</value>
        </IntervalReading>
        <IntervalReading>
          <timePeriod>
            <duration>900</duration>
            <start>1299388500</start>
          </timePeriod>
          <value>1791</value>
        </IntervalReading>

Epoch Calc
image

Seed
image

@nllong
Copy link
Member

nllong commented May 2, 2019

Can you move the Energy tab to be just to the right of the "Property Detail"?
image

@nllong
Copy link
Member

nllong commented May 2, 2019

Fix the spacing between the last two items:

image

url(r'meters/(?P<pk>\w+)/timeseries/$',
MeterViewSet.as_view({'post': 'add_timeseries'}),
name='meters-add-timeseries'),
# url(r'meters/(?P<pk>\w+)/timeseries/$',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just remove these? Seems like these are old.


self.assertEqual(meter_reading_10.start_time, make_aware(datetime(2011, 3, 5, 21, 0, 0), timezone=self.tz_obj))
self.assertEqual(meter_reading_10.end_time, make_aware(datetime(2011, 3, 5, 21, 15, 0), timezone=self.tz_obj))
self.assertEqual(meter_reading_10.reading, 1790 * 3.412 / 1000 * ureg('kBtu'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

# Sanity check to be sure, nothing was changed with existing meter reading
self.assertEqual(meter_reading_12, existing_meter_reading)

def test_existing_meter_reading_has_reading_source_unit_and_conversion_factor_updated_if_import_file_references_previous_entry(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this_is_the_longest_function_name_ive_ever_seen

@@ -119,12 +136,17 @@ class Meta:
created = models.DateTimeField(auto_now_add=True, null=True)
modified = models.DateTimeField(auto_now=True, null=True)

# Default preferred all meter units to kBtu
display_meter_units = JSONField(default=_default_display_meter_units)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

name='meter',
),
migrations.RemoveField(
model_name='meter',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for cleaning these up.

@nllong
Copy link
Member

nllong commented May 2, 2019

This interface is a bit strange... but i think we leave it for now. It is quite cool that users can specify the way to want to view meter data by units.

image

@nllong
Copy link
Member

nllong commented May 2, 2019

Fix the spacing between the last two items:

image

Per @RDmitchell -- And how about putting all the ESPM choices together? Which would mean the ESPM meter option would go right below the Upload Portfolio Manager Data button

@SEED-platform SEED-platform deleted a comment from RDmitchell May 2, 2019
@adrian-lara
Copy link
Contributor Author

hi @adrian-lara can you verify the timestamp imports for GreenButton? It looks like the data are in epoch time, but when importing and converting, it looks like that we are at least 1 hour off.

Raw file (example-GreenButton-data.xml)

<IntervalReading>
          <timePeriod>
            <duration>900</duration>
            <start>1299387600</start>
          </timePeriod>
          <value>1790</value>
        </IntervalReading>
        <IntervalReading>
          <timePeriod>
            <duration>900</duration>
            <start>1299388500</start>
          </timePeriod>
          <value>1791</value>
        </IntervalReading>

Epoch Calc
image

Seed
image

@nllong, I specified GB epoch times to be read and saved using the default timezone of the app America/Los_Angeles specified here:

TIME_ZONE = 'America/Los_Angeles'

I used the same epoch converter site but changed the timezone (https://www.epochconverter.com/timezones?q=1299387600&tz=America%2FLos_Angeles) and got the time shown in your SEED screenshot.

@nllong
Copy link
Member

nllong commented May 3, 2019 via email

@RDmitchell
Copy link

Do we have a good source for greenbutton data? When we were implementing this before with CMU I generated greenbutton files from my house, which I can do again if that would be useful.

@adrian-lara
Copy link
Contributor Author

The samples I used came from here: https://www.energy.gov/downloads/green-button-sample-data-pge

Do we have a good source for greenbutton data? When we were implementing this before with CMU I generated greenbutton files from my house, which I can do again if that would be useful.

@nllong
Copy link
Member

nllong commented May 6, 2019

Fix the spacing between the last two items:

image

Looks good. Thanks for the fixes.
image

@nllong
Copy link
Member

nllong commented May 6, 2019

I think this is good to go. Any last comments before I merge?

@nllong
Copy link
Member

nllong commented May 6, 2019

Can you move the Energy tab to be just to the right of the "Property Detail"?
image
bingo.

image

@nllong nllong merged commit af71f64 into develop May 6, 2019
@nllong nllong deleted the meters branch May 6, 2019 19:51
@nllong nllong mentioned this pull request Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants