Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

Modifying OSM files in python

asked 2023-09-29 15:54:03 -0500

Ali-Khosravani's avatar

updated 2023-09-29 16:06:00 -0500

I am trying to write a python script to read an OSM file and modify its thermostat setpoints schedules during some peak perids. does anyone know how can I modify thermostat schedules in OpenStudio (OSM) file using python?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2023-10-02 14:44:09 -0500

updated 2023-10-02 14:44:41 -0500

pip install openstudio. Make sure you use python 3.7 to 3.10, see the OpenStudio SDK Python Binding Version Compatibility Matrix

Then it's a matter of using the SDK to modify the schedule. Depends which schedule type is used (eg: ScheduleRuleset).

A short example:

In [1]: import openstudio

In [2]: openstudio.openStudioLongVersion()
Out[2]: '3.6.1+bb9481519e'

In [3]: m = openstudio.model.exampleModel()

In [4]: sch_ruleset = m.getScheduleRulesets()[0]
   ...: print(sch_ruleset)
OS:Schedule:Ruleset,
  {759b60e6-ce95-4ff3-8400-2162e0d007be}, !- Handle
  Medium Office Cooling Setpoint Schedule, !- Name
  {1f748523-f5e7-4388-8c2d-3aed545795c2}, !- Schedule Type Limits Name
  {91357986-488a-469e-8dca-cd87a7647e4b}, !- Default Day Schedule Name
  {d651ceae-2f44-465b-9617-554befb57e9b}; !- Summer Design Day Schedule Name

In [5]: sch_day = sch_ruleset.defaultDaySchedule()
   ...: print(sch_day)
OS:Schedule:Day,
  {91357986-488a-469e-8dca-cd87a7647e4b}, !- Handle
  Medium Office Cooling Setpoint All Other Days Schedule, !- Name
  {1f748523-f5e7-4388-8c2d-3aed545795c2}, !- Schedule Type Limits Name
  ,                                       !- Interpolate to Timestep
  24,                                     !- Hour 1
  0,                                      !- Minute 1
  26.7;                                   !- Value Until Time 1

In [6]: sch_day.clearExtensibleGroups()
   ...: sch_day.addValue(openstudio.Time(0, 12, 0), 18)
   ...: sch_day.addValue(openstudio.Time(0, 16, 0), 20)
   ...: sch_day.addValue(openstudio.Time(0, 24, 0), 18)

In [7]: print(sch_day)
OS:Schedule:Day,
  {91357986-488a-469e-8dca-cd87a7647e4b}, !- Handle
  Medium Office Cooling Setpoint All Other Days Schedule, !- Name
  {1f748523-f5e7-4388-8c2d-3aed545795c2}, !- Schedule Type Limits Name
  ,                                       !- Interpolate to Timestep
  12,                                     !- Hour 1
  0,                                      !- Minute 1
  18,                                     !- Value Until Time 1
  16,                                     !- Hour 2
  0,                                      !- Minute 2
  20,                                     !- Value Until Time 2
  24,                                     !- Hour 3
  0,                                      !- Minute 3
  18;                                     !- Value Until Time 3
edit flag offensive delete link more
0

answered 2023-10-01 15:54:09 -0500

altamar's avatar

A long time ago i was trying to develop a OSM handler, may be you can try it and modify it to your goals https://github.com/AltamarMx/osm_handler

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2023-09-29 15:54:03 -0500

Seen: 118 times

Last updated: Oct 02 '23