Skip to content

Commit 871792b

Browse files
Improve mapping doc examples about enumerations usage (#180)
Signed-off-by: Damien Jeandemange <[email protected]> Co-authored-by: Nicolas Rol <[email protected]>
1 parent d980aee commit 871792b

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

Diff for: docs/mapping.md

+44-32
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ parameters {
3131
There is one mapping function for each type of network elements:
3232

3333
```groovy
34-
mapToGenerators {...}
35-
mapToLoads {...}
36-
mapToHvdcLines {...}
37-
mapToBoundaryLines {...}
38-
mapToBreakers {...}
39-
mapToTransformers {...}
40-
mapToPhaseTapChangers {...}
41-
mapToRatioTapChangers {...}
42-
mapToLccConverterStations {...}
43-
mapToVscConverterStations {...}
34+
mapToGenerators { /* ... */ }
35+
mapToLoads { /* ... */ }
36+
mapToHvdcLines { /* ... */ }
37+
mapToBoundaryLines { /* ... */ }
38+
mapToBreakers { /* ... */ }
39+
mapToTransformers { /* ... */ }
40+
mapToPhaseTapChangers { /* ... */ }
41+
mapToRatioTapChangers { /* ... */ }
42+
mapToLccConverterStations { /* ... */ }
43+
mapToVscConverterStations { /* ... */ }
4444
```
4545

4646
the general syntax is:
@@ -49,8 +49,8 @@ the general syntax is:
4949
mapToXXX {
5050
variable variableName //optional, the name of the element variable to map the time series with. Each element have a default mapped variable (defined below)
5151
timeSeriesName 'timeseriesName' // name of the time series to map
52-
filter {...} // a filter predicate allowing to select which item of the element type we wish to map
53-
distributionKey {...} // optional, a repartition key that will define how the time serie values will be distributed for each selected items (default is equipartition : val / N)
52+
filter { /* ... */ } // a filter predicate allowing to select which item of the element type we wish to map
53+
distributionKey { /* ... */ } // optional, a repartition key that will define how the time serie values will be distributed for each selected items (default is equipartition : val / N)
5454
}
5555
```
5656
The element of the general syntax are described below.
@@ -110,26 +110,38 @@ Please learn more with the following examples:
110110

111111
To filter the generators of the country 'FR' of energy source type 'THERMAL', we can define the following filter:
112112
```groovy
113-
filter {generator.terminal.voltageLevel.substation.country == FR && generator.energySource == EnergySource.THERMAL}
113+
import com.powsybl.iidm.network.Country
114+
import com.powsybl.iidm.network.EnergySource
115+
116+
mapToGenerators {
117+
/* ... */
118+
filter { generator.terminal.voltageLevel.substation.country == Country.FR && generator.energySource == EnergySource.THERMAL }
119+
}
114120
```
115121
or
116122
```groovy
117-
filter {substation.country == FR && generator.energySource == EnergySource.THERMAL}
123+
import com.powsybl.iidm.network.Country
124+
import com.powsybl.iidm.network.EnergySource
125+
126+
mapToGenerators {
127+
/* ... */
128+
filter { substation.country == Country.FR && generator.energySource == EnergySource.THERMAL }
129+
}
118130
```
119131

120-
To filter the generators connected to a list of substations:
132+
To filter the generators connected to a list of voltage levels:
121133
```groovy
122-
filter {['D.BURP7', 'D.BUXP7'].contains(generator.terminal.voltageLevel.id)}
134+
filter { ['D.BURP7', 'D.BUXP7'].contains(generator.terminal.voltageLevel.id) }
123135
```
124136

125137
To filter the loads of a particular region (assuming the IIDM model has been extended with a custom property `region`):
126138
```groovy
127-
filter { ['05', '08', '09', '13', '14', '17', '24', '25', '28'].contains(load.voltageLevel.substation.region)}
139+
filter { ['05', '08', '09', '13', '14', '17', '24', '25', '28'].contains(load.voltageLevel.substation.region) }
128140
```
129141

130142
To filter generators that belong to the main connected component:
131143
```groovy
132-
filter {generator.terminal.busView.bus?.inMainConnectedComponent}
144+
filter { generator.terminal.busView.bus?.inMainConnectedComponent }
133145
```
134146

135147
#### Distribution key
@@ -143,14 +155,14 @@ Please look at the following examples:
143155
To create a distribution key relative to the Pmax of each group:
144156
```groovy
145157
mapToGenerators {
146-
...
147-
distributionKey {generator.maxP}
158+
/* ... */
159+
distributionKey { generator.maxP }
148160
}
149161
```
150162

151163
To create a distribution key relative to the power target:
152164
```groovy
153-
distributionKey {generator.targetP}
165+
distributionKey { generator.targetP }
154166
```
155167

156168
To create a distribution key defined by time series (assuming we have or created the time series SO_G1_key and SO_G2_key):
@@ -166,8 +178,8 @@ mapToGenerators {
166178
To create a distribution key relative to the base load:
167179
```groovy
168180
mapToLoads {
169-
...
170-
distributionKey {load.p0}
181+
/* ... */
182+
distributionKey { load.p0 }
171183
}
172184
```
173185

@@ -195,7 +207,7 @@ Time series mapping on a generator :
195207
```groovy
196208
mapToGenerators {
197209
timeSeriesName 'myTimeSeries'
198-
filter {generator.id=='GROUP_1'}
210+
filter { generator.id=='GROUP_1' }
199211
}
200212
```
201213

@@ -204,32 +216,32 @@ Time series mapping on the variable active power of a load :
204216
mapToLoads {
205217
variable variableActivePower
206218
timeSeriesName 'myTimeSeries'
207-
filter {load.id=='CONSO_1'}
219+
filter { load.id=='CONSO_1' }
208220
}
209221
```
210222

211223
Mapping on the load of a whole region (with custom IIDM properties `region`):
212224
```groovy
213225
mapToLoads {
214226
timeSeriesName '15_fr_LOAD'
215-
filter {substation.region=='15_fr'}
216-
distributionKey { load.p0}
227+
filter { substation.region=='15_fr' }
228+
distributionKey { load.p0 }
217229
}
218230
```
219231

220232
Mapping on breakers:
221233
```groovy
222234
mapToBreakers {
223235
timeSeriesName 'ARD_CT2018_PRATCP6'
224-
filter {breaker.id == 'PRATCP6_PRATC 6COUPL DJ'}
236+
filter { breaker.id == 'PRATCP6_PRATC 6COUPL DJ' }
225237
}
226238
```
227239

228240
Mapping on Phase Tap Shifters:
229241
```groovy
230242
mapToPhaseTapChangers {
231243
timeSeriesName 'N1_TD'
232-
filter {twoWindingsTransformer.id == 'TD_1'}
244+
filter { twoWindingsTransformer.id == 'TD_1' }
233245
}
234246
```
235247

@@ -257,8 +269,8 @@ Mapping on multiple items (HVDC)
257269
```groovy
258270
mapToHvdcLines {
259271
timeSeriesName 'HVDC.DE32DE34'
260-
filter {hvdcLine.id == 'BRUN_GROS' || hvdcLine.id == 'WILS_GRAFEN'}
261-
distributionKey {1}
272+
filter { hvdcLine.id == 'BRUN_GROS' || hvdcLine.id == 'WILS_GRAFEN' }
273+
distributionKey { 1 }
262274
}
263275
```
264276

@@ -297,4 +309,4 @@ The use of the option `--equipment-time-series-dir` (with required associated op
297309
### Network variant generation
298310

299311
The use of the option `--network-output-dir` (with required associated options `--check-equipment-time-series` and `--check-versions`) produces as many IIDM network files as time steps we have in the input time series (with filtering by `--check-versions`, `--first-variant` and `--max-variant-count` options).
300-
Each le m will have the template name `<network_id>_<version>_<YYYYMMDD>_<HHmm>.iidm` and is the network generated with values mapped at indicated time step.
312+
Each produced file has the template name `<network_id>_<version>_<YYYYMMDD>_<HHmm>.xiidm` and is the network generated with values mapped at indicated time step.

0 commit comments

Comments
 (0)