Skip to content

Commit

Permalink
BRICK model example looking good. ready for social media writeup to l…
Browse files Browse the repository at this point in the history
…oop through data via BRICK model and apply FD
  • Loading branch information
bbartling committed Aug 30, 2024
1 parent 95ff6f5 commit 35e089e
Show file tree
Hide file tree
Showing 9 changed files with 1,107 additions and 369 deletions.
14 changes: 8 additions & 6 deletions examples/brick_model_and_sqlite/1_make_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
id INTEGER PRIMARY KEY AUTOINCREMENT,
sensor_name TEXT NOT NULL,
timestamp TEXT NOT NULL,
value REAL NOT NULL,
fc1_flag INTEGER DEFAULT 0 -- Add this line to store fault condition 1 flags
value REAL NOT NULL
)
"""
)
Expand Down Expand Up @@ -65,6 +64,9 @@
)
df.columns = df.columns.str.replace(pattern, "", regex=True)

# Trim any leading or trailing spaces from the column names
df.columns = df.columns.str.strip()

# Print columns after modification to verify changes
print("Modified df.columns", df.columns)

Expand All @@ -80,14 +82,14 @@
VALUES (?, ?, ?)
""",
(
column,
column.strip(), # Trim the sensor_name
row["timestamp"].strftime("%Y-%m-%d %H:%M:%S"),
row[column],
),
)
if index < 5: # Print the first 5 rows only
print(
f"Inserted sensor name {column} with value {row[column]} at {row['timestamp']}"
f"Inserted sensor name {column.strip()} with value {row[column]} at {row['timestamp']}"
)
print(f"Processed {column} in step 5")
else:
Expand All @@ -107,9 +109,9 @@
INSERT INTO TimeseriesReference (timeseries_id, stored_at)
VALUES (?, ?)
""",
(column, "SQLite Timeseries Storage"),
(column.strip(), "SQLite Timeseries Storage"),
)
print(f"Inserted reference for {column} in step 6")
print(f"Inserted reference for {column.strip()} in step 6")
else:
pass

Expand Down
5 changes: 1 addition & 4 deletions examples/brick_model_and_sqlite/2_make_rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
ahu_uris = {} # To track and associate sensors with AHUs

# List of specific identifiers related to AHU points
ahu_related_identifiers = ["SaStaticSPt", "SaStatic", "SaFanSpeedAO"]
ahu_related_identifiers = ["StaticSPt", "SaStatic", "SaFanSpeedAO"]

for timeseries_id, stored_at in timeseries_refs:
timeseries_id = timeseries_id.strip() # Remove any leading/trailing spaces
Expand All @@ -65,15 +65,12 @@
if "StaticSPt" in timeseries_id:
g.add((sensor_uri, RDF.type, brick.Supply_Air_Static_Pressure_Setpoint))
g.add((sensor_uri, brick.hasUnit, unit.Inch_Water_Column))
print("StaticSPt added: ", sensor_uri)
elif "SaStatic" in timeseries_id:
g.add((sensor_uri, RDF.type, brick.Supply_Air_Static_Pressure_Sensor))
g.add((sensor_uri, brick.hasUnit, unit.Inch_Water_Column))
print("SaStatic added: ", sensor_uri)
elif "SaFanSpeedAO" in timeseries_id:
g.add((sensor_uri, RDF.type, brick.Supply_Fan_VFD_Speed_Sensor))
g.add((sensor_uri, brick.hasUnit, unit.Percent))
print("SaFanSpeedAO added: ", sensor_uri)

# Associate the sensor with the AHU
g.add((ahu_uris[ahu_name], brick.hasPoint, sensor_uri))
Expand Down
Loading

0 comments on commit 35e089e

Please sign in to comment.