-
-
Notifications
You must be signed in to change notification settings - Fork 21
update docs forecast #111
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
Open
lambaaryan011
wants to merge
1
commit into
openclimatefix:main
Choose a base branch
from
lambaaryan011:update-docs-forecast
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
update docs forecast #111
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
import datetime as dt | ||
|
||
from datetime import datetime, time, timedelta | ||
from zoneinfo import ZoneInfo | ||
|
||
def get_window() -> tuple[dt.datetime, dt.datetime]: | ||
"""Returns the start and end of the window for timeseries data.""" | ||
# Window start is the beginning of the day two days ago | ||
"""Returns the start and end of the window for timeseries data. | ||
|
||
Window start is the beginning of the day two days ago. | ||
Window end is the beginning of the day two days ahead. | ||
""" | ||
# Using UTC for current window calculation | ||
start = (dt.datetime.now(tz=dt.UTC) - dt.timedelta(days=2)).replace( | ||
hour=0, | ||
minute=0, | ||
second=0, | ||
microsecond=0, | ||
) | ||
# Window end is the beginning of the day two days ahead | ||
end = (dt.datetime.now(tz=dt.UTC) + dt.timedelta(days=2)).replace( | ||
hour=0, | ||
minute=0, | ||
second=0, | ||
microsecond=0, | ||
) | ||
return (start, end) | ||
return (start, end) | ||
|
||
def is_submission_valid(forecast_target: datetime, submission_time: datetime) -> bool: | ||
""" | ||
Validates whether a forecast submission is made on time. | ||
|
||
For a forecast targeting a specific datetime (forecast_target) in IST, | ||
the submission must be made before 9:00 AM IST on the day prior to the forecast date. | ||
|
||
Returns True if submission_time is before the deadline, False otherwise. | ||
""" | ||
ist = ZoneInfo("Asia/Kolkata") | ||
# Ensure both times are in IST | ||
forecast_target_ist = forecast_target.astimezone(ist) | ||
submission_time_ist = submission_time.astimezone(ist) | ||
|
||
# Deadline is set to 9:00 AM IST on the day before the forecast target date. | ||
deadline_date = forecast_target_ist.date() - timedelta(days=1) | ||
deadline = datetime.combine(deadline_date, time(9, 0, 0), tzinfo=ist) | ||
|
||
return submission_time_ist < deadline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed those example lines because they are outdated or no longer accurately reflect how the class is used, they might end up confusing readers. Additionally, if the functionality of the EnvParser is already there so , including those examples just becomes unnecessary.