chris
November 16, 2021, 9:21pm
2
Yea, those components are only meant to serialize honeybee objects and not ladybug ones. People keep asking for a way to serialize the Ladybug data collections, though. Here are some previous posts that will help you:
Hey Guys,
There are plenty of ways to write the results into a file, the most straightforward being to deconstruct the data collection and use any of the several Grasshopper plugins that write GH data to CSV or Excel. But those workflows will involve dumping the data into the Grasshopper UI and will be slow if you have 2981 * 8760 data points. If you want something fast, you should use the LBT Python SDK.
@RafaelA posted an example here where he uses a few lines of the Python SDK to serializ…
@RafaelA ,
Data Collections can be serialized to/from a dictionary or JSON but the honeybee serialization components are only meant for serializing honeybee objects. You can do the serailization to JSON with the following code:
import json
a = 'C:/ladybug/data_collection.json'
obj_dict = [data.to_dict() for data in x]
with open(a, 'w') as fp:
json.dump(obj_dict, fp)
And here’s how you can re-serialize it back:
from ladybug.datacollection import HourlyDiscontinuousCollection
import jso…
If we’re going to add something official for this, let me know if you prefer serializing to CSV over JSON.