-
Notifications
You must be signed in to change notification settings - Fork 9
Tech 182 python sdk users want an example with historic monthly data #37
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
Changes from all commits
cfcd1d6
3aee978
8f0a223
2b6c745
20a2f6c
967c73d
45ffb9e
c713c9f
05e97ea
04bbd63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,4 +30,34 @@ res.to_pandas().head() | |
| | 2022-06-01 07:00:00+00:00 | 13 | 62 | 12 | | ||
| | 2022-06-01 07:30:00+00:00 | 13 | 0 | 0 | | ||
| | 2022-06-01 08:00:00+00:00 | 12 | 0 | 0 | | ||
| | 2022-06-01 08:30:00+00:00 | 12 | 0 | 0 | | ||
| | 2022-06-01 08:30:00+00:00 | 12 | 0 | 0 | | ||
|
|
||
|
|
||
| ## Example of multi period request for the year of 2023 from Jan 01 | ||
| ### The below code is using an unmetered location. If using a metered location, it will consume 12 request. | ||
billy-solcast marked this conversation as resolved.
Show resolved
Hide resolved
billy-solcast marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```python | ||
| from solcast import historic | ||
| import pandas as pd | ||
| from solcast.unmetered_locations import UNMETERED_LOCATIONS | ||
| from solcast import historic | ||
|
|
||
| site = UNMETERED_LOCATIONS["Stonehenge"] | ||
billy-solcast marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| latitude, longitude = site["latitude"], site["longitude"] | ||
|
|
||
| data = [] | ||
| start_date = '2023-01-01' | ||
| start_dates = pd.date_range(start=start_date, periods=12, freq='MS') | ||
|
|
||
| for start in start_dates: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I liked about your previous implementation with while loop, is that it did not require the user to think up front about how the queries should be chunked. The following version of the former while code will only get the exact number of days required (including getting all of the final day).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was updated as a solution to @Zempire's comment: I think it's a cleaner way to pull the data, if the final objective is to retrieve only one years worth of data. |
||
| start_str = start.strftime('%Y-%m-%dT00:00:00.000Z') | ||
billy-solcast marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end_date = (start + pd.offsets.MonthEnd(1)).strftime('%Y-%m-%dT23:59:59.000Z') | ||
billy-solcast marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| res = historic.radiation_and_weather(latitude=latitude, longitude=longitude, start=start_str, end=end_date) | ||
| if res.success: | ||
| data.append(res.to_pandas()) | ||
| else: | ||
| print(res.exception) | ||
|
|
||
| output = pd.concat(data) | ||
billy-solcast marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
billy-solcast marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.