Skip to content
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

Remove now_casting Dataset Usage and Adjust GSP Endpoints (#323) #325

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pydantic
numpy
requests
nowcasting_datamodel==1.5.18
nowcasting_dataset==3.7.12
sqlalchemy
psycopg2-binary
geopandas
Expand Down
48 changes: 0 additions & 48 deletions src/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from fastapi import APIRouter, Depends, Request, Security
from fastapi_auth0 import Auth0User
from nowcasting_datamodel.models import GSPYield, Location
from nowcasting_dataset.data_sources.gsp.eso import get_gsp_metadata_from_eso
from sqlalchemy.orm.session import Session

from auth_utils import get_auth_implicit_scheme, get_user
Expand All @@ -25,53 +24,6 @@
NationalYield = GSPYield


def get_gsp_boundaries_from_eso_wgs84() -> gpd.GeoDataFrame:
"""Get GSP boundaries in lat/lon format (EPSG:4326)"""

# get gsp boundaries
boundaries = get_gsp_metadata_from_eso()

# change to lat/lon - https://epsg.io/4326
boundaries = boundaries.to_crs(4326)

# fill nans
boundaries = boundaries.fillna("")

return boundaries


# corresponds to API route /v0/system/GB/gsp/boundaries
@router.get(
"/boundaries",
dependencies=[Depends(get_auth_implicit_scheme())],
)
@cache_response
@limiter.limit(f"{N_CALLS_PER_HOUR}/hour")
def get_gsp_boundaries(
request: Request,
session: Session = Depends(get_session),
user: Auth0User = Security(get_user()),
) -> dict:
"""### Get GSP boundaries

Returns an object with GSP boundaries provided by National Grid ESO.

[This is a wrapper around the dataset](https://data.nationalgrideso.com/systemgis-boundaries-for-gb-grid-supply-points).

The return object is in EPSG:4326 (ie. contains latitude & longitude
coordinates).

"""

logger.info(f"Getting all GSP boundaries for user {user}")

json_string = get_gsp_boundaries_from_eso_wgs84().to_json()

json.loads(json_string)

return json.loads(json_string)


# corresponds to API route /v0/system/GB/gsp/, get system details for all GSPs
@router.get(
"/",
Expand Down
10 changes: 0 additions & 10 deletions src/tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,3 @@ def test_get_gsp_systems(db_session, api_client):
locations = [Location(**location) for location in response.json()]
assert len(locations) == 10
assert locations[1].installed_capacity_mw == 1.1


def test_gsp_boundaries(db_session, api_client):
"""Check main system/GB/gsp/boundaries"""

app.dependency_overrides[get_session] = lambda: db_session

response = api_client.get("/v0/system/GB/gsp/boundaries")
assert response.status_code == 200
assert len(response.json()) > 0
Loading