Skip to content

Commit

Permalink
feat!: Do not extract redundant bidzone information. Bidzone can be o…
Browse files Browse the repository at this point in the history
…btained by a lookup to BusData

BREAKING CHANGE: The bidzone field is removed from several dataframes
  • Loading branch information
davidkleiven committed Aug 6, 2024
1 parent f9b99d6 commit 86d6766
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 32 deletions.
4 changes: 0 additions & 4 deletions cimsparql/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class BusDataSchema(JsonSchemaOut):
class LoadsSchema(NamedResourceSchema):
node: Series[str] = pa.Field()
substation_mrid: Series[str] = pa.Field()
bidzone: Series[str] = pa.Field(nullable=True)
status: Series[bool] = pa.Field()
p: Series[float] = pa.Field(nullable=True)
q: Series[float] = pa.Field(nullable=True)
Expand Down Expand Up @@ -105,7 +104,6 @@ class SynchronousMachinesSchema(NamedMarketResourceSchema):
maxP: Series[float] = pa.Field()
minP: Series[float] = pa.Field()
MO: Series[float] = pa.Field(nullable=True)
bidzone: Series[str] = pa.Field(nullable=True)
sn: Series[float] = pa.Field()
p: Series[float] = pa.Field(nullable=True)
q: Series[float] = pa.Field(nullable=True)
Expand Down Expand Up @@ -200,8 +198,6 @@ class CoordinatesSchema(JsonSchemaOut):


class BranchComponentSchema(NamedResourceSchema):
bidzone_1: Series[str] = pa.Field(nullable=True)
bidzone_2: Series[str] = pa.Field(nullable=True)
node_1: Series[str] = pa.Field()
node_2: Series[str] = pa.Field()
ploss_1: Series[float] = pa.Field(nullable=True)
Expand Down
7 changes: 0 additions & 7 deletions cimsparql/sparql/ac_lines.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ select
# thus max-aggregation will pick True if it exists in the group
(max(?mrid) as ?mrid)
(max(?name) as ?name)
(max(?bidzone_1) as ?bidzone_1)
(max(?bidzone_2) as ?bidzone_2)
(max(?node_1) as ?node_1)
(max(?node_2) as ?node_2)

