Is there a folder where you can save custom program types to be loaded with the function:
from honeybee_energy.lib.programtypes import program_type_by_identifier
test_import = program_type_by_identifier("NECB 2017 SPACE: Museum restoration room")
Is there a folder where you can save custom program types to be loaded with the function:
from honeybee_energy.lib.programtypes import program_type_by_identifier
test_import = program_type_by_identifier("NECB 2017 SPACE: Museum restoration room")
Hi @marentette ,
Yes, there is a folder on your machine where you can save custom program types, which you can then apply to any model that you open on your machine (and you can load with that program_type_by_identifier()
function). However, I would usually not recommend editing the folder directly unless you know exactly what is supposed to go in the folder.
Instead, the most recent version of the Pollination Rhino plugin has a command where you can add program types that you have created within a given Pollination Rhino model to your user standards library. All that you have to do is open the Pollination Rhino model with the Program that you want to add and then select “Save to User Library” under the “Model Resources” menu:
You’ll then need to restart Rhino but, after that, the ProgramTypes from that model will always be accessible whenever you open Rhino or Grasshopper on your machine (including through that program_type_by_identifier
function).
Now, I realize that you’re already working in Python so you may already know exactly what the JSON schema of the program types is. So, if you don’t want to use the new Pollination Rhino command above, the folder where your custom user library of program types is stored is:
C:\Users\[USERNAME]\AppData\Roaming\ladybug_tools\standards\programtypes
But, again, I only recommend that people touch that folder unless they know what they’re doing because it’s very easy to corrupt things if you add something incorrect to that folder.
@chriswmackey Thanks Chris.
I have saved the custom program types in that folder and this works great for the Rhino interface. Since I am adding all of the NECB templates I don’t think the new Rhino command is useful in this situation.
I am trying to build an app to automate program type template assignment outside the Rhino environment. The program_type_by_identifier
function throws a ValueError when I try and load any of the NECB templates I can use inside the Rhino interface.
Hey @marentette ,
Understood. If the JSON specification of your "NECB 2017 SPACE: Museum restoration room"
is inside that folder and the "identifier"
of the Program Type is exactly what you have there (including correct capitalization), then you should be able to use the program_type_by_identifier()
function to get the object in any of the Python versions on your system (eg. GHPython or your system cPython).
If you’re confident that you’ve matched everything correctly with the identifier in the JSON file, then you can upload it and I’ll see if I can recreate it on my end.
Here is the json file:
necb 2017 program types.zip (14.2 KB)
Hey @marentette ,
So there were a number of things going on here. The first is that honeybee-energy was not set up to load the schedules that you needed from the honeybee-energy-standards package and was expecting all of the schedules to be in your user library. I pushed a fix for this here:
… and running the LB Versioner should get the fix in your local installation. You can also get the fix on your system python with a pip install lbt-dragonfly -U
.
The second issue is that practically none of these Programs in your JSON correctly follow the Honeybee-schema definition for ProgramTypes. You can see the documentation for this schema here:
https://www.ladybug.tools/honeybee-schema/model.html#tag/programtypeabridged_model
The programs in your file have nulls for several required values (like sensible and latent fractions) and they also have identifiers that are much longer than the 100 character limit for EnergyPlus-compatible IDs. So you’ll need to fix these things if you want to be able to load these programs with Python.
Here’s a simple test you can do to see if a given program is correct, where prog_dict
is the Python dictionary representation of a given Program:
from honeybee_energy.lib.programtypes import lib_dict_abridged_to_program_type
test_program = lib_dict_abridged_to_program_type(prog_dict, [])
print(test_program)
If your program is invalid, running that sample code will tell you exactly what is wrong with it.
Thanks @chriswmackey for taking a look!
I modeled the JSON file to match the schema found in the ASHRAE datasets in the folder: C:\Program Files\ladybug_tools\resources\standards\honeybee_energy_standards\programtypes
. It appears to be slightly different schema than the link you sent.
Comparing my JSON to 2007_data.json appear to match in schema. Can you be more specific when you say practically none match?
I understand the identifier needs to be shorten and the nulls are all at the same variable for “sensible_fraction” and “latent_fraction” under the service_hot_water object which I see you hard code the values into in your update script here:
honeybee-energy-standards/standards_update/extension/programtype.py at master · ladybug-tools/honeybee-energy-standards (github.com)
I updated my conversion script with those comments and all the nulls are resolved:
openstudio_necb_convert/program_types_to_hb.py at main · mcw-energy/openstudio_necb_convert (github.com)
Finally, after resolving those issues and updating honeybee using pip install lbt-dragonfly -U.
I still cannot access the programtypes from the appdata folder. Did it work on your end? I added sample JSON files to the repo linked above if you have time to test.
Hey @marentette ,
Did you try using the sample code that I posted , where prog_dict
is the Python dictionary representation of a given Program:
from honeybee_energy.lib.programtypes import lib_dict_abridged_to_program_type
test_program = lib_dict_abridged_to_program_type(prog_dict, [])
print(test_program)
If your program dictionaries are still not loading then running that sample on one of your ProgramType dictionaries will tell you what is wrong about it with a clear error message.
This is the error I get: Traceback (most recent call last):
File "script.py", line 132, in <module>
test_program = lib_dict_abridged_to_program_type(prog_dict, [])
File "C:\Users\\AppData\Local\Programs\Python\Python38\lib\site-packages\honeybee_energy\lib\programtypes.py", line 113, in lib_dict_abridged_to_program_type
add_schedule(schedules, program_dict, 'people', 'occupancy_schedule')
File "C:\Users\\AppData\Local\Programs\Python\Python38\lib\site-packages\honeybee_energy\lib\programtypes.py", line 109, in add_schedule
scheds[sch_id] = _s.schedule_by_identifier(sch_id)
TypeError: list indices must be integers or slices, not str
I also get this same error using one of the program types from the standards library. Am I using this function wrong?
prog_dict = {
"type": "ProgramTypeAbridged",
"identifier": "NECB 2017 BLDG: Automotive facility",
"people": {
"type": "PeopleAbridged",
"identifier": "NECB_2017_Automotive facility_People",
"people_per_area": 0.0500185873605948,
"radiant_fraction": 0.3,
"latent_fraction": {"type": "Autocalculate"},
"occupancy_schedule": "NECB-E-Occupancy",
"activity_schedule": "NECB-Activity"
},
"lighting": {
"type": "LightingAbridged",
"identifier": "NECB_2017_Automotive facility_Lighting",
"watts_per_area": 7.599997548,
"return_air_fraction": 0.0,
"radiant_fraction": 0.5,
"visible_fraction": 0.2,
"schedule": "NECB-E-Lighting",
"baseline_watts_per_area": 7.599997548
},
"electric_equipment": {
"type": "ElectricEquipmentAbridged",
"identifier": "NECB_2017_Automotive facility_Electric",
"watts_per_area": 5.0018587360594795,
"radiant_fraction": 0.5,
"latent_fraction": 0.0,
"lost_fraction": 0.0,
"schedule": "NECB-E-Electric-Equipment"
},
"service_hot_water": {
"type": "ServiceHotWaterAbridged",
"identifier": "NECB_2017_Automotive facility_SHW",
"flow_per_area": 0.0860419279608,
"target_temperature": 60.0,
"sensible_fraction": 0.2,
"latent_fraction": 0.05,
"schedule": "NECB-E-Service Water Heating"
},
"infiltration": {
"type": "InfiltrationAbridged",
"identifier": "NECB_2017_Automotive facility_Infiltration",
"flow_per_exterior_area": 0.000250063,
"schedule": "Always On"
},
"ventilation": {
"type": "VentilationAbridged",
"identifier": "NECB_2017_Automotive facility_Ventilation",
"flow_per_person": 0.0,
"flow_per_area": 0.00762
},
"setpoint": {
"type": "SetpointAbridged",
"identifier": "NECB_2017_Automotive facility_Setpoint",
"heating_schedule": "NECB-E-Thermostat Setpoint-Heating",
"cooling_schedule": "NECB-E-Thermostat Setpoint-Cooling"
}
}
test_program = lib_dict_abridged_to_program_type(prog_dict, [])
Ah, thanks, @marentette . There was a typo in my sample code. You should have been passing an empty dictionary instead of an empty list. Here is the correct sample code:
from honeybee_energy.lib.programtypes import lib_dict_abridged_to_program_type
test_program = lib_dict_abridged_to_program_type(prog_dict, {})
print(test_program)
When I run your particular program through the sample, I can see that it’s valid:
… so this ProgramType should be coming through when you drop it into your standards folder and you were right to bring this to my attention. There was a bug in the previous change that I made to ensure that your ProgramTypes can reference schedule in honeybee-energy-standards. I have just pushed a fix for this:
You should be able to get the fix on your end with the LB Versioner in an hour or so after it makes it through our continuous integration. After that, I see that I can successfully load this program into Grasshopper with the program_type_by_identifier()
function:
… and it shows up in the list of Programs that you can assign to Rooms in the Pollination Rhino UI:
Here’s a sample JSON of your program if you want to try dropping it into your standards folder after running the LB Versioner:
necb_program.json (2.4 KB)