Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin_lightcycle will fail when using it with a zt #12

Closed
matiasandina opened this issue Aug 5, 2023 · 1 comment
Closed

bin_lightcycle will fail when using it with a zt #12

matiasandina opened this issue Aug 5, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@matiasandina
Copy link
Owner

matiasandina commented Aug 5, 2023

The lights_on_hour is given in local time instead of being given in zt time.
This will produce erroneous binning. I think that it's easy to catch that bin_pellets_lightcycle is being called with zt and modify lights_on_hour to 0 and lights_off_hour to 12. This function will mostly be used with zt anyway since we want the light/dark info instead of the date, so it's better this way. We can also add a zt_date to this result to make clear that we are talking about zt datetime instead of date.

> df %>% recalculate_pellets() %>% add_zt(Pi_Time, lights_on_hour=7) %>% bin_pellets_lightcycle(Pi_Time, lights_on_hour=7)
# A tibble: 6 × 3
# Groups:   date, light_cycle [6]
  date       light_cycle pellets
  <date>     <chr>         <int>
1 2023-08-03 dark             89
2 2023-08-03 light            23
3 2023-08-04 dark            168
4 2023-08-04 light            45
5 2023-08-05 dark             87
6 2023-08-05 light            14
> df %>% recalculate_pellets() %>% add_zt(Pi_Time, lights_on_hour=7) %>% bin_pellets_lightcycle(zt, lights_on_hour=7)
# A tibble: 5 × 3
# Groups:   date, light_cycle [5]
  date       light_cycle pellets
  <date>     <chr>         <int>
1 2023-08-03 dark             53
2 2023-08-03 light           138
3 2023-08-04 dark             71
4 2023-08-04 light           150
5 2023-08-05 dark             14
@matiasandina matiasandina added the bug Something isn't working label Aug 5, 2023
@matiasandina
Copy link
Owner Author

This could potentially solve the issue

df %>% 
  recalculate_pellets() %>% 
  add_zt(Pi_Time, lights_on_hour = 7) %>%
  bin_pellets_lightcycle(zt, lights_on_hour = 0, lights_off_hour = 12)

But I think the user should not need to know this, it's better to intercept the use of zt and adjust. When using zt, we should also have a zt_date and a date, since it can be really confusing for the user. Unfortunately, we would need to add an extra parameter to the function to keep the original date...Will evaluate in the future if it makes sense at all.

matiasandina added a commit that referenced this issue Aug 7, 2023
matiasandina added a commit that referenced this issue Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant