Construct Discontinuous Data Collection


First off, the new release is great! However, I have found an issue. I’m not sure if i’m missing something so thought I would post the problem and my solution.

First Issue
The issue is with the LB Construct Data component. I’m trying to construct a discontinuous data collection, however the component appears to only allow for a continuous data collection. To recreate, i’m using Direct Sun Hours with an Analysis Period between 8am to 2pm full year. The following is the error i get when creating the data collection with LB Construct Data;

1. Solution exception:analysis_period start hour of HourlyContinuousCollection must be 0. Got 8

I notice when I open the component (thanks open source) that the component only attempts to create a continuous data collection;

if all_required_inputs(ghenv.Component):
    data = HourlyContinuousCollection(_header, _values)

So, through using the API and python imports (thanks again) I managed to create a discontinuous data collection that works;

from ladybug.datacollection import HourlyDiscontinuousCollection
data = HourlyDiscontinuousCollection(header, values, datetimes)

Hopefully that makes sense.


Hi @jordanmathers ,

I was wondering when someone would get to this level of skill with the Ladybug Tools SDK but less than 2 weeks after the release is a lot sooner than I expected. You are exactly right that we didn’t expose the ability to create discontinuous collections with the current Ladybug Grasshopper components but everything exists in the ladybug-core SDK to do so and your code is the correct way to make it. For anyone else interested in understanding @jordanmathers 's code, here are the docs for the HourlyDiscontinuousCollection class that is being initialized in the code sample:


This is the one and only thing I have done with the SDK so far, but I have noticed a couple of other things that I will post about when I explore the solutions more.

1 Like

Hi @jordanmathers,

did you manage to implement this in gh?

I’m trying to use the code you shared but I’m getting a strange error related to the header.


I managed to solve this issue thanks to @OlivierDambron.

Using the native python component and giving List Access for datetimes and values made it work. :slight_smile:


1 Like

Hi. Sorry I didn’t see this before. Glad you figured it out. I still get the wrong input settings when using ghpython after a couple of years of doing this.

Edit. Also in regards to your code. You don’t need to write If something == True. If that something is already a boolean then you just need If something. But it’s good practice to understand both as your way is easier to understand.

ahh, thanks for the tip - helps to understand some other parts of the code in general

FYI @RafaelA ,

You can also create your own DateTime objects by importing the ladybug.dt module. So you can crate the datetimes form the HOYs inside your custom GHPython script.

And thanks, @jordanmathers, for being a part of the PEP8 Police force!

1 Like

Hi All,

I have followed this thread closely as it seems to be the source of an issue I have been having with creating a 3D chart for a discontinuous data collection combining header and values. I get a “1. Solution exception:analysis_period start hour of HourlyContinuousCollection must be 0. Got 10” error when using the LB Construct Data component. (42.8 KB)

I’ve copied the GHPython text that @RafaelA shared along with the list access override for datetimes noted, but receive the same output error below:

  1. Solution exception:values should be a list or tuple. Got <type ‘str’>

Attached is a copy of the script for clarity. Can anyone help?

Hey, you also need to set values to list access. Checking your script you will also need to provide the same amount of values as datetimes. You’re passing values manually so I can’t help you there.

@jordanmathers thanks for the reply. I’ve made the amendments suggested, and rationalised the no. of values/datetimes to match, but the output still records as null.

Updated script attached for reference - any other suggestions? (53.2 KB)

Thanks in advance

Hi @jwoodall ,

You just need to change one of the component outputs to data so that you can actually get the data collection object out of the component: (46.4 KB)

Thanks @chris, such a simple fix! Although when I plug this data output into an hourly plot I receive another issue (pasted below). Can you clarify why this might be happening?

  1. Solution exception:Expected number for min. Got <type ‘str’>.

The values that were plugging into the custom GHPython component were text strings and not numbers. Just right-click on the values input and change the Type hint to float and it all works: (51.5 KB)