-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: autoformat sparql-files with pre-commit
- Loading branch information
Showing
35 changed files
with
686 additions
and
674 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
# Name: Associated switches | ||
PREFIX cim: <${cim}> | ||
|
||
select (SAMPLE(?equipment_mrid) as ?mrid) (SAMPLE(?name) as ?name) (GROUP_CONCAT(?switch_mrid; SEPARATOR=',') as ?switch_mrids) (GROUP_CONCAT(?switch_name; SEPARATOR=',') as ?switch_names) where { | ||
{ | ||
?equipment ^cim:Terminal.ConductingEquipment/cim:Terminal.ConnectivityNode/^cim:Terminal.ConnectivityNode/cim:Terminal.ConductingEquipment ?switch; | ||
cim:IdentifiedObject.name ?name ; | ||
cim:IdentifiedObject.mRID ?equipment_mrid . | ||
?switch cim:Switch.normalOpen ?_normalOpen; | ||
cim:IdentifiedObject.mRID ?switch_mrid ; | ||
cim:IdentifiedObject.name ?switch_name ; | ||
# Only included switches that has a "second" terminal. There are switches | ||
# that only have one terminal. These switches can not connect/disconnect anything | ||
^cim:Terminal.ConductingEquipment/cim:ACDCTerminal.sequenceNumber 2 . | ||
} minus { | ||
?equipment cim:Switch.normalOpen ?_open | ||
} | ||
|
||
} group by ?equipment | ||
SELECT (SAMPLE(?equipment_mrid) AS ?mrid) (SAMPLE(?name) AS ?name) (GROUP_CONCAT(?switch_mrid;SEPARATOR=',') AS ?switch_mrids) (GROUP_CONCAT(?switch_name;SEPARATOR=',') AS ?switch_names) WHERE { | ||
{ | ||
?equipment ^cim:Terminal.ConductingEquipment/cim:Terminal.ConnectivityNode/^cim:Terminal.ConnectivityNode/cim:Terminal.ConductingEquipment ?switch ; | ||
cim:IdentifiedObject.name ?name ; | ||
cim:IdentifiedObject.mRID ?equipment_mrid . | ||
?switch cim:Switch.normalOpen ?_normalOpen ; | ||
cim:IdentifiedObject.mRID ?switch_mrid ; | ||
cim:IdentifiedObject.name ?switch_name ; | ||
# Only included switches that has a "second" terminal. | ||
There are switches | ||
# that only have one terminal. | ||
These switches can not connect/disconnect anything ^cim:Terminal.ConductingEquipment/cim:ACDCTerminal.sequenceNumber 2 . | ||
} | ||
MINUS { | ||
?equipment cim:Switch.normalOpen ?_open | ||
} | ||
} | ||
GROUP BY ?equipmentment |
This file contains 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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
# Name: Base voltage | ||
PREFIX cim: <${cim}> | ||
PREFIX xsd: <${xsd}> | ||
|
||
select ?mrid ?un ?operating_voltage { | ||
{ | ||
select ?base_voltage (avg(xsd:double(str(?voltage))) as ?operating_voltage) { | ||
?top_node ^cim:SvVoltage.TopologicalNode/cim:SvVoltage.v ?voltage; | ||
cim:TopologicalNode.BaseVoltage ?base_voltage . | ||
filter(xsd:double(str(?voltage)) > 0.0) | ||
} group by ?base_voltage | ||
SELECT ?mrid ?un ?operating_voltage { | ||
{ | ||
SELECT ?base_voltage (AVG(xsd:double(STR(?voltage))) AS ?operating_voltage) { | ||
?top_node ^cim:SvVoltage.TopologicalNode/cim:SvVoltage.v ?voltage ; | ||
cim:TopologicalNode.BaseVoltage ?base_voltage . | ||
FILTER (xsd:double(STR(?voltage)) > 0.0) | ||
} | ||
|
||
?_eq_subject <http://entsoe.eu/CIM/EquipmentCore/3/1> ?eq_repo . | ||
service ?eq_repo { | ||
# Find the nominal voltage from the base voltage associated with the topological node | ||
?base_voltage cim:BaseVoltage.nominalVoltage ?un ; | ||
cim:IdentifiedObject.mRID ?mrid | ||
GROUP BY ?base_voltage | ||
} | ||
?_eq_subject <http://entsoe.eu/CIM/EquipmentCore/3/1> ?eq_repo . | ||
SERVICE ?eq_repo { | ||
# Find the nominal voltage from the base voltage associated with the topological node | ||
?base_voltage cim:BaseVoltage.nominalVoltage ?un ; | ||
cim:IdentifiedObject.mRID ?mrid | ||
} | ||
} | ||
mRID ?mrid | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,32 +1,33 @@ | ||
# Name: Borders | ||
PREFIX cim:<${cim}> | ||
PREFIX SN:<${SN}> | ||
select ?mrid ?name ?market_code ?area_1 ?area_2 ?t_mrid_1 ?t_mrid_2 | ||
where { | ||
SELECT ?mrid ?name ?market_code ?area_1 ?area_2 ?t_mrid_1 ?t_mrid_2 WHERE { | ||
# Extract mRID, name and optionally market_code for aclines | ||
?acline a cim:ACLineSegment; | ||
cim:IdentifiedObject.mRID ?mrid; | ||
cim:IdentifiedObject.name ?name. | ||
optional {?acline cim:Equipment.EquipmentContainer/SN:Line.marketCode ?market_code} . | ||
optional {?acline SN:Equipment.networkAnalysisEnable ?_analysis_enabled .} | ||
|
||
?acline a cim:ACLineSegment ; | ||
cim:IdentifiedObject.mRID ?mrid ; | ||
cim:IdentifiedObject.name ?name . | ||
OPTIONAL { | ||
?acline cim:Equipment.EquipmentContainer/SN:Line.marketCode ?market_code | ||
} . | ||
OPTIONAL { | ||
?acline SN:Equipment.networkAnalysisEnable ?_analysis_enabled . | ||
} | ||
# Extract properties for the terminal connected to one end of the acline (sequenceNumber 1) | ||
?terminal1 a cim:Terminal; | ||
cim:Terminal.ConductingEquipment ?acline; | ||
cim:Terminal.sequenceNumber|cim:ACDCTerminal.sequenceNumber 1; | ||
cim:Terminal.ConnectivityNode/cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation/cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area_1; | ||
cim:IdentifiedObject.mRID ?t_mrid_1 . | ||
|
||
?terminal1 a cim:Terminal ; | ||
cim:Terminal.ConductingEquipment ?acline ; | ||
cim:Terminal.sequenceNumber | cim:ACDCTerminal.sequenceNumber 1 ; | ||
cim:Terminal.ConnectivityNode/cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation/cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area_1 ; | ||
cim:IdentifiedObject.mRID ?t_mrid_1 . | ||
# Extract properties for the terminal connected to the other end of the acline (sequenceNumber 2) | ||
?terminal2 a cim:Terminal; | ||
cim:Terminal.ConductingEquipment ?acline; | ||
cim:Terminal.sequenceNumber|cim:ACDCTerminal.sequenceNumber 2; | ||
cim:Terminal.ConnectivityNode/cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation/cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area_2 ; | ||
cim:IdentifiedObject.mRID ?t_mrid_2 . | ||
|
||
filter (?area_1 != ?area_2) | ||
filter (regex(?area_1, '${region}') || regex(?area_2, '${region}')) | ||
filter (!regex(?name, 'HVDC')) # Ignore HVDC | ||
bind(coalesce(?_analysis_enabled, True) as ?analysis_enabled) | ||
filter(?analysis_enabled) | ||
?terminal2 a cim:Terminal ; | ||
cim:Terminal.ConductingEquipment ?acline ; | ||
cim:Terminal.sequenceNumber | cim:ACDCTerminal.sequenceNumber 2 ; | ||
cim:Terminal.ConnectivityNode/cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation/cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area_2 ; | ||
cim:IdentifiedObject.mRID ?t_mrid_2 . | ||
FILTER (?area_1 != ?area_2) | ||
FILTER (REGEX(?area_1, '${region}') || REGEX(?area_2, '${region}')) | ||
FILTER (!regex(?name, 'HVDC')) | ||
# Ignore HVDC | ||
BIND (COALESCE(?_analysis_enabled, True) AS ?analysis_enabled) | ||
FILTER (?analysis_enabled) | ||
} |
This file contains 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 |
---|---|---|
@@ -1,44 +1,45 @@ | ||
# Name: Branch node withdraw | ||
PREFIX cim:<${cim}> | ||
PREFIX SN:<${SN}> | ||
select ?mrid ?node ?p ?q ?connectivity_node | ||
where { | ||
SELECT ?mrid ?node ?p ?q ?connectivity_node WHERE { | ||
{ | ||
select * where { | ||
?_eq_subject <http://entsoe.eu/CIM/EquipmentCore/3/1> ?eq_repo . | ||
service ?eq_repo { | ||
# Specify components wer are interested in | ||
values ?rdf_type {cim:ACLineSegment cim:SeriesCompensator cim:PowerTransformer} . | ||
?component a ?rdf_type . | ||
optional {?component SN:Equipment.networkAnalysisEnable ?_analysis_enabled .} | ||
?terminal cim:Terminal.ConductingEquipment ?component; | ||
cim:IdentifiedObject.mRID ?mrid; | ||
SELECT * WHERE { | ||
?_eq_subject <http://entsoe.eu/CIM/EquipmentCore/3/1> ?eq_repo . | ||
SERVICE ?eq_repo { | ||
# Specify components wer are interested in | ||
VALUES ?rdf_type { cim:ACLineSegment cim:SeriesCompensator cim:PowerTransformer } . | ||
?component a ?rdf_type . | ||
OPTIONAL { | ||
?component SN:Equipment.networkAnalysisEnable ?_analysis_enabled . | ||
} | ||
?terminal cim:Terminal.ConductingEquipment ?component ; | ||
cim:IdentifiedObject.mRID ?mrid ; | ||
cim:Terminal.ConnectivityNode ?con_node . | ||
?con_node cim:IdentifiedObject.mRID ?connectivity_node . | ||
|
||
# Find area for the connectivity node of the terminal | ||
?con_node cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation/cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area . | ||
filter(regex(?area, '${region}')) | ||
?con_node cim:IdentifiedObject.mRID ?connectivity_node . | ||
# Find area for the connectivity node of the terminal | ||
?con_node cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation/cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area . | ||
FILTER (REGEX(?area, '${region}')) | ||
} | ||
} | ||
} | ||
|
||
# Extract properties of each terminal from the SV/TP/SSH profile. | ||
# If exists, the mRID of the topological node associated with the terminal is etracted | ||
?terminal cim:ACDCTerminal.connected ?connected . | ||
?_sv_t cim:SvPowerFlow.Terminal ?terminal; | ||
cim:SvPowerFlow.p ?p; | ||
cim:SvPowerFlow.q ?q . | ||
?_sv_t cim:SvPowerFlow.Terminal ?terminal ; | ||
cim:SvPowerFlow.p ?p ; | ||
cim:SvPowerFlow.q ?q . | ||
{ | ||
?con_node cim:ConnectivityNode.TopologicalNode ?topological_node . | ||
} union { | ||
filter not exists {?con_node cim:ConnectivityNode.TopologicalNode ?topological_node} | ||
} | ||
UNION { | ||
FILTER NOT EXISTS { | ||
?con_node cim:ConnectivityNode.TopologicalNode ?topological_node | ||
} | ||
?terminal cim:Terminal.TopologicalNode ?topological_node . | ||
} | ||
?topological_node cim:IdentifiedObject.mRID ?node . | ||
|
||
# Assign analysis enabled (all True if not exist) | ||
bind(coalesce(?_analysis_enabled, True) as ?analysis_enabled) | ||
filter(?analysis_enabled) | ||
filter(?connected) | ||
BIND (COALESCE(?_analysis_enabled, True) AS ?analysis_enabled) | ||
FILTER (?analysis_enabled) | ||
FILTER (?connected) | ||
} |
This file contains 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 |
---|---|---|
@@ -1,67 +1,61 @@ | ||
# Name: Connectivity nodes | ||
|
||
PREFIX cim:<${cim}> | ||
PREFIX SN:<${SN}> | ||
PREFIX entsoeSecretariat:<${entsoeSecretariat}> | ||
|
||
select ?mrid (?container_mrid as ?container) ?container_name ?un ?base_voltage_mrid ?bidzone ?container_type | ||
where { | ||
?con_node cim:ConnectivityNode.ConnectivityNodeContainer ?con_node_container; | ||
cim:IdentifiedObject.mRID ?mrid . | ||
|
||
{ | ||
select ?con_node (count(*) as ?num_active) { | ||
# Support both typed and not typed networkAnalysisEnable flag | ||
values ?true {True "true"} | ||
?con_node ^cim:Terminal.ConnectivityNode/cim:Terminal.ConductingEquipment/SN:Equipment.networkAnalysisEnable ?true | ||
} group by ?con_node | ||
SELECT ?mrid (?container_mrid AS ?container) ?container_name ?un ?base_voltage_mrid ?bidzone ?container_type WHERE { | ||
?con_node cim:ConnectivityNode.ConnectivityNodeContainer ?con_node_container ; | ||
cim:IdentifiedObject.mRID ?mrid . | ||
{ | ||
SELECT ?con_node (COUNT(*) AS ?num_active) { | ||
# Support both typed and not typed networkAnalysisEnable flag | ||
VALUES ?true { True "true" } | ||
?con_node ^cim:Terminal.ConnectivityNode/cim:Terminal.ConductingEquipment/SN:Equipment.networkAnalysisEnable ?true | ||
} | ||
filter(?num_active > 0) | ||
|
||
GROUP BY ?con_node | ||
} | ||
FILTER (?num_active > 0) | ||
# Extract properties from the connectivity node container associated with each topoligical node | ||
{ | ||
?con_node_container cim:VoltageLevel.BaseVoltage ?base_voltage; | ||
cim:VoltageLevel.Substation ?_substation . | ||
|
||
?base_voltage cim:BaseVoltage.nominalVoltage ?un; | ||
cim:IdentifiedObject.mRID ?base_voltage_mrid . | ||
|
||
?con_node_container cim:VoltageLevel.BaseVoltage ?base_voltage ; | ||
cim:VoltageLevel.Substation ?_substation . | ||
?base_voltage cim:BaseVoltage.nominalVoltage ?un ; | ||
cim:IdentifiedObject.mRID ?base_voltage_mrid . | ||
# Extract information about the substation associated with the connectivity node container | ||
?_substation cim:IdentifiedObject.mRID ?container_mrid; | ||
cim:IdentifiedObject.name ?container_name; | ||
cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area . | ||
# Extract the bidzone of each substation if it exists | ||
optional { | ||
?_substation cim:IdentifiedObject.mRID ?container_mrid ; | ||
cim:IdentifiedObject.name ?container_name ; | ||
cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area . | ||
# Extract the bidzone of each substation if it exists | ||
OPTIONAL { | ||
?_substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/entsoeSecretariat:IdentifiedObject.energyIdentCodeEIC ?direct_bidzone | ||
} . | ||
{ | ||
filter(!bound(?bidzone)) | ||
FILTER (!bound(?bidzone)) | ||
# When an EIC code does not exist, look for an EIC code in neighbouring nodes | ||
{ | ||
select (max(?related_bidzone) as ?nearby_bidzone) where { | ||
SELECT (MAX(?related_bidzone) AS ?nearby_bidzone) WHERE { | ||
# Collect bidzones from substations connected to the current substation via a ConductingEquipment | ||
?con_node ^cim:Terminal.ConnectivityNode/cim:Terminal.ConductingEquipment/^cim:Terminal.ConductingEquipment/cim:Terminal.ConnectivityNode/cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation/SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/entsoeSecretariat:IdentifiedObject.energyIdentCodeEIC ?related_bidzone . | ||
} | ||
?con_node ^cim:Terminal.ConnectivityNode/cim:Terminal.ConductingEquipment/^cim:Terminal.ConductingEquipment/cim:Terminal.ConnectivityNode/cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation/SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/entsoeSecretariat:IdentifiedObject.energyIdentCodeEIC ?related_bidzone . | ||
} | ||
} | ||
} | ||
bind("Substation" as ?container_type) | ||
bind(coalesce(?direct_bidzone, ?nearby_bidzone) as ?bidzone) | ||
} union { | ||
?con_node_container cim:Line.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area; | ||
cim:IdentifiedObject.name ?container_name; | ||
cim:IdentifiedObject.mRID ?container_mrid | ||
|
||
BIND ("Substation" AS ?container_type) | ||
BIND (COALESCE(?direct_bidzone, ?nearby_bidzone) AS ?bidzone) | ||
} | ||
UNION { | ||
?con_node_container cim:Line.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area ; | ||
cim:IdentifiedObject.name ?container_name ; | ||
cim:IdentifiedObject.mRID ?container_mrid | ||
# Extract voltage levels connectivity nodes related via a conducting equipment (cim:Line has no cim:VoltageLeve.BaseVoltage) | ||
{ | ||
select ?base_voltage_mrid ?un { | ||
SELECT ?base_voltage_mrid ?un { | ||
?con_node ^cim:Terminal.ConnectivityNode/cim:Terminal.ConductingEquipment/^cim:Terminal.ConductingEquipment/cim:Terminal.ConnectivityNode/cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.BaseVoltage ?base_voltage . | ||
?base_voltage cim:IdentifiedObject.mRID ?base_voltage_mrid; | ||
cim:BaseVoltage.nominalVoltage ?un | ||
} order by desc (xsd:double(str(?un))) | ||
limit 1 | ||
?base_voltage cim:IdentifiedObject.mRID ?base_voltage_mrid ; | ||
cim:BaseVoltage.nominalVoltage ?un | ||
} | ||
ORDER BY DESC(xsd:double(STR(?un))) | ||
LIMIT 1 | ||
} | ||
|
||
bind("Line" as ?container_type) | ||
BIND ("Line" AS ?container_type) | ||
} | ||
FILTER regex(?area, '.*') | ||
FILTER REGEX(?area, '.*') | ||
} |
Oops, something went wrong.