Development: Leap Year button for analysis period

Hi @chris

I hope you’re doing well.

I was wondering if it’s possible to have is_leap_year as an input for the LB Analysis Period in the component, with the option to toggle it on or off via a button.

Thank you very much for your time and assistance.

Sincerely,
Behnam

1 Like

Hey @behnammmohseni ,

This is a reasonable request since it is important for working with AMY EPW files for leap years and it’s also really straightforward to implement given that the AnalysisPeriod object in the SDK already has a fully-functioning is_leap_year property on it.

When you see features like this that are fully supported in the SDK but not exposed on an official component, it’s because we thought that exposing it might make the components more complex and therefore make it harder for new users to understand and get started with the components. For advanced users like yourself, you can always just open up a GHPython component and edit the AnalysisPeriod object to be for a leap year if you needed to.

Granted, I understand it can get annoying if you find yourself constantly having to make GHPython components. If this is what is going on, then I concede that adding one more input to the component isn’t really going to overwhelm and new user. So we can add it.

But I’m just trying to explain why every feature of the Ladybug Tools SDK isn’t exposed on a Grasshopper component since that would be pretty overwhelming for new users.

2 Likes

Since I have not heard from anyone yet about the leap year being a consistent pain point, I’m thinking to address this topic by just posting an example GHPython component that takes an analysis period as input and spits out one that is a leap year. Rather than making a change to the official component.

I’ll try to do this tomorrow unless I hear otherwise that it would be really appreciated to make the official change.

2 Likes

Here is a sample file with a little GHPython component in it, which converts an input AnalysisPeriod over to being a leap year:


convert_analysis_period_to_leap_year.gh (21.2 KB)

… and here is a sample leap year EPW if anyone wants to test it:

Sample_Leap_Year.zip (486.4 KB)

This is the code inside the GHPython component if anyone is just looking to copy/paste it:

from ladybug.analysisperiod import AnalysisPeriod
from ladybug_rhino.grasshopper import all_required_inputs

if all_required_inputs(ghenv.Component):
    period = AnalysisPeriod(
        _period.st_month, _period.st_day, _period.st_hour,
        _period.end_month, _period.end_day, _period.end_hour,
        _period.timestep, is_leap_year=True
    )
5 Likes