Sunpath for leap years

Is there a way, using or modifying the Sunpath component, to get sun direction vectors for leap years and other years? What I would like to do is show that the vector for noon on Feb 28, 2027 is slightly different from the same day in 2026 or 2028.

1 Like

Hi @Nathaniel, It is possible to get them for the leap_year but it is not exposed in the UI. You have to change the components in two places:

  1. In the LB Calculate HOY component change line 43 to calculate pass leap_year=True to create the DateTime for the leap year.
  2. In the LB SunPath component, set is_leap_year to True after creating the sunpath. Line 245 in the above screenshot.

Here is the edited GH file.

Changing the year is a bit more work since it is hard-coded in the source code. We use 2016 for leap_year and 2017 for a typical year.

You can manually edit the source code in the C:\Program Files\ladybug_tools\python\Lib\site-packages\ladybug\dt.py to change the years to the two that you are interested in comparing. Don’t forget to Restart Rhino to reload the libraries after editing them.

1 Like

@mostapha’s solution worked. There are multiple places in dt.py (and sunpath.py) where the year is hard coded, so I created global variables for the leapyear year and the non-leapyear year. I also implemented a check in Grasshopper that throws an error if the year I’m processing doesn’t match one of those global variables. I was then able to produce analemmas for four consecutive years showing the differences in solar angles, only needing to restart Rhino twice to reset the global variables.

2 Likes

Thank you for the update, @Nathaniel! And glad that you figured it out. Maybe we should consider exposing this as a variable at some point to make it easier for cases like yours.

1 Like