Skip to content

cli

plot()

Plotting utilities for PROCESS

Source code in process/core/io/plot/cli.py
18
19
20
21
22
23
24
@click.group(
    cls=LazyGroup,
    lazy_subcommands={"costs": "process.core.io.plot.costs.cli.costs"},
)
@help_opt
def plot():
    """Plotting utilities for PROCESS"""

sankey(mfile, format_)

Plot the power flow in PROCESS using a Sankey diagram.

Source code in process/core/io/plot/cli.py
27
28
29
30
31
32
33
34
35
36
37
38
@plot.command("sankey", no_args_is_help=True)
@help_opt
@mfile_opt(exists=True)
@click.option("-fmt", "--format", "format_", default="pdf", help="file format")
def sankey(mfile, format_):
    """Plot the power flow in PROCESS using a Sankey diagram."""
    if format_ in {"html", "plotly"}:
        out = plot_sankey_plotly(mfile)
        if out is not None:
            return out

    return plot_sankey(mfile, format_=format_)

plot_scans_cli(mfiles, output_names, output_names2, outputdir, term_output, save_format, axis_font_size, axis_tick_size, x_axis_percent, x_axis_max, x_axis_range, y_axis_percent, y_axis_percent2, y_axis_max, y_axis2_max, y_axis_range, y_axis_range2, label_name, twod_contour, stack_plots)

Plot optimisation information

Source code in process/core/io/plot/cli.py
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
@plot.command("scans", no_args_is_help=True)
@help_opt
@mfile_arg
# At least one output variable must be supplied in order to plot
@click.option(
    "-yv",
    "--y-vars",
    "output_names",
    callback=split_callback,
    required=True,
    help=(
        "Select the output variables\nMore than one output can be plotted "
        "eg: -yv 'var1:var2'\nA separate plot will be created for each "
        "inputs"
    ),
)
@click.option(
    "-yv2",
    "--y-vars2",
    "output_names2",
    callback=split_callback,
    default="",
    help=(
        "Select the 2nd axis output variable\n "
        "eg: -yv2 'var'\n 2nd variable will be plotted on shared figure "
        "inputs"
    ),
)
@click.option(
    "-o",
    "--outputdir",
    default=Path.cwd(),
    type=click.Path(path_type=Path),
    help="Output directory for plots, defaults to current working directory.",
)
@click.option(
    "-out",
    "--term-output",
    is_flag=True,
    help="Option to show scans values on terminal",
)
@click.option(
    "-sf",
    "--save-format",
    default="pdf",
    help="Output format (default='pdf') ",
)
@click.option(
    "-afs",
    "--axis-font-size",
    default=18,
    help="Axis label font size selection (default=18)",
    type=int,
)
@click.option(
    "-ats",
    "--axis-tick-size",
    default=16,
    help="Axis tick label font size selection (default=16)",
    type=int,
)
@click.option(
    "-x%",
    "--x-axis-percent",
    is_flag=True,
    help=("Used to set the x axis ticks to percentages in place of absolute \nvalues."),
)
@click.option(
    "-xm",
    "--x-axis-max",
    callback=split_callback,
    default="",
    help=(
        "Used to set the x value corresponding to 100 percent when "
        "converting from absolute to percent values. Multiple values separated with :"
    ),
)
@click.option(
    "-xr",
    "--x-axis-range",
    callback=split_callback,
    default="",
    help=("Used to set the range for x axis"),
)
@click.option(
    "-y%",
    "--y-axis-percent",
    is_flag=True,
    help=("Used to set the y axis ticks to percentages in place of absolute \nvalues."),
)
@click.option(
    "-y2%",
    "--y-axis2-percent",
    "y_axis_percent2",
    is_flag=True,
    help=(
        "Used to set the y axis ticks to percentages in place of absolute \nvalues. For the twinned axis if present."
    ),
)
@click.option(
    "-ym",
    "--y-axis-max",
    callback=split_callback,
    default="",
    help=(
        "Used to set the y value corresponding to 100 percent when \nconverting from absolute to percent values."
    ),
)
@click.option(
    "-ym2",
    "--y-axis2-max",
    callback=split_callback,
    default="",
    help=(
        "Used to set the y value corresponding to 100 percent when \nconverting from absolute to percent values."
        "For the twinned axis if present."
    ),
)
@click.option(
    "-yr",
    "--y-axis-range",
    callback=split_callback,
    default="",
    help=("Used to set the range for y axis"),
)
@click.option(
    "-yr2",
    "--y-axis2-range",
    "y_axis_range2",
    callback=split_callback,
    default="",
    help=("Used to set the range for y axis. For the twinned axis if present."),
)
@click.option(
    "-ln",
    "--label-name",
    default="",
    callback=split_callback,
    help=(
        "Label names for plot legend. If multiple input files used then \n"
        "list the same number of label names eg: -nl 'leg1 leg2'\n"
        "(default = MFile file name) "
    ),
)
@click.option(
    "-2DC",
    "--two-dimensional-contour",
    "twod_contour",
    is_flag=True,
    help=(
        "Option to plot 2D scans as a coloured contour plot instead of a line plot \n  "
        "Note: Non convergent points will show up with a value of zero \n "
        "Note: The scan paramters must both be in increasing orderl \n "
    ),
)
@click.option(
    "-stc",
    "--stack-plots",
    is_flag=True,
    help=(
        "Option to plot multiple 1D plots in a column of subplots \n  "
        "Variables will be plotted in order of input"
    ),
)
def plot_scans_cli(
    mfiles,
    output_names,
    output_names2,
    outputdir,
    term_output,
    save_format,
    axis_font_size,
    axis_tick_size,
    x_axis_percent,
    x_axis_max,
    x_axis_range,
    y_axis_percent,
    y_axis_percent2,
    y_axis_max,
    y_axis2_max,
    y_axis_range,
    y_axis_range2,
    label_name,
    twod_contour,
    stack_plots,
):
    """Plot optimisation information"""
    return plot_scan(
        mfiles,
        list(filter(None, output_names)),
        list(filter(None, output_names2)),
        outputdir,
        term_output,
        save_format,
        axis_font_size,
        axis_tick_size,
        x_axis_percent,
        list(map(float, filter(None, x_axis_max))),
        list(map(float, filter(None, x_axis_range))),
        y_axis_percent,
        y_axis_percent2,
        list(map(float, filter(None, y_axis_max))),
        list(map(float, filter(None, y_axis2_max))),
        list(map(float, filter(None, y_axis_range))),
        list(map(float, filter(None, y_axis_range2))),
        label_name,
        twod_contour,
        stack_plots,
    )

