Skip to content

Commit

Permalink
Merge pull request #76 from carbon-data-specification/abg/update_meta…
Browse files Browse the repository at this point in the history
…data

Abg/update metadata
  • Loading branch information
ssuffian authored Dec 8, 2023
2 parents c86e940 + 50a11fa commit cdbebd7
Show file tree
Hide file tree
Showing 7 changed files with 609 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name,external_reference,external_id
Solar - Photovoltaic - Unspecified,EECS Rules Fact Sheet 5 TYPES OF ENERGY INPUTS AND TECHNOLOGIES,T010100
Fossil - Solid - Hard Coal - Unspecified,EECS Rules Fact Sheet 5 TYPES OF ENERGY INPUTS AND TECHNOLOGIES,F02010100
Mechanical source or other - Wind - Unspecified, EECS Rules Fact Sheet 5 TYPES OF ENERGY INPUTS AND TECHNOLOGIES,F01050100
Thermal - Steam engine - Unspecified,EECS Rules Fact Sheet 5 TYPES OF ENERGY INPUTS AND TECHNOLOGIES,T050900
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Grid Node,Topology Level,Unit,Connected Node,Capacity
US-WECC-CISO,1,MW,US-WECC-PACW,800
US-WECC-CISO,1,MW,US-WECC-BANC,100
US-WECC-PACW,0,MW,US-WECC-CISO,800
US-WECC-BANC,1,MW,US-WECC-CISO,100
159 changes: 159 additions & 0 deletions power_systems_data_api_demonstrator/data/example/psr_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
[
{
"id": "US-WECC-BANC",
"topology_level": 1,
"transmission_capacity": [
{
"connectedPSR": "US-WECC-CISO",
"unit": "MW",
"value": 700
}
],
"fuelSource_capacity": [
{
"type": "Renewable-Heat-Solar-Unespecified",
"technology": "Solar-Photovoltaic-Classic silicon",
"unit": "MW",
"capacity": [
{
"value": 500,
"startDatetime": "2017-10-10"
}
]
},
{
"type": "Renewable-Mechanical source or other-Wind-Unespecified",
"technology": "Wind-Offshore-Unespecified",
"unit": "MW",
"capacity": [
{
"value": 500,
"startDatetime": "2016-02-28"
}
]
}
]
},
{
"id": "US-WECC-PACW",
"topology_level": 1,
"transmission_capacity": [
{
"connectedPSR": "US-WECC-CISO",
"unit": "MW",
"value": 1000
}
],
"fuelSource_capacity": [
{
"type": "Renewable-Mechanical source or other-Wind-Unespecified",
"technology": "Wind-Onshore-Unespecified",
"unit": "MW",
"capacity": [
{
"value": 1000,
"startDatetime": "2017-01-01"
}
]
},
{
"type": "Nuclear-Solid-Radiactive fuel-UOX",
"technology": "Thermal-Steam Turbine with condensation turbine-Unespecified",
"unit": "MW",
"capacity": [
{
"value": 800,
"startDatetime": "1975-10-15",
"endDatetime": "2016-12-31"
}
]
}
]
},
{
"id": "US-WECC-CISO",
"topology_level": 1,
"transmission_capacity": [
{
"connectedPSR": "US-WECC-BANC",
"unit": "MW",
"value": 700
},
{
"connectedPSR": "US-WECC-PACW",
"unit": "MW",
"value": 1000
}
],
"fuelSource_capacity": [
{
"type": "Renewable-Heat-Solar-Unespecified",
"technology": "Solar-Photovoltaic-Classic silicon",
"unit": "MW",
"capacity": [
{
"value": 500,
"startDatetime": "2020-10-15"
}
]
},
{
"type": "Fossil-Solid-Hard Coal-Antracite",
"technology": "Thermal-Steam Turbine with condensation turbine-Unespecified",
"unit": "MW",
"capacity": [
{
"value": 1000,
"startDatetime": "1999-12-13"
},
{
"value": 500,
"startDatetime": "1980-10-15",
"endDatetime": "1999-12-12"
}
]
}
]
},
{
"id": "US-WECC-AZPS",
"topology_level": 2,
"parent": "US-WECC-CISO",
"fuelSource_capacity": [
{
"type": "Renewable-Heat-Solar-Unespecified",
"technology": "Solar-Photovoltaic-Classic silicon",
"unit": "MW",
"capacity": [
{
"value": 500,
"startDatetime": "2020-10-15"
}
]
}
]
},
{
"id": "US-WECC-CEN",
"topology_level": 2,
"parent": "US-WECC-CISO",
"fuelSource_capacity": [
{
"type": "Fossil-Solid-Hard Coal-Antracite",
"technology": "Thermal-Steam Turbine with condensation turbine-Unespecified",
"unit": "MW",
"capacity": [
{
"value": 1000,
"startDatetime": "1999-12-13"
},
{
"value": 500,
"startDatetime": "1980-10-15",
"endDatetime": "1999-12-12"
}
]
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
level,id
0,Interconnection
1,Balancing Area
2,Generating Plant
3,Generating Unit
4,Consumption Unit
120 changes: 91 additions & 29 deletions power_systems_data_api_demonstrator/src/api/metadata/views.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
from pydantic import BaseModel
from typing import Sequence
from sqlmodel import select

from sqlmodel import Session
from enum import Enum
from sqlmodel import Field
from datetime import datetime
from sqlmodel import SQLModel
from typing import Optional, Sequence

from fastapi import APIRouter, Request
import pandas as pd
from fastapi import APIRouter
from fastapi.param_functions import Depends
from power_systems_data_api_demonstrator.src.api.db import get_session
from pydantic import BaseModel
from sqlmodel import Field, Session, SQLModel, select

from power_systems_data_api_demonstrator.src.api.db import get_session

router = APIRouter()

Expand All @@ -20,7 +15,9 @@ class TopologyLevel(SQLModel, table=True):
id: str = Field(primary_key=True)
level: int | None = Field(
ge=0,
description="A number representing the hierarchy of this resource topology in relation to the other resource types. These levels **shall** include a sequential set of positive integers starting at 0.",
description="""A number representing the hierarchy of this resource topology in
relation to the other resource types. These levels **shall** include a
sequential set of positive integers starting at 0.""",
)


Expand All @@ -40,22 +37,87 @@ async def get_topology_levels(
return TopologyLevelsResponse(topology_levels=topology_levels)


class FuelTypeDescription(BaseModel):
name: str = Field(
description="A common name to use for the fuel type. If using AIB codes, it should be a concatenation of the three code descriptions with a dash between (i.e. 'Solar - Photovoltaic - Unspecified')."
)
external_id: str = Field(
description="A unique code (such as the AIB code) referencing the type of fuel."
)
class FuelSourceType(SQLModel, table=True):
name: str = Field(primary_key=True)
external_reference: Optional[str]
external_id: Optional[str]


class FuelTypesResponse(BaseModel):
external_reference: str = Field(
default="AIB EECS Rule Fact Sheet 5",
description="A reference that provides context for this specific fuel type.",
)
external_reference_url: str = Field(
default="https://www.aib-net.org/sites/default/files/assets/eecs/facts-sheets/AIB-2019-EECSFS-05%20EECS%20Rules%20Fact%20Sheet%2005%20-%20Types%20of%20Energy%20Inputs%20and%20Technologies%20-%20Release%207.7%20v5.pdf",
description="A unique code (such as the AIB code) referencing the type of fuel.",
)
types: list[FuelTypeDescription]
class FuelSourceTypesResponse(SQLModel):
types: list[FuelSourceType]


@router.get(
"/fuel-source/types",
summary="FUEL SOURCE TYPES",
)
async def get_fuel_source_types(
session: Session = Depends(get_session),
) -> FuelSourceTypesResponse:
result = session.execute(select(FuelSourceType))
types = result.scalars().all()
return FuelSourceTypesResponse(types=types)


class FuelSourceTechnologyReference(SQLModel):
aibCode: str
source_document: str


class FuelSourceTechnologyReferenceTable(FuelSourceTechnologyReference, table=True):
name: str = Field(primary_key=True)


class FuelSourceTechnology(SQLModel):
name: str
externalReference: FuelSourceTechnologyReference


class FuelSourceTechnologyResponse(SQLModel):
technologies: Sequence[FuelSourceTechnology]


@router.get(
"/fuel-source/technologies",
summary="FUEL SOURCE TECHNOLOGIES",
)
async def get_fuel_source_technologies(
session: Session = Depends(get_session),
) -> FuelSourceTechnologyResponse:
result = session.execute(select(FuelSourceTechnologyReferenceTable))
technologies = result.scalars().all()
df = pd.DataFrame(g.dict() for g in technologies)
technologies = []
for index, row in df.iterrows():
technologies.append(
# FuelSourceTechnologyReferenceTable(
FuelSourceTechnology(
name=row["name"],
externalReference=FuelSourceTechnologyReference(
aibCode=row["aibCode"],
source_document=row["source_document"],
),
)
)
return FuelSourceTechnologyResponse(technologies=technologies)


# class FuelTypeDescription(BaseModel):
# name: str = Field(
# description="A common name to use for the fuel type. If using AIB codes, it should be a concatenation of the three code descriptions with a dash between (i.e. 'Solar - Photovoltaic - Unspecified')."# noqa: E501
# )
# external_id: str = Field(
# description="A unique code (such as the AIB code) referencing the type of fuel. # noqa: E501"
# )


# class FuelTypesResponse(BaseModel):
# external_reference: str = Field(
# default="AIB EECS Rule Fact Sheet 5",
# description="A reference that provides context for this specific fuel type.",
# )
# external_reference_url: str = Field(
# default="https://www.aib-net.org/sites/default/files/assets/eecs/facts-sheets/AIB-2019-EECSFS-05%20EECS%20Rules%20Fact%20Sheet%2005%20-%20Types%20of%20Energy%20Inputs%20and%20Technologies%20-%20Release%207.7%20v5.pdf",# noqa: E501
# description="A unique code (such as the AIB code) referencing the type of fuel # noqa: E501.",
# )
# types: list[FuelTypeDescription]
Loading

0 comments on commit cdbebd7

Please sign in to comment.