Last active
September 27, 2025 19:13
-
-
Save bbartling/b961e04b9b88c3690454687d271fc81b to your computer and use it in GitHub Desktop.
Linkedlen article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import os | |
| # Load the CSV data into a DataFrame | |
| df = pd.read_csv("Merged_Weather_System_Data.csv") | |
| # Convert timestamp to datetime and set as index | |
| df['ts'] = pd.to_datetime(df['ts']) | |
| df.set_index('ts', inplace=True) | |
| print(df.columns) | |
| print(df.head()) | |
| # Filter for when the chiller is running (Pump Speed > 20%) | |
| df_running = df[ | |
| (df['Berry ES CHW System CHW Loop Temp'] < 50) | |
| ] | |
| # Define bins and labels for OAT (Outside Air Temperature) | |
| bins = np.arange(40, 115, 5) # Bins from 40 to 110 in 5-degree increments | |
| labels = [f"{i}_{i+4}" for i in bins[:-1]] | |
| # Bin the OAT data and count hours in each bin | |
| df_running['OAT_bin'] = pd.cut(df_running['Temperature_F'], bins=bins, labels=labels, right=False) | |
| # Count total hours for each bin | |
| hours_binned = df_running.groupby('OAT_bin', observed=True).size() | |
| # Create output directory if it doesn't exist | |
| output_dir = "binned_hours" | |
| os.makedirs(output_dir, exist_ok=True) | |
| # Save results to CSV | |
| hours_binned.to_csv(os.path.join(output_dir, "chiller_hours_binned.csv")) | |
| print(hours_binned) | |
| # Plotting the binned hours | |
| plt.figure(figsize=(12, 6)) | |
| bars = hours_binned.plot(kind='bar', color='skyblue', edgecolor='black') | |
| plt.xlabel('OAT Bins (°F)') | |
| plt.ylabel('Hours Chiller Ran') | |
| plt.title('Chiller Run Hours by OAT Bin') | |
| plt.grid(axis='y', linestyle='--', alpha=0.7) | |
| plt.xticks(rotation=45) | |
| # Annotate bars with values | |
| for i, val in enumerate(hours_binned): | |
| plt.text(i, val + 0.5, str(val), ha='center', va='bottom', fontsize=8, rotation=45) | |
| plt.tight_layout() | |
| # Save the plot | |
| plt.savefig(os.path.join(output_dir, "chiller_hours_binned_plot.png")) | |
| plt.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "annotations": { | |
| "list": [ | |
| { | |
| "builtIn": 1, | |
| "datasource": { | |
| "type": "grafana", | |
| "uid": "-- Grafana --" | |
| }, | |
| "enable": true, | |
| "hide": true, | |
| "iconColor": "rgba(0, 211, 255, 1)", | |
| "name": "Annotations & Alerts", | |
| "type": "dashboard" | |
| } | |
| ] | |
| }, | |
| "editable": true, | |
| "fiscalYearStartMonth": 0, | |
| "graphTooltip": 0, | |
| "id": 67, | |
| "links": [], | |
| "panels": [ | |
| { | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "fieldConfig": { | |
| "defaults": { | |
| "color": { | |
| "mode": "continuous-GrYlRd" | |
| }, | |
| "custom": { | |
| "axisBorderShow": false, | |
| "axisCenteredZero": false, | |
| "axisColorMode": "text", | |
| "axisLabel": "", | |
| "axisPlacement": "auto", | |
| "barAlignment": 0, | |
| "barWidthFactor": 0.6, | |
| "drawStyle": "line", | |
| "fillOpacity": 20, | |
| "gradientMode": "scheme", | |
| "hideFrom": { | |
| "legend": false, | |
| "tooltip": false, | |
| "viz": false | |
| }, | |
| "insertNulls": false, | |
| "lineInterpolation": "smooth", | |
| "lineWidth": 3, | |
| "pointSize": 5, | |
| "scaleDistribution": { | |
| "type": "linear" | |
| }, | |
| "showPoints": "auto", | |
| "spanNulls": false, | |
| "stacking": { | |
| "group": "A", | |
| "mode": "none" | |
| }, | |
| "thresholdsStyle": { | |
| "mode": "off" | |
| } | |
| }, | |
| "mappings": [], | |
| "thresholds": { | |
| "mode": "absolute", | |
| "steps": [ | |
| { | |
| "color": "green", | |
| "value": 0 | |
| }, | |
| { | |
| "color": "red", | |
| "value": 80 | |
| } | |
| ] | |
| } | |
| }, | |
| "overrides": [] | |
| }, | |
| "gridPos": { | |
| "h": 10, | |
| "w": 24, | |
| "x": 0, | |
| "y": 0 | |
| }, | |
| "id": 2, | |
| "options": { | |
| "legend": { | |
| "calcs": [], | |
| "displayMode": "hidden", | |
| "placement": "right", | |
| "showLegend": false | |
| }, | |
| "tooltip": { | |
| "hideZeros": false, | |
| "mode": "single", | |
| "sort": "none" | |
| } | |
| }, | |
| "pluginVersion": "12.1.1", | |
| "repeat": "station", | |
| "repeatDirection": "h", | |
| "targets": [ | |
| { | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "editorMode": "code", | |
| "format": "table", | |
| "rawQuery": true, | |
| "rawSql": "WITH samples AS (\r\n SELECT\r\n a.id,\r\n a.station_name,\r\n b.time,\r\n COALESCE(b.value::int, 0) AS value,\r\n EXTRACT(EPOCH FROM (LEAD(b.time) OVER (PARTITION BY a.id ORDER BY b.time) - b.time)) AS dur\r\n FROM vw_nfmeta_fox a\r\n JOIN data b ON b.point_id = a.id\r\n WHERE\r\n $__timeFilter(b.time)\r\n AND a.station_name IN ($station)\r\n AND a.point_name IN ($objname)\r\n),\r\nclean AS (\r\n SELECT\r\n station_name, time, value,\r\n -- cap any single step to 1 hour to avoid outage spikes\r\n GREATEST(0, LEAST(COALESCE(dur, 0), 3600)) AS dur_capped\r\n FROM samples\r\n)\r\nSELECT\r\n $__timeGroup(time, '1d') AS \"time\", -- daily buckets as TIMESTAMP\r\n station_name AS metric, -- one line per station\r\n SUM(CASE WHEN value = 1 THEN dur_capped ELSE 0 END) / 3600.0 AS \"Daily Run Hours\"\r\nFROM clean\r\nGROUP BY 1, 2\r\nORDER BY 1, 2;\r\n", | |
| "refId": "A", | |
| "sql": { | |
| "columns": [ | |
| { | |
| "parameters": [], | |
| "type": "function" | |
| } | |
| ], | |
| "groupBy": [ | |
| { | |
| "property": { | |
| "type": "string" | |
| }, | |
| "type": "groupBy" | |
| } | |
| ], | |
| "limit": 50 | |
| } | |
| } | |
| ], | |
| "title": "$station Daily Run Hours", | |
| "type": "timeseries" | |
| }, | |
| { | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "fieldConfig": { | |
| "defaults": { | |
| "color": { | |
| "mode": "thresholds" | |
| }, | |
| "custom": { | |
| "axisBorderShow": false, | |
| "axisCenteredZero": false, | |
| "axisColorMode": "text", | |
| "axisLabel": "Run Hours", | |
| "axisPlacement": "auto", | |
| "fillOpacity": 80, | |
| "gradientMode": "none", | |
| "hideFrom": { | |
| "legend": false, | |
| "tooltip": false, | |
| "viz": false | |
| }, | |
| "lineWidth": 1, | |
| "scaleDistribution": { | |
| "type": "linear" | |
| }, | |
| "thresholdsStyle": { | |
| "mode": "off" | |
| } | |
| }, | |
| "displayName": "Motor Run Hours", | |
| "mappings": [], | |
| "thresholds": { | |
| "mode": "absolute", | |
| "steps": [ | |
| { | |
| "color": "green", | |
| "value": 0 | |
| }, | |
| { | |
| "color": "orange", | |
| "value": 217 | |
| }, | |
| { | |
| "color": "yellow", | |
| "value": 271 | |
| }, | |
| { | |
| "color": "red", | |
| "value": 325 | |
| } | |
| ] | |
| } | |
| }, | |
| "overrides": [] | |
| }, | |
| "gridPos": { | |
| "h": 14, | |
| "w": 24, | |
| "x": 0, | |
| "y": 30 | |
| }, | |
| "id": 1, | |
| "options": { | |
| "barRadius": 0, | |
| "barWidth": 0.97, | |
| "colorByField": "Monthly Run Hours", | |
| "fullHighlight": false, | |
| "groupWidth": 0.7, | |
| "legend": { | |
| "calcs": [], | |
| "displayMode": "list", | |
| "placement": "bottom", | |
| "showLegend": true | |
| }, | |
| "orientation": "auto", | |
| "showValue": "auto", | |
| "stacking": "none", | |
| "tooltip": { | |
| "hideZeros": false, | |
| "mode": "single", | |
| "sort": "none" | |
| }, | |
| "xTickLabelRotation": 0, | |
| "xTickLabelSpacing": 0 | |
| }, | |
| "pluginVersion": "12.1.1", | |
| "repeat": "station", | |
| "repeatDirection": "h", | |
| "targets": [ | |
| { | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "editorMode": "code", | |
| "format": "table", | |
| "hide": false, | |
| "rawQuery": true, | |
| "rawSql": "WITH samples AS (\r\n SELECT\r\n a.id,\r\n a.station_name,\r\n b.time,\r\n COALESCE(b.value::int, 0) AS value,\r\n EXTRACT(EPOCH FROM (LEAD(b.time) OVER (PARTITION BY a.id ORDER BY b.time) - b.time)) AS dur\r\n FROM vw_nfmeta_fox a\r\n JOIN data b ON b.point_id = a.id\r\n WHERE\r\n $__timeFilter(b.time)\r\n AND a.station_name IN ($station)\r\n AND a.point_name IN ($objname)\r\n),\r\nclean AS (\r\n SELECT\r\n station_name,\r\n time,\r\n value,\r\n -- cap any single gap to 1 hour to avoid outage spikes\r\n GREATEST(0, LEAST(COALESCE(dur, 0), 3600)) AS dur_capped\r\n FROM samples\r\n)\r\nSELECT\r\n to_char(time_bucket('1 month', time), 'YYYY-MM') AS \"Month\", -- x-axis label\r\n station_name AS metric, -- series by Station\r\n SUM(CASE WHEN value = 1 THEN dur_capped ELSE 0 END) / 3600.0 AS \"Monthly Run Hours\"\r\nFROM clean\r\nGROUP BY 1, 2\r\nORDER BY 1, 2;\r\n", | |
| "refId": "B", | |
| "sql": { | |
| "columns": [ | |
| { | |
| "parameters": [], | |
| "type": "function" | |
| } | |
| ], | |
| "groupBy": [ | |
| { | |
| "property": { | |
| "type": "string" | |
| }, | |
| "type": "groupBy" | |
| } | |
| ], | |
| "limit": 50 | |
| } | |
| } | |
| ], | |
| "title": "$station Run Hours", | |
| "type": "barchart" | |
| } | |
| ], | |
| "preload": false, | |
| "refresh": "", | |
| "schemaVersion": 41, | |
| "tags": [], | |
| "templating": { | |
| "list": [ | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": "Diggs", | |
| "value": "Diggs" | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "select distinct site \nfrom vw_nfmeta_fox\nwhere station_name is not null;", | |
| "description": "", | |
| "label": "Site", | |
| "name": "site", | |
| "options": [], | |
| "query": "select distinct site \nfrom vw_nfmeta_fox\nwhere station_name is not null;", | |
| "refresh": 1, | |
| "regex": "", | |
| "sort": 1, | |
| "type": "query" | |
| }, | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": [ | |
| "Diggs_RTU4", | |
| "Diggs_RTU5", | |
| "Diggs_RTU3", | |
| "Diggs_RTU2", | |
| "Diggs_RTU1", | |
| "Diggs_RTU6", | |
| "Diggs_RTU7", | |
| "Diggs_RTU8", | |
| "Diggs_RTU9" | |
| ], | |
| "value": [ | |
| "Diggs_RTU4", | |
| "Diggs_RTU5", | |
| "Diggs_RTU3", | |
| "Diggs_RTU2", | |
| "Diggs_RTU1", | |
| "Diggs_RTU6", | |
| "Diggs_RTU7", | |
| "Diggs_RTU8", | |
| "Diggs_RTU9" | |
| ] | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "select distinct station_name \nfrom vw_nfmeta_fox\nwhere site ='$site'\nand station_name is not null;", | |
| "includeAll": false, | |
| "label": "Station", | |
| "multi": true, | |
| "name": "station", | |
| "options": [], | |
| "query": "select distinct station_name \nfrom vw_nfmeta_fox\nwhere site ='$site'\nand station_name is not null;", | |
| "refresh": 1, | |
| "regex": "", | |
| "sort": 1, | |
| "type": "query" | |
| }, | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": [ | |
| "/RTU4", | |
| "/RTU5" | |
| ], | |
| "value": [ | |
| "/RTU4", | |
| "/RTU5" | |
| ] | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "select distinct path from vw_nfmeta_fox where path is not null and site ='$site' and station_name IN ($station)", | |
| "includeAll": false, | |
| "label": "Path", | |
| "multi": true, | |
| "name": "path", | |
| "options": [], | |
| "query": "select distinct path from vw_nfmeta_fox where path is not null and site ='$site' and station_name IN ($station)", | |
| "refresh": 1, | |
| "regex": "", | |
| "sort": 1, | |
| "type": "query" | |
| }, | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": [ | |
| "AhuScheduleNextTime", | |
| "SaFanStatus" | |
| ], | |
| "value": [ | |
| "AhuScheduleNextTime", | |
| "SaFanStatus" | |
| ] | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "select distinct point_name from vw_nfmeta_fox where station_name IN ($station) and site = '$site' and path IN ($path)", | |
| "includeAll": false, | |
| "label": "Point Name", | |
| "multi": true, | |
| "name": "objname", | |
| "options": [], | |
| "query": "select distinct point_name from vw_nfmeta_fox where station_name IN ($station) and site = '$site' and path IN ($path)", | |
| "refresh": 1, | |
| "regex": "", | |
| "sort": 1, | |
| "type": "query" | |
| } | |
| ] | |
| }, | |
| "time": { | |
| "from": "now-300d", | |
| "to": "now" | |
| }, | |
| "timepicker": {}, | |
| "timezone": "browser", | |
| "title": "Diggs AHU Fan Run Hours", | |
| "uid": "9bf09166-325c-4f92-b65e-76a80844129e", | |
| "version": 20 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "annotations": { | |
| "list": [ | |
| { | |
| "builtIn": 1, | |
| "datasource": { | |
| "type": "grafana", | |
| "uid": "-- Grafana --" | |
| }, | |
| "enable": true, | |
| "hide": true, | |
| "iconColor": "rgba(0, 211, 255, 1)", | |
| "name": "Annotations & Alerts", | |
| "type": "dashboard" | |
| } | |
| ] | |
| }, | |
| "editable": true, | |
| "fiscalYearStartMonth": 0, | |
| "graphTooltip": 0, | |
| "id": 69, | |
| "links": [], | |
| "panels": [ | |
| { | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "fieldConfig": { | |
| "defaults": { | |
| "color": { | |
| "mode": "palette-classic" | |
| }, | |
| "custom": { | |
| "axisBorderShow": false, | |
| "axisCenteredZero": false, | |
| "axisColorMode": "text", | |
| "axisLabel": "Run Hours", | |
| "axisPlacement": "left", | |
| "fillOpacity": 80, | |
| "gradientMode": "none", | |
| "hideFrom": { | |
| "legend": false, | |
| "tooltip": false, | |
| "viz": false | |
| }, | |
| "lineWidth": 1, | |
| "scaleDistribution": { | |
| "type": "linear" | |
| }, | |
| "thresholdsStyle": { | |
| "mode": "off" | |
| } | |
| }, | |
| "mappings": [], | |
| "thresholds": { | |
| "mode": "absolute", | |
| "steps": [ | |
| { | |
| "color": "green", | |
| "value": 0 | |
| } | |
| ] | |
| }, | |
| "unit": "short" | |
| }, | |
| "overrides": [ | |
| { | |
| "matcher": { | |
| "id": "byName", | |
| "options": "OAT Bin (°F)" | |
| }, | |
| "properties": [ | |
| { | |
| "id": "custom.axisLabel", | |
| "value": "Outside Air Temp Ranges" | |
| } | |
| ] | |
| } | |
| ] | |
| }, | |
| "gridPos": { | |
| "h": 12, | |
| "w": 24, | |
| "x": 0, | |
| "y": 0 | |
| }, | |
| "id": 2, | |
| "options": { | |
| "barRadius": 0, | |
| "barWidth": 0.97, | |
| "colorByField": "OAT Bin (°F)", | |
| "fullHighlight": false, | |
| "groupWidth": 0.7, | |
| "legend": { | |
| "calcs": [], | |
| "displayMode": "list", | |
| "placement": "right", | |
| "showLegend": true | |
| }, | |
| "orientation": "auto", | |
| "showValue": "always", | |
| "stacking": "none", | |
| "tooltip": { | |
| "hideZeros": false, | |
| "mode": "single", | |
| "sort": "none" | |
| }, | |
| "xTickLabelRotation": 0, | |
| "xTickLabelSpacing": 0 | |
| }, | |
| "pluginVersion": "12.1.1", | |
| "targets": [ | |
| { | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "editorMode": "code", | |
| "format": "table", | |
| "rawQuery": true, | |
| "rawSql": "-- Vars used: $site, $station, $path, $oat_point, $chilled_water_temp_point\r\nWITH ids AS (\r\n SELECT\r\n (SELECT id FROM vw_nfmeta_fox\r\n WHERE site = ${site:singlequote}\r\n AND station_name IN (${station:singlequote})\r\n AND point_name IN (${oat_point:singlequote})\r\n LIMIT 1) AS oat_id,\r\n (SELECT id FROM vw_nfmeta_fox\r\n WHERE site = ${site:singlequote}\r\n AND station_name IN (${station:singlequote})\r\n AND path IN (${path:singlequote})\r\n AND point_name IN (${chilled_water_temp_point:singlequote})\r\n LIMIT 1) AS chw_id\r\n),\r\naligned AS (\r\n SELECT\r\n time_bucket('5 minutes', d.time) AS ts,\r\n MAX(CASE WHEN d.point_id = i.oat_id THEN d.value END) AS oat_f,\r\n MAX(CASE WHEN d.point_id = i.chw_id THEN d.value END) AS chw_f\r\n FROM data d\r\n CROSS JOIN ids i\r\n WHERE $__timeFilter(d.time)\r\n AND d.point_id IN (i.oat_id, i.chw_id)\r\n GROUP BY ts\r\n),\r\nrunning AS (\r\n SELECT\r\n ts, oat_f, chw_f,\r\n -- cap the step size to the bucket (5 min = 300 s)\r\n LEAST(EXTRACT(EPOCH FROM (LEAD(ts) OVER (ORDER BY ts) - ts)), 300) AS dt_s\r\n FROM aligned\r\n),\r\nfiltered AS (\r\n SELECT\r\n dt_s AS duration_seconds,\r\n GREATEST(40, LEAST(110, oat_f)) AS oat_clamped\r\n FROM running\r\n WHERE dt_s IS NOT NULL\r\n AND oat_f IS NOT NULL\r\n AND chw_f IS NOT NULL\r\n AND chw_f < 50 -- running condition (edit as needed)\r\n),\r\nbinned AS (\r\n SELECT\r\n (FLOOR(oat_clamped / 5) * 5) AS bin_start,\r\n SUM(duration_seconds) / 3600.0 AS hours\r\n FROM filtered\r\n GROUP BY 1\r\n)\r\nSELECT\r\n bin_start::int || '-' || (bin_start + 4)::int AS \"OAT Bin (°F)\",\r\n hours AS \"Hours Chiller Ran\"\r\nFROM binned\r\nWHERE bin_start BETWEEN 40 AND 110\r\nORDER BY bin_start;\r\n", | |
| "refId": "A", | |
| "sql": { | |
| "columns": [ | |
| { | |
| "parameters": [], | |
| "type": "function" | |
| } | |
| ], | |
| "groupBy": [ | |
| { | |
| "property": { | |
| "type": "string" | |
| }, | |
| "type": "groupBy" | |
| } | |
| ], | |
| "limit": 50 | |
| } | |
| } | |
| ], | |
| "title": "$station Chiller Run Hours", | |
| "type": "barchart" | |
| }, | |
| { | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "fieldConfig": { | |
| "defaults": { | |
| "color": { | |
| "mode": "palette-classic" | |
| }, | |
| "custom": { | |
| "axisBorderShow": false, | |
| "axisCenteredZero": false, | |
| "axisColorMode": "text", | |
| "axisLabel": "", | |
| "axisPlacement": "auto", | |
| "barAlignment": 0, | |
| "barWidthFactor": 0.6, | |
| "drawStyle": "line", | |
| "fillOpacity": 25, | |
| "gradientMode": "none", | |
| "hideFrom": { | |
| "legend": false, | |
| "tooltip": false, | |
| "viz": false | |
| }, | |
| "insertNulls": false, | |
| "lineInterpolation": "linear", | |
| "lineWidth": 1, | |
| "pointSize": 5, | |
| "scaleDistribution": { | |
| "type": "linear" | |
| }, | |
| "showPoints": "auto", | |
| "spanNulls": false, | |
| "stacking": { | |
| "group": "A", | |
| "mode": "normal" | |
| }, | |
| "thresholdsStyle": { | |
| "mode": "off" | |
| } | |
| }, | |
| "mappings": [], | |
| "thresholds": { | |
| "mode": "absolute", | |
| "steps": [ | |
| { | |
| "color": "green", | |
| "value": 0 | |
| }, | |
| { | |
| "color": "red", | |
| "value": 80 | |
| } | |
| ] | |
| } | |
| }, | |
| "overrides": [] | |
| }, | |
| "gridPos": { | |
| "h": 14, | |
| "w": 24, | |
| "x": 0, | |
| "y": 12 | |
| }, | |
| "id": 1, | |
| "options": { | |
| "legend": { | |
| "calcs": [], | |
| "displayMode": "hidden", | |
| "placement": "right", | |
| "showLegend": false | |
| }, | |
| "tooltip": { | |
| "hideZeros": false, | |
| "mode": "single", | |
| "sort": "none" | |
| } | |
| }, | |
| "pluginVersion": "12.1.1", | |
| "repeat": "station", | |
| "repeatDirection": "h", | |
| "targets": [ | |
| { | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "editorMode": "code", | |
| "format": "table", | |
| "hide": false, | |
| "rawQuery": true, | |
| "rawSql": "WITH ids AS (\r\n SELECT\r\n (SELECT id FROM vw_nfmeta_fox\r\n WHERE site = ${site:singlequote}\r\n AND station_name IN (${station:singlequote})\r\n AND point_name IN (${oat_point:singlequote})\r\n LIMIT 1) AS oat_id,\r\n (SELECT id FROM vw_nfmeta_fox\r\n WHERE site = ${site:singlequote}\r\n AND station_name IN (${station:singlequote})\r\n AND path IN (${path:singlequote})\r\n AND point_name IN (${chilled_water_temp_point:singlequote})\r\n LIMIT 1) AS chw_id\r\n)\r\nSELECT\r\n time_bucket('5 minutes', d.time) AS \"time\",\r\n MAX(CASE WHEN d.point_id = i.oat_id THEN d.value END) AS \"Outside Air Temp\",\r\n MAX(CASE WHEN d.point_id = i.chw_id THEN d.value END) AS \"Chilled Water Temp\"\r\n -- Example clamp for visual sanity: -- GREATEST(34, LEAST(65, ...)) AS \"Chilled Water Temp\"\r\nFROM data d\r\nCROSS JOIN ids i\r\nWHERE $__timeFilter(d.time)\r\n AND d.point_id IN (i.oat_id, i.chw_id)\r\nGROUP BY 1\r\nORDER BY \"time\";\r\n", | |
| "refId": "B", | |
| "sql": { | |
| "columns": [ | |
| { | |
| "parameters": [], | |
| "type": "function" | |
| } | |
| ], | |
| "groupBy": [ | |
| { | |
| "property": { | |
| "type": "string" | |
| }, | |
| "type": "groupBy" | |
| } | |
| ], | |
| "limit": 50 | |
| } | |
| } | |
| ], | |
| "title": "$station Chilled Water Sensor Check", | |
| "type": "timeseries" | |
| } | |
| ], | |
| "preload": false, | |
| "refresh": "", | |
| "schemaVersion": 41, | |
| "tags": [], | |
| "templating": { | |
| "list": [ | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": "Diggs", | |
| "value": "Diggs" | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "select distinct site \nfrom vw_nfmeta_fox\nwhere station_name is not null;", | |
| "description": "", | |
| "label": "Site", | |
| "name": "site", | |
| "options": [], | |
| "query": "select distinct site \nfrom vw_nfmeta_fox\nwhere station_name is not null;", | |
| "refresh": 1, | |
| "regex": "", | |
| "sort": 1, | |
| "type": "query" | |
| }, | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": "DiggsES_Mech_VAVs", | |
| "value": "DiggsES_Mech_VAVs" | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "select distinct station_name \nfrom vw_nfmeta_fox\nwhere site ='$site'\nand station_name is not null;", | |
| "includeAll": false, | |
| "label": "Station", | |
| "name": "station", | |
| "options": [], | |
| "query": "select distinct station_name \nfrom vw_nfmeta_fox\nwhere site ='$site'\nand station_name is not null;", | |
| "refresh": 1, | |
| "regex": "", | |
| "sort": 1, | |
| "type": "query" | |
| }, | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": [ | |
| "/PointsForGraphic", | |
| "/PointsForGraphic/BoilerControl" | |
| ], | |
| "value": [ | |
| "/PointsForGraphic", | |
| "/PointsForGraphic/BoilerControl" | |
| ] | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "select distinct path\nfrom vw_nfmeta_fox\nwhere site = ${site:singlequote}\n and station_name IN (${station:singlequote})\n and path is not null\norder by 1;\n", | |
| "includeAll": false, | |
| "label": "Path", | |
| "multi": true, | |
| "name": "path", | |
| "options": [], | |
| "query": "select distinct path\nfrom vw_nfmeta_fox\nwhere site = ${site:singlequote}\n and station_name IN (${station:singlequote})\n and path is not null\norder by 1;\n", | |
| "refresh": 1, | |
| "regex": "", | |
| "sort": 1, | |
| "type": "query" | |
| }, | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": [ | |
| "AV_nviOaTemp" | |
| ], | |
| "value": [ | |
| "AV_nviOaTemp" | |
| ] | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "-- oat_point (single-select)\nselect distinct point_name\nfrom vw_nfmeta_fox\nwhere site = ${site:singlequote}\n and station_name in (${station:singlequote})\norder by 1;\n", | |
| "includeAll": false, | |
| "label": "Outside Air Temp", | |
| "multi": true, | |
| "name": "oat_point", | |
| "options": [], | |
| "query": "-- oat_point (single-select)\nselect distinct point_name\nfrom vw_nfmeta_fox\nwhere site = ${site:singlequote}\n and station_name in (${station:singlequote})\norder by 1;\n", | |
| "refresh": 1, | |
| "regex": "", | |
| "sort": 1, | |
| "type": "query" | |
| }, | |
| { | |
| "allowCustomValue": false, | |
| "current": { | |
| "text": [ | |
| "BldgCHWSupplyTemp" | |
| ], | |
| "value": [ | |
| "BldgCHWSupplyTemp" | |
| ] | |
| }, | |
| "datasource": { | |
| "type": "grafana-postgresql-datasource", | |
| "uid": "normal-timescaledb" | |
| }, | |
| "definition": "select distinct point_name\nfrom vw_nfmeta_fox\nwhere site = ${site:singlequote}\n and station_name IN (${station:singlequote})\n and path IN (${path:singlequote})\norder by 1;\n", | |
| "label": "Chilled Water Temp", | |
| "multi": true, | |
| "name": "chilled_water_temp_point", | |
| "options": [], | |
| "query": "select distinct point_name\nfrom vw_nfmeta_fox\nwhere site = ${site:singlequote}\n and station_name IN (${station:singlequote})\n and path IN (${path:singlequote})\norder by 1;\n", | |
| "refresh": 1, | |
| "regex": "", | |
| "type": "query" | |
| } | |
| ] | |
| }, | |
| "time": { | |
| "from": "now-180d", | |
| "to": "now" | |
| }, | |
| "timepicker": {}, | |
| "timezone": "browser", | |
| "title": "Diggs Chiller Hours", | |
| "uid": "5e172132-8ddc-4ff3-9d5d-8a4cd29a73d7", | |
| "version": 16 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment