Skip to content

Conversation

@samland1116
Copy link
Contributor

  • Adds ForecastLeadTimeBins() class to existing rcf's
    • allows for static or dynamic binning
    • offers examples of the various methods you can define dynamic bin dictionary in docstring
  • Corrects various formatting issues (as encountered) and removes unused dependencies (as encountered)

Also could include:

  • example in docs -- not sure how this translates over to Sam Lamont's docs update for v0.6?

@samland1116 samland1116 added this to the v0.6 Release milestone Dec 5, 2025
@samland1116 samland1116 self-assigned this Dec 5, 2025
@samland1116 samland1116 added enhancement New feature or request v0.6-dev Denotes that the issue is meant to be merged into the v0.6-beta development branch. main This is an issue that is considered v0.5.0 maintenance and should be merged into main priority: High This is blocking work, let's get it done as soon as possible. labels Dec 5, 2025
@samland1116 samland1116 linked an issue Dec 5, 2025 that may be closed by this pull request
Copy link
Collaborator

@samlamont samlamont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting the error: TypeError: ForecastLeadTimeBins._validate_bin_size_dict() takes 2 positional arguments but 3 were given when running rcf.ForecastLeadTimeBins() in the test_add_row_udfs test

@samland1116
Copy link
Contributor Author

I'm getting the error: TypeError: ForecastLeadTimeBins._validate_bin_size_dict() takes 2 positional arguments but 3 were given when running rcf.ForecastLeadTimeBins() in the test_add_row_udfs test

resolved this by adding in the @staticmethod decorator -- merged in the newly updated main to consider other recently merged PR as well

@samland1116 samland1116 requested a review from samlamont December 8, 2025 20:15
pd.Timedelta(days=2): pd.Timedelta(hours=12),
pd.Timedelta(days=3): pd.Timedelta(days=1)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it might be a bit more clear to define the keys as just an integer (or maybe even string?) then the bin could be some time value (could also be a string?), for example:

bin_size = {
    "1": "6 hours",
    "2": "12 hours",
    "3": "1 day"
}

where bin 1 would be 0-6, 2 would be 6-18, etc. And the values (whether strings or datetime objects) could be converted to datetime objects is not already. Then the resulting field would just be the simple key value 1,2, or 3 rather than the time interval string, which could be hard to filter on if there's a long record of forecasts in the table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to consider inputs of format:

output:
     {
         "PT0H_PT6H",
         "PT6H_PT12H",
         "PT12H_PT1D",
         "PT1D_PT2D",
     }
     
     input:
     1. constant bin size, timedelta:
         pd.Timedelta(days=5)
         
     2. variable bin size, dict:
         [
             {start_inclusive: pd.Timedelta(hours=0), end_exclusive: pd.Timedelta(hours=6)},
             {start_inclusive: pd.Timedelta(hours=12), end_exclusive: pd.Timedelta(hours=18)}
         ]
         
     3. variable bin size, dict with string/datetime keys:
         {
             "bin1": {start_inclusive: pd.Timedelta(hours=0), end_exclusive: pd.Timedelta(hours=6)}
         }
         
         - allow string, datetime timedelta as well

@samland1116 samland1116 requested a review from samlamont December 9, 2025 20:52
Copy link
Collaborator

@samlamont samlamont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your efforts on this!

@samlamont samlamont merged commit 1d3647f into main Dec 11, 2025
@samlamont samlamont deleted the 598-add-calculated-field-method-to-bin-by-forecast-leadtime branch December 11, 2025 00:57
samlamont added a commit that referenced this pull request Dec 11, 2025
* adds rcf ForecastLeadTimeBins, corrects misc. formatting

* update docs and API formatting w.r.t ForecastLeadTimeBins

* adds staticmethod decorators to class methods

* refactors ForecastLeadTimeBins

* adds new tests for ForecastLeadTimeBins

* update tests

* adds additional input type support, support for mixed input types

---------

Co-authored-by: samlamont <sam.lamont@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request main This is an issue that is considered v0.5.0 maintenance and should be merged into main priority: High This is blocking work, let's get it done as soon as possible. v0.6-dev Denotes that the issue is meant to be merged into the v0.6-beta development branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add calculated field method to bin by forecast leadtime

3 participants