This repository was archived by the owner on Sep 11, 2023. It is now read-only.
-
Couldn't load subscription status.
- Fork 7
Issue/52 sun azimuth elevation #175
Merged
Merged
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1881ef1
first try and saving Sun data
peterdudfield 6c66457
Merge branch 'bug/154-crs-warning' into issue/52-sun-azimuth-elevation
peterdudfield 768af24
add test sun data
peterdudfield ff8280a
fix tests apart from datamodule ones
peterdudfield 91e0466
Merge commit 'aa702078eedbe8e41c04b89ddbf44fb88845884f' into issue/52…
peterdudfield a8f78ae
add Sun Data Source to DataModule
peterdudfield 7fb04f7
update sun data to save x,y centers (OSGB) not lats and lons
peterdudfield a721ac5
update sun test data
peterdudfield ece93c8
Make sure sun data source works for other years than just 2019
peterdudfield cb92a3f
Merge commit '5a80d7e5b2eb47cf2f654e100c84cc4ff16d87aa' into issue/52…
peterdudfield 5aff271
add function strings
peterdudfield 4b950d8
tidy
peterdudfield 4eb8dd1
tidy
peterdudfield ff00e7b
Update nowcasting_dataset/data_sources/sun/raw_data_load_save.py
peterdudfield 1082fcb
PR comments
peterdudfield 4ffe644
Merge branch 'issue/52-sun-azimuth-elevation' of github.com:openclima…
peterdudfield 7ba47b8
Update scripts/get_raw_sun_data.py
peterdudfield f730d52
PR comments
peterdudfield 49b4211
tidy from PR comment
peterdudfield ac3c5a2
fix
peterdudfield 890934a
Merge branch 'main' into issue/52-sun-azimuth-elevation
peterdudfield fe5adf2
pylint
peterdudfield bb105be
Merge branch 'main' into issue/52-sun-azimuth-elevation
peterdudfield 58212bc
Merge branch 'main' into issue/52-sun-azimuth-elevation
peterdudfield 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| ############ | ||
| # Look into the differences from year to year in elevation and azimuthal direction | ||
|
|
||
| # Looked from 2018-2020, for January, April, July and October, | ||
| # Found the different from year to year was less than 1 degree | ||
|
|
||
| ############ | ||
|
|
||
| import logging | ||
|
|
||
| logging.basicConfig() | ||
| logging.getLogger().setLevel(logging.DEBUG) | ||
| logging.getLogger("urllib3").setLevel(logging.WARNING) | ||
|
|
||
| from datetime import datetime | ||
| from pathlib import Path | ||
| import pandas as pd | ||
| import numpy as np | ||
| import os | ||
| import nowcasting_dataset | ||
| from nowcasting_dataset.data_sources.gsp.eso import get_gsp_metadata_from_eso | ||
| from nowcasting_dataset.data_sources.sun.raw_data_load_save import ( | ||
| save_to_zarr, | ||
| get_azimuth_and_elevation, | ||
| ) | ||
|
|
||
| # set up | ||
| BUCKET = Path("solar-pv-nowcasting-data") | ||
| PV_PATH = BUCKET / "PV/PVOutput.org" | ||
| PV_METADATA_FILENAME = PV_PATH / "UK_PV_metadata.csv" | ||
|
|
||
| # set up variables | ||
| local_path = os.path.dirname(nowcasting_dataset.__file__) + "/.." | ||
| metadata_filename = f"gs://{PV_METADATA_FILENAME}" | ||
|
|
||
| # PV metadata | ||
| pv_metadata = pd.read_csv(metadata_filename, index_col="system_id") | ||
| pv_metadata = pv_metadata.dropna(subset=["longitude", "latitude"]) | ||
| pv_longitudes = pv_metadata["longitude"] | ||
| pv_latitudes = pv_metadata["latitude"] | ||
|
|
||
| # GSP Metadata | ||
| gsp_metadata = get_gsp_metadata_from_eso() | ||
| gsp_metadata = gsp_metadata.dropna(subset=["centroid_lon", "centroid_lat"]) | ||
| # probably need to change this to centroid | ||
| gsp_lon = gsp_metadata["centroid_lon"] | ||
| gsp_lat = gsp_metadata["centroid_lat"] | ||
|
|
||
| # join all sites together | ||
| longitudes = list(pv_longitudes.values) + list(gsp_lon.values) | ||
| latitudes = list(pv_latitudes.values) + list(gsp_lat.values) | ||
|
|
||
| # make d | ||
| start_dt = datetime.fromisoformat("2019-01-01 00:00:00.000+00:00") | ||
| end_dt = datetime.fromisoformat("2019-01-02 00:00:00.000+00:00") | ||
|
|
||
| azimuths = {} | ||
| azimuths_sin = {} | ||
| azimuths_cos = {} | ||
| elevations = {} | ||
| months = [1, 4, 7, 10] | ||
| years = [2018, 2019, 2020] | ||
| for month in months: | ||
| for year in years: | ||
| print(year) | ||
| print(month) | ||
| start_dt = start_dt.replace(year=year, month=month) | ||
| end_dt = end_dt.replace(year=year, month=month) | ||
| datestamps = pd.date_range(start=start_dt, end=end_dt, freq="5T") | ||
|
|
||
| azimuth, elevation = get_azimuth_and_elevation( | ||
| longitudes=longitudes, latitudes=latitudes, datestamps=datestamps | ||
| ) | ||
|
|
||
| azimuths[f"{year}_{month}"] = azimuth | ||
| azimuths_sin[f"{year}_{month}"] = np.sin(np.deg2rad(azimuth)) | ||
| azimuths_cos[f"{year}_{month}"] = np.cos(np.deg2rad(azimuth)) | ||
| elevations[f"{year}_{month}"] = elevation | ||
|
|
||
| m_azimuths = [] | ||
| m_azimuths_sin = [] | ||
| m_azimuths_cos = [] | ||
| m_elevations = [] | ||
| for month in months: | ||
| for year in years[1:]: | ||
| print(year) | ||
| print(month) | ||
|
|
||
| m_azimuths.append( | ||
| (np.abs(azimuths[f"{year}_{month}"].values - azimuths[f"2018_{month}"].values)).max() | ||
| ) | ||
| m_azimuths_sin.append( | ||
| ( | ||
| np.abs( | ||
| azimuths_sin[f"{year}_{month}"].values - azimuths_sin[f"2018_{month}"].values | ||
| ) | ||
| ).max() | ||
| ) | ||
| m_azimuths_cos.append( | ||
| ( | ||
| np.abs( | ||
| azimuths_cos[f"{year}_{month}"].values - azimuths_cos[f"2018_{month}"].values | ||
| ) | ||
| ).max() | ||
| ) | ||
| m_elevations.append( | ||
| ( | ||
| np.abs(elevations[f"{year}_{month}"].values - elevations[f"2018_{month}"].values) | ||
| ).max() | ||
| ) | ||
|
|
||
|
|
||
| # for small radians, sin(x) ~ x, so sin(x)*180/pi ~ degrees | ||
| m_azimuths = np.array(m_azimuths_sin) * 180 / np.pi | ||
| # m_azimuths = np.array(m_azimuths_cos) * 180 / np.pi | ||
|
|
||
| print(f"Maximum azimuth difference is {max(m_azimuths)} degree") | ||
| print(f"Maximum elevation difference is {max(m_elevations)} degree") | ||
|
|
||
| # largest different in both azimuth and elevation < 1 degree --> Happy to use one yea data |
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
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
Empty file.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.