A library for working with the Brick ontology for buildings (brickschema.org)
Project description
Brick Ontology Python package
Documentation available at readthedocs
Installation
The brickschema
package requires Python >= 3.6. It can be installed with pip
:
pip install brickschema
Haystack Inference
Requires a JSON export of a Haystack model
First, export your Haystack model as JSON; we are using the public reference model carytown.json
.
Then you can use this package as follows:
import json
from brickschema.inference import HaystackInferenceSession
haysess = HaystackInferenceSession("http://project-haystack.org/carytown#")
model = json.load(open('carytown.json'))
model = haysess.infer_model(model)
print(len(model))
points = model.query("""SELECT ?point ?type WHERE {
?point rdf:type/rdfs:subClassOf* brick:Point .
?point rdf:type ?type
}""")
print(points)
SQL ORM
from brickschema.graph import Graph
from brickschema.namespaces import BRICK
from brickschema.orm import SQLORM, Location, Equipment, Point
# loads in default Brick ontology
g = Graph(load_brick=True)
# load in our model
g.load_file("test.ttl")
# put the ORM in a SQLite database file called "brick_test.db"
orm = SQLORM(g, connection_string="sqlite:///brick_test.db")
# get the points for each equipment
for equip in orm.session.query(Equipment):
print(f"Equpiment {equip.name} is a {equip.type} with {len(equip.points)} points")
for point in equip.points:
print(f" Point {point.name} has type {point.type}")
# filter for a given name or type
hvac_zones = orm.session.query(Location)\
.filter(Location.type==BRICK.HVAC_Zone)\
.all()
print(f"Model has {len(hvac_zones)} HVAC Zones")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
brickschema-0.1.0.tar.gz
(72.6 kB
view hashes)
Built Distribution
Close
Hashes for brickschema-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e09c3c1ba8f2a63e39607c1cef8478f086c1787e1721e110d91195bf89a1ffe |
|
MD5 | 629f6ef8e44be23c0e1a059930c84176 |
|
BLAKE2b-256 | 4a78c3c8bd7683a78cca5a567b7edd74a8fab7122aeb55bf22bb6a7643e4885a |