Feature/add nighttime zeros issue #104#110
Feature/add nighttime zeros issue #104#110Sagarpillai wants to merge 34 commits intoopenclimatefix:mainfrom
Conversation
|
Hi @peterdudfield If you’d prefer this to live in a different folder or a different name, let me know and I’ll move it. |
solar_consumer/data/nighttime.py
Outdated
| @@ -0,0 +1,43 @@ | |||
| # solar_consumer/pvlive/nighttime.py | |||
There was a problem hiding this comment.
if possible, could you put this under the data folder
solar_consumer/data/nighttime.py
Outdated
| at_night = (df["target_time_utc"] < df["sunrise_utc"]) | (df["target_time_utc"] >= df["sunset_utc"]) | ||
| df.loc[at_night, "generation_mw"] = 0.0 | ||
|
|
||
| return df |
There was a problem hiding this comment.
could you also copy any tests across from PVLive consumer?
|
Thank you btw for doing this |
|
@peterdudfield, sure, I've made the changes, please let me know if everything's okay |
solar_consumer/data/nighttime.py
Outdated
|
|
||
| # Build mask: night is before sunrise OR at/after sunset | ||
| at_night = (df[ts_col] < df[sunrise_col]) | (df[ts_col] >= df[sunset_col]) | ||
| df.loc[at_night, mw_col] = 0.0 |
There was a problem hiding this comment.
I dont remeber these sunrise and sunset columns? How was this done in PVLive-Consumer?
|
@peterdudfield , |
solar_consumer/data/fetch_gb_data.py
Outdated
| # Prefer loading locations from the canonical datamodel; fall back to empty frame | ||
| try: | ||
| from nowcasting_datamodel.read.gsp import get_all_locations # type: ignore | ||
| _GSP_LOCATIONS = get_all_locations().set_index("gsp_id") |
There was a problem hiding this comment.
sorry, could we not use nowcasting_datamodel, i think copying in a csv of the centeroid of the gsps would be fine
There was a problem hiding this comment.
sure I'll change that
solar_consumer/data/nighttime.py
Outdated
| Copy of df with nighttime rows set to zero in `mw_col`. | ||
| """ | ||
| try: | ||
| import pvlib # lazy import |
There was a problem hiding this comment.
why have this try and except? I would just import it at the opt
There was a problem hiding this comment.
I'll change this as well, I'll update the PR soon, is there an issue with anything else?
|
@peterdudfield yep, made the changes. Hope everything's good now, please let me know if im missing anything, thank you. |
|
@peterdudfield, For the CSV with gsp_id + lat/lon which repo/source would you like me to take the centroid values from? Once I know the preferred source, I’ll copy those values into gsp_id,latitude,longitude |
where does it get them from in PVLive-consumer? |
@peterdudfield yep, got it was confused on copying .csv files, hope this is the one. |
solar_consumer/data/fetch_gb_data.py
Outdated
| # Load GSP lat/lon for night-time zeroing from CSV (no datamodel dependency) | ||
| DIR = os.path.dirname(__file__) | ||
|
|
||
| def _load_gsp_locations() -> pd.DataFrame | None: |
There was a problem hiding this comment.
could this be moved to nighttime, as a specific to that?
peterdudfield
left a comment
There was a problem hiding this comment.
This looks great!
I think with one more test, we would be good to go
sure, I've added the test to check whether it loads data |
tests/data/test_nighttime.py
Outdated
| def test_load_gsp_locations(): | ||
| """Verify the bundled GSP locations CSV loads and contains expected columns.""" | ||
| if GSP_LOCATIONS is None: | ||
| pytest.skip("GSP locations CSV not present in this environment") |
There was a problem hiding this comment.
Can you remove this please
There was a problem hiding this comment.
We want to make sure the test run
tests/data/test_nighttime.py
Outdated
| def test_make_night_time_zeros_uses_gsp_id_fallback(): | ||
| """Ensure make_night_time_zeros can look up coords using gsp_id and run.""" | ||
| if GSP_LOCATIONS is None: | ||
| pytest.skip("GSP locations CSV not present in this environment") |
|
@peterdudfield Ive removed the skipping tests part, please review it when you get a moment |
|
@peterdudfield any update on this? |
…builds start/end time index and includes capacity columns (fix reviewer request)
…e gives empty df (reviewer request)
|
@peterdudfield |
| - `Datetime_GMT`: Combined date and time in UTC. | ||
| - `solar_forecast_kw`: Estimated solar forecast in kW. | ||
| """ | ||
| meta_url = "https://api.neso.energy/api/3/action/datapackage_show?id=embedded-wind-and-solar-forecasts" |
There was a problem hiding this comment.
why has this changed?
There was a problem hiding this comment.
i dont really understand why any of this function has been changed?
(aprt from adding nighttime in)
|
@peterdudfield , sorry about the mess, I've reverted back to the original code. Please check if everything's okay, thank you |
|
Hey @peterdudfield any updates on this? |
|
Sorry for my slow reply. I think im getting a bit confused. Looking back at the issue, #104, this function should add night time zeros, if there is no data provded by PVLive. However looking at this PR, it looks like it changes results. I think we might need to change this. Sorry i should have said this when you first submiited it |
Apologies for the misunderstanding, I'll redo it and put up a PR soon. |
|
Hi, I've been travelling and I'm a little sick, I'll make the changes as soon as I can :) |
Pull Request
Changes made:
Added import for make_night_time_zeros from pvliveconsumer.nightime
Added function call in the PVLive data processing loop to fill nighttime gaps
Added pvliveconsumer dependency to pyproject.toml
Fixes #104