Expand Down Expand Up @@ -54,9 +52,6 @@ where {

# Find area and optionally bidzone for each substation
?substation cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area .
optional {
?substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone .
}

optional {?acline cim:ACLineSegment.gch ?g .}
optional {?acline SN:Equipment.networkAnalysisEnable ?analysis_enabled .}
Expand Down Expand Up @@ -87,11 +82,9 @@ where {
bind(if(?nr = 1, str(?p), '') as ?p_1)
bind(if(?nr = 1, ?node, '') as ?node_1)
bind(if(?nr = 1, ?connected, False) as ?connected_1)
bind(if(?nr = 1, ?bidzone, '') as ?bidzone_1)
bind(if(?nr = 2, str(?p), '') as ?p_2)
bind(if(?nr = 2, ?node, '') as ?node_2)
bind(if(?nr = 2, ?connected, False) as ?connected_2)
bind(if(?nr = 2, ?bidzone, '') as ?bidzone_2)
bind(if(?nr = 1, ?connectivity_node, '') as ?connectivity_node_1)
bind(if(?nr = 2, ?connectivity_node, '') as ?connectivity_node_2)
filter(regex(?area, '${region}'))
Expand Down
4 changes: 1 addition & 3 deletions cimsparql/sparql/loads.sparql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Name: Loads
PREFIX cim: <${cim}>
PREFIX SN: <${SN}>
select ?mrid ?name ?node ?substation_mrid ?bidzone ?status ?p ?q ?station_group ?connectivity_node
select ?mrid ?name ?node ?substation_mrid ?status ?p ?q ?station_group ?connectivity_node
where {
{
# Appears to be significantly faster to run the query if the EQ part is executed within its own sub-query
Expand All @@ -18,8 +18,6 @@ where {
cim:IdentifiedObject.mRID ?substation_mrid .
filter regex(?area, '${region}')

# Optionally extract bidzone for each substation and station_group for each load
optional {?substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone} .
optional {?load cim:NonConformLoad.LoadGroup/SN:NonConformLoadGroup.ScheduleResource/SN:ScheduleResource.marketCode ?station_group} .
optional {?load SN:Equipment.networkAnalysisEnable ?_network_analysis} .
bind(coalesce(?_network_analysis, True) as ?network_analysis)
Expand Down
7 changes: 0 additions & 7 deletions cimsparql/sparql/series_compensators.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ PREFIX xsd: <${xsd}>
select
(max(?mrid) as ?mrid)
(max(?name) as ?name)
(max(?bidzone_1) as ?bidzone_1)
(max(?bidzone_2) as ?bidzone_2)
(max(?node_1) as ?node_1)
(max(?node_2) as ?node_2)
(if (xsd:double(max(?p_1)) < xsd:double(max(?p_2)), xsd:double(max(?p_1)) + xsd:double(max(?p_2)), xsd:double(0.0)) as ?ploss_1)
Expand Down Expand Up @@ -36,9 +34,6 @@ where {
?con_node cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation ?substation ;
cim:IdentifiedObject.mRID ?connectivity_node .
?substation cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area .
optional {
?substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone
}
optional {?compensator SN:Equipment.networkAnalysisEnable ?network_analysis}
filter(regex(?area, '${region}'))

Expand Down Expand Up @@ -68,11 +63,9 @@ where {
bind(if(?nr = 1, str(?p), '') as ?p_1)
bind(if(?nr = 1, ?node, '') as ?node_1)
bind(if(?nr = 1, ?connected, False) as ?connected_1)
bind(if(?nr = 1, ?bidzone, '') as ?bidzone_1)
bind(if(?nr = 2, str(?p), '') as ?p_2)
bind(if(?nr = 2, ?node, '') as ?node_2)
bind(if(?nr = 2, ?connected, False) as ?connected_2)
bind(if(?nr = 2, ?bidzone, '') as ?bidzone_2)
bind(if(?nr = 1, ?connectivity_node, '') as ?connectivity_node_1)
bind(if(?nr = 2, ?connectivity_node, '') as ?connectivity_node_2)
} group by ?compensator
Expand Down
7 changes: 1 addition & 6 deletions cimsparql/sparql/synchronous_machines.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PREFIX cim: <${cim}>
PREFIX SN: <${SN}>
PREFIX xsd: <${xsd}>
select ?mrid ?name ?market_code ?node ?status ?station_group ?station_group_name ?substation_mrid ?maxP ?minP ?MO ?bidzone ?sn ?p ?q ?connectivity_node ?generator_type ?schedule_resource
select ?mrid ?name ?market_code ?node ?status ?station_group ?station_group_name ?substation_mrid ?maxP ?minP ?MO ?sn ?p ?q ?connectivity_node ?generator_type ?schedule_resource
where {
# Extract properties for synchronous machines.
{
Expand Down Expand Up @@ -48,11 +48,6 @@ where {
}
filter regex(?area, '${region}')

# Optionally extract bidzone for the substation associated with the sync machin
optional {
?substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone
} .

# Opionally extract non-CIM standard properties generating units
optional {?machine SN:Equipment.networkAnalysisEnable ?_network_analysis}
bind(if(bound(?gen_type), replace(str(?gen_type), str(cim:), ""), "unknown") as ?generator_type)
Expand Down
6 changes: 1 addition & 5 deletions cimsparql/sparql/transformer_branches.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PREFIX cim: <${cim}>
PREFIX SN: <${SN}>
PREFIX xsd: <${xsd}>
# Name: Transformer branches
select ?node_1 ?node_2 ?status ?name ?mrid ?un ?r ?x ?b ?g ?rate (?bidzone as ?bidzone_1) (?bidzone as ?bidzone_2) ?angle ?ratio ?connectivity_node_1 (?node_2 as ?connectivity_node_2)
select ?node_1 ?node_2 ?status ?name ?mrid ?un ?r ?x ?b ?g ?rate ?angle ?ratio ?connectivity_node_1 (?node_2 as ?connectivity_node_2)
where {
{
select * where {
Expand Down Expand Up @@ -32,10 +32,6 @@ where {
?terminal cim:Terminal.ConnectivityNode ?con_node .
?con_node cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.BaseVoltage/cim:BaseVoltage.nominalVoltage ?un ;
cim:IdentifiedObject.mRID ?connectivity_node_1 .

# Optionally extract bidzone for substations
optional {?Substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone} .

# Optionally extract active power limits
optional {
?_lim a cim:ActivePowerLimit;
Expand Down

0 comments on commit 86d6766

Please sign in to comment.