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.
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:
- In the
LB Calculate HOY
component change line 43 to calculate passleap_year=True
to create theDateTime
for the leap year. - In the
LB SunPath
component, setis_leap_year
toTrue
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.
@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.
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.