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
feat: new chart type for sensor data: daily heatmap #715
Conversation
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Maybe the name "Runtime Matrix" is better? |
Suggestions welcome! The chart type will be available for any sensor. The term "runtime" seems particularly appropriate for power sensors of individual devices. For other sensors (those recording weather, prices, or aggregate power flows like the one shown above), it seems less appropriate. Note that, at the moment, the button text is the only user-facing term. At some point I imagine we'll also list available chart types in the CLI ( Also note that the image is already slightly outdated: in the code I've updated the button text: "Run times" is now "Time of day". Maybe it can also help to think about chart type names in the context of imagining a longer list of chart types (for showing sensor data). On the other hand, maybe that's just over-thinking things. |
Cool feature!! I've been experimenting with the DST time changes to see how 23h or 25h days would look like.
I'm not sure if it could be a fault on my side loading the data or there's something in the timezone location that is failing somewhere. Code to generate the dataimport asyncio
from flexmeasures_client.client import FlexMeasuresClient as Client
SENSOR_ID = 21 # 15min resolution sensor
EMAIL = "admin@admin.nl"
PASSWORD = "admin"
async def my_script():
# Winter to Summer
await client.post_measurements(
sensor_id=21,
entity_address="ea1.2023-06.localhost:fm1",
start="2023-03-25T00:00:00+02:00",
duration="PT80H",
unit="MW",
values=[1, 1, 1, 1, -1, -1, -1, -1]*40,
)
# Summer to Winter
await client.post_measurements(
sensor_id=21,
entity_address="ea1.2023-06.localhost:fm1",
start="2023-10-27T00:00:00+02:00",
duration="PT80H",
unit="MW",
values=[1, 1, 1, 1, -1, -1, -1, -1]*40,
)
client = Client(
email=EMAIL,
password=PASSWORD,
host="localhost:5000",
)
asyncio.run(my_script()) Winter to SummerTime SeriesMatrix ChartSummer to WinterTime SeriesMatrix Chart |
Okay, then "Activity Matrix" :) Definitely follow up with API integration, as this is the way where FlexMeasures hosters can add value for their customers (who are able to use those plots in their custom frontends. |
First of all, nice use of the FlexMeasures client! Let me discuss the charts in the order you posted them. Note that the time axes are in local time. The 23-hour day:
The 25-hour day:
|
Indeed, this edge case breaks the whole point of this data viz (align hours). I think the most important is to let the user know that they are seeing a DST time change and not a weird bug that might be affecting the data. For that, It would be great to show a mark indicating the moment of change of hour. Also, maybe we could let the user chose if they want to use CET/CEST... In any case, I think we should leave these improvements for a follow up issue. |
Signed-off-by: F.N. Claessen <felix@seita.nl>
…m request variables Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
I feel the naming issue is still open. I see "heatmap" and "matrix" being used, and the UI now says "Time of day". I realize one name might be the one in the code, one the user-facing label. They should nt be completely different though. Maybe the user label can be "Daily activity heatmap" and we call it "heatmap" internally? |
Does the replay button work well in this chart type? |
It works well, yes. Not perfect, though. The data shows up perfectly, but the one thing I couldn't get precisely right was the replay ruler. It is full-chart-height rather than the height of the currently replayed day. It was one of those things that seems like a really tiny thing, but then ends up taking hours (to, in this case, as of yet, not succeed). |
The ruler doesn't seem to be worth hours of our time. |
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
|
I can't seem to be able to test this feature locally. I'm running the right branch (see log below), I look at a sensor page, but there is no chart selection option:
Am I missing something? |
Perhaps a hard refresh in the browser? Can you check the page source for the chat type button? |
I see it now, not sure what went wrong. But I can't test this feature because I cannot upgrade my database with this step:
That's no part of this PR. |
I could resolve this local issue and now I can test. It works. Some limitations are that sources seem to be not labelled or not distinguished? See my screenshot above, it has two sources for the same sensor. I'm not sure if they are mixed or so. Also, one source gives schedules (Seita), the other measurements (Ard), I believe. The playback results in "interesting" behavior. I can make a screencast if needed. |
Good catch. Maybe I can create something to toggle between sources, because showing multiple sources in a single heatmap won't make for a very useful visual imo. Unless the sources don't overlap in time (e.g. when one source takes over from another). In that case it might make sense to show only the most recent source for each time step, and possibly indicate the transitions. Perhaps the second idea can be a follow-up issue, and for now we either support toggling or simply raise if the selected time period contains multiple sources. |
I'm for toggling, but it seems that might also be hours of work. Isn't toggling by source a feature we would like to have in general? Then that could be done with a benefit to the whole UI, and with this type of chart we should allow only one to be active at a time. |
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
I went some quite some way into getting the toggle selection to work, but in the end I abandoned it, because I can't manage to initialize the selection to show 1 source instead of none (or all) of the sources, at least not within vega-lite. So for now I decided to show the source with the most data (in the chart). |
Signed-off-by: F.N. Claessen <felix@seita.nl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, so now we only show data from one source, with no way to adapt.
I know this is still filed under "experimental", but should we not mention this below the chart (maybe if there are more than one source, or just in genera)?
Otherwise, I confirmed locally that it works :) |
…same number of data points, arbitrarily pick the first one in the data Signed-off-by: F.N. Claessen <felix@seita.nl>
…s sources (#780) Signed-off-by: F.N. Claessen <felix@seita.nl>
This is essentially a heatmap of the sensor's values, with dates on the y-axis and time of day on the x-axis. For individual devices, it gives an insight into the device's running times. A new button lets users switch between charts.
I needed this trick to align the date labels.