Saber: Building Audit Tool

The building energy audit tool used by students in CU Boulder’s Civil, Environmental and Architectural Engineering (CEAE) department, roughly 900 undergraduate and graduate students. It calibrates an energy model from a year of utility bills and shows which retrofits pay for themselves.

5 min readTry it live

Saber landing page: “Your utility bills know when your heating kicks in.” with Open the tool and Watch the intro buttons above a preview of the change-point model results

A building’s utility bills already know when its heating kicks in. Saber reads them, builds a calibrated energy model, and prices out every upgrade worth doing.

What I shipped

Saber is a building energy audit platform for the BEST Center, built out of Larson Lab at CU Boulder. An auditor describes a building, uploads twelve months of electricity and gas bills, and gets back a calibrated baseline plus savings, cost, payback and net present value for every energy conservation measure (ECM) they want to test.

Before this, the whole thing was a PyQt5 desktop app. It worked, but you needed the right conda environment, the right Python version and someone from the lab sitting next to you. Nobody outside the lab was ever going to use it. I rebuilt it as a web product that anyone can open in a browser.

Describe the building, upload a year of bills, and Saber fits a change-point model, then checks it against the meter.
~4 mofirst commit to live on Azure
$25–30running cost per month
~4,100lines of modeling code reused
120+retrofit measure options

The ~4,100 lines of Python analysis engine were reused, not rewritten, and now sit behind a REST API. The 120+ measure options span insulation, windows, infiltration, HVAC, DHW, lighting and controls. It’s been tested against 15 real buildings, mostly churches and parsonages across Colorado and Montana. Try it live .

How it works

Two services, one shared Linux plan. A Next.js and TypeScript front end talks to a FastAPI back end that wraps the original modeling engine. Both run as containers on Azure App Service.

Swipe to see the whole diagram →

Saber architecture: users reach the Next.js front end over HTTPS, which calls the FastAPI back end over REST on Azure App Service; GitHub pushes trigger a Docker build into Azure Container Registry
Two containers on one Azure App Service plan, built from GitHub through Docker and Azure Container Registry.

The core idea is inverse modeling. Instead of simulating a building from first principles (which needs hundreds of inputs nobody has), Saber works backwards from what the meter actually recorded.

  1. Describe the building. A seven-step wizard covers geometry, envelope, equipment, HVAC, preferences, analysis and ECMs. Or drop in an existing .pkl building file and the fields fill themselves in.
  2. Find the weather. The building’s coordinates go through a haversine great-circle search to pick the nearest NOAA station, then daily temperatures get pulled and aligned to each billing period.
  3. Fit the baseline. Monthly energy use is regressed against outdoor temperature with piecewise-linear change-point models: 3P heating, 3P cooling, 4P and 5P. The search sweeps candidate balance points and keeps the fit with the best R². The balance point is literally the temperature where the heating turns on.
  4. Split it into end uses. Degree-day heat balance and a building load coefficient break the total into heating, cooling, lighting, equipment and hot water.
  5. Test retrofits. Each measure changes conduction, infiltration or system efficiency, and the calibrated model reruns to estimate the new consumption.
  6. Price it. Present value and life-cycle cost with a user-set discount rate (default 3%) and lifetime (default 20 years) give payback and NPV per measure and per package.

Swipe to see the whole diagram →

Saber back-end pipeline: FastAPI, input validation and async workers; then weather, change-point and degree-day models; then measures, re-simulation and life-cycle cost
The back end, from utility bills to retrofit savings: API layer, baseline energy model, then retrofit analysis.

Desktop to web: what had to change

Porting a scientific desktop app is not a UI reskin. The engine assumed one user, one machine and a local filesystem. Here is what broke and how I handled it.

Problem in the desktop versionWhat Saber does now
Ran only on a lab machine with a fragile conda setupDockerized scientific Python stack, open in any browser
PyQt5 forms with no validationTyped form state (types/form.ts) driven by a reducer with one-way data flow
Every ECM run refit the baseline from scratchBaseline fit is cached per project, so ECM runs only pay for the new work
Analysis blocked the whole appCPU-heavy fits run in a bounded two-worker thread pool, so the API stays responsive
Server restart meant losing stateCache rebuilds itself from the submitted form data on the next ECM request
Weather downloads changed the working directoryLocked and isolated so concurrent users do not step on each other
Opened any .pkl file with plain pickle.load()Restricted unpickler that only rebuilds pandas and numpy data
Long dropdowns, desktop-only layoutSearchable selects and a mobile layout
Saber wizard on the retrofit step: all seven earlier steps checked off, with financial parameters for cost per therm, cost per kWh, discount rate and measure lifetime
The last step of the wizard: financial parameters feed the payback and NPV for every measure.

The part I am proudest of: safe uploads

Auditors share buildings as pickled pandas DataFrames. That is convenient and also a remote code execution hole. A normal pickle.load() will call any function the file names, so one crafted upload could run shell commands on the server.

I wrote a restricted unpickler that allows only the types a DataFrame actually needs: pandas and numpy classes, their own reconstruction helpers, and a short list of harmless builtins like datetime and Decimal. Anything that touches files, evaluates expressions or plots (pandas.io, pandas.core.computation, numpy.lib, and friends) is blocked before it loads. Dotted names are rejected too, so nobody can reach a method like DataFrame.to_csv through the back door.

Existing building files keep working. Malicious ones never execute.

Shipping it

  • Hosting. Both services on Azure App Service (Web App for Containers) sharing one Linux plan, images in Azure Container Registry.
  • Right-sizing. Started on the B3 tier. Measured about 360 MB of combined average memory over seven days, then dropped to B2. Same performance, lower bill.
  • Health checks that mean something. /health imports the analysis engine, confirms the reference data is on disk and that upload storage is writable with 200 MB free. Any failure returns a 503 so monitors actually alert. The footer shows a live status light that polls it every 60 seconds.
  • Security. HTTPS only, TLS 1.2, HSTS, CORS locked to the Saber front end, 20 MB upload cap, path traversal protection on project names, and server errors that log details but never leak a stack trace to the browser.
  • Feedback loop. Most of the 76 commits came straight out of review rounds with the faculty and lab team. Ship, get comments, fix ECM edge cases, ship again.

Results

What a run gives back for a typical building:

OutputWhat you get
Baseline modelBest-fit change-point type (3P, 4P or 5P), balance point, R²
Calibration checkModeled vs metered use, month by month, for electricity and gas
End-use breakdownHeating, cooling, lighting, equipment and hot water
Per-measure economicsAnnual savings, installed cost, simple payback, NPV
PackagesCombined measures, rerun through the model so savings do not double count
ExportPDF report and a .pkl file you can load back later

The real win is not any one chart. It is that an energy audit which used to mean installing software on a lab computer is now a link you can send to a facilities manager. Open Saber .

Resources

  1. Kissock, Haberl and Claridge, Inverse Modeling Toolkit: Numerical Algorithms | ASHRAE Transactions, 2003
  2. ASHRAE Guideline 14, Measurement of Energy, Demand, and Water Savings
  3. Krarti, Energy Audit of Building Systems: An Engineering Approach | CRC Press
  4. NOAA NCEI, Integrated Surface Database
  5. FastAPI
  6. Azure App Service documentation | Microsoft Learn
  7. Python docs, pickle: restricting globals
  8. Saber, live