# Search by name patternmatches=variables.search("Zone Mean Air Temperature")# Search with regexmatches=variables.search(r"Zone.*Temperature")# Case-insensitivematches=variables.search("temperature")# Finds all temperature vars
# All output variablesforvarinvariables.variables:print(f"Variable: {var.name} [{var.units}]")# All metersformeterinvariables.meters:print(f"Meter: {meter.name} [{meter.units}]")
# Search first, review, then add selectivelymatches=variables.search("Heating")# Filter to specific onesselected=[vforvinmatchesif"Coil"inv.name]# Add to model (name is optional for Output:Variable)forvarinselected:model.add("Output:Variable",key_value="*",variable_name=var.name,reporting_frequency="Timestep",)
A common pattern is to run a "discovery" simulation to find available
outputs, then run a second simulation with those outputs requested:
fromidfkit.simulationimportsimulate# Step 1: Discovery runresult=simulate(model,weather,design_day=True)# Step 2: Find interesting outputsmatches=result.variables.search("Zone Mean Air Temperature")print(f"Found {len(matches)} matching variables")# Step 3: Add outputs to modelresult.variables.add_all_to_model(model,filter_pattern="Zone Mean Air Temperature",reporting_frequency="Hourly",)# Step 4: Full run with outputsresult=simulate(model,weather,annual=True)# Step 5: Query the dataforzonein["ZONE 1","ZONE 2"]:ts=result.sql.get_timeseries("Zone Mean Air Temperature",zone,)print(f"{zone}: avg {sum(ts.values)/len(ts.values):.1f}°C")