Skip to content

Commit

Permalink
Remove now_casting Dataset Usage and Adjust GSP Endpoints (#323) (#325)
Browse files Browse the repository at this point in the history
* Remove now_casting Dataset Usage and Adjust GSP Endpoints (#323)

* removed nowcasting_dataset

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Removed now_cast dataset tests (#326)

* removed nowcasting_dataset

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* removed realted test

* Merge branch 'nowcast_dataset' of https://github.com/roshnaeem/uk-pv-national-gsp-api into nowcast_dataset

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

---------

Co-authored-by: Rosheen Naeem <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 12, 2024
1 parent 321b665 commit 68eaad1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 59 deletions.
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

0 comments on commit 68eaad1

Please sign in to comment.