plot_tf_stress(plot_selec, save_format, axis_font_size, term_output, input_file)

TF coil inboard mid-plane stress/strain summary plots

Source code in process/core/io/plot/cli.py
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
@plot.command("tf-stress", no_args_is_help=True)
@help_opt
@click.option(
    "-p",
    "--plot-selec",
    multiple=True,
    default=["all"],
    type=click.Choice(["all", "sig", "disp", "strain", "sm_sig"]),
    help="""\b
Plot selection string :
- If it containts 'sig'      -> Stress radial dependency
- If it containts 'strain'   -> Strain
- If it containts 'disp'     -> Displacement
- If it containts 'all'      -> all the mentioned plots (default value)
""",
)
@click.option(
    "-sf",
    "--save-format",
    default="pdf",
    help="output format (default='pdf') ",
)
@click.option(
    "-as",
    "--axis-font-size",
    default=18,
    help="Axis label font size selection (default=18)",
    type=int,
)
@click.option(
    "-out",
    "--term-output",
    is_flag=True,
    help="Option to show stress on terminal output",
)
@click.option(
    "-f",
    "--input-file",
    default="SIG_TF.json",
    help="specify input file path (default = SIG_TF.json)",
)
def plot_tf_stress(plot_selec, save_format, axis_font_size, term_output, input_file):
    """TF coil inboard mid-plane stress/strain summary plots"""
    plot_stress(plot_selec, save_format, axis_font_size, term_output, input_file)

plot_summary_cli(mfile, scan, demo_ranges, colour, output_format, show)

Produces a summary of the PROCESS MFILE output.

Source code in process/core/io/plot/cli.py
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
@plot.command("summary", no_args_is_help=True)
@help_opt
@mfile_opt(exists=True)
@click.option("-n", "scan", type=int, default=-1, help="Which scan to plot?")
@click.option(
    "-d",
    "--DEMO-ranges",
    "demo_ranges",
    help="Uses the DEMO dimensions as ranges for all graphics",
    is_flag=True,
)
@click.option(
    "-c",
    "--colour",
    help=(
        "Which colour scheme to use for cross-section plots\n"
        "1: Original PROCESS (default)\n"
        "2: BLUEMIRA"
    ),
    default=1,
    type=click.Choice([1, 2]),
)
@click.option(
    "-o",
    "--output-format",
    help=(
        "Output file format\npdf: pdf output (default)\npng: png output\nnone: no output file written"
    ),
    default="pdf",
    type=click.Choice(["pdf", "png", "none"]),
)
@click.option("-s", "--show", help="show plot", is_flag=True)
def plot_summary_cli(mfile, scan, demo_ranges, colour, output_format, show):
    """Produces a summary of the PROCESS MFILE output."""
    plot_summary(mfile, scan, demo_ranges, colour, output_format, show)