This example notebook is a supplement to the ANDES tutorial. Make sure you have read the tutorial on using the CLI first.
A brief version can be found at https://github.com/cuihantao/andes/blob/master/README.md#run-simulations
!
magic in iPython¶This example shows how to use the ANDES CLI from Jupyter Notebook.
It is based on the iPython magic !
.
To run a command from within IPython or Jupyter, place a !
immediately before the command.
Conversely, all commands demonstrated in this notebook can be used in a terminal/shell by removing the preceeding !
sign.
# !conda install -c msys2 -n base --yes m2-base
For example, to list the directory , use !ls
. This is equivalent to executing ls
from the terminal.
!ls
'10. load-frequency-control.ipynb' demonstration '1. simulate_and_plot.ipynb' ieee14_out.lst '2. inspect_data.ipynb' ieee14_out.npz '3. eigenvalue.ipynb' kundur_full_out_1.png '4. inspect_models.ipynb' kundur_full_out.lst '5. profiling.ipynb' kundur_full_out.npz '6. using-cli-from-notebook.ipynb' kundur_full_out.txt '7. parallel-simulation.ipynb' kundur_out.lst '8. change-setpoints.ipynb' kundur_out.npz '9. batch-processing.ipynb' kundur_out.txt batch_cases verification
Likewise, to run andes
, use !andes
. Addition arguments can be passed as usual.
!andes
_ _ | Version 1.4.2.post116.dev0+g832274a7 /_\ _ _ __| |___ ___ | Python 3.9.6 on Linux, 09/26/2021 05:41:52 PM / _ \| ' \/ _` / -_|_-< | /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY. usage: andes [-h] [-v {1,10,20,30,40}] {run,plot,doc,misc,prepare,prep,selftest,st,demo} ... positional arguments: {run,plot,doc,misc,prepare,prep,selftest,st,demo} [run] run simulation routine; [plot] plot results; [doc] quick documentation; [misc] misc. functions; [prepare] prepare the numerical code; [selftest] run self test; [demo] show demos. optional arguments: -h, --help show this help message and exit -v {1,10,20,30,40}, --verbose {1,10,20,30,40} Verbosity level in 10-DEBUG, 20-INFO, 30-WARNING, or 40-ERROR.
Pass the path to the case file and other arguments to andes from the command line as follows.
!andes run ../andes/cases/kundur/kundur_full.xlsx -r tds
_ _ | Version 1.4.2.post116.dev0+g832274a7 /_\ _ _ __| |___ ___ | Python 3.9.6 on Linux, 09/26/2021 05:41:53 PM / _ \| ' \/ _` / -_|_-< | /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY. Working directory: "/home/hcui7/repos/andes/examples" Loaded config from file "/home/hcui7/.andes/andes.rc" Loaded generated Python code in "~/.andes/pycode". Parsing input file "../andes/cases/kundur/kundur_full.xlsx"... Input file parsed in 0.4932 seconds. System internal structure set up in 0.0352 seconds. -> System connectivity check results: No islanded bus detected. A total of 1 island(s) detected. Each island has a slack bus correctly defined and enabled. -> Power flow calculation Sparse solver: KLU Solution method: NR method Sparse addition: Fast in-place (kvxopt) Power flow initialized. 0: |F(x)| = 14.9282832 1: |F(x)| = 3.608627841 2: |F(x)| = 0.1701107882 3: |F(x)| = 0.002038626956 4: |F(x)| = 3.745103977e-07 Converged in 5 iterations in 0.0077 seconds. Report saved to "kundur_full_out.txt" in 0.0013 seconds. -> Time Domain Simulation Summary: Sparse Solver: KLU Simulation time: 0-20.0 s. Fixed step size: h=33.33 ms. Shrink if not converged. Initialization for dynamics was successful in 0.0222 seconds. <Toggler 1>: Line.Line_8 status changed to 0 at t=2.0 sec. 100%|████████████████████████████████| 100/100 [00:02<00:00, 40.29%/s] Simulation completed in 2.4819 seconds. Outputs to "kundur_full_out.lst" and "kundur_full_out.npz". Outputs written in 0.0386 seconds. -> Single process finished in 3.3971 seconds.
Case file names can be separated from the path, which can be passed to -p
. The above command is equivanent to
!andes run kundur_full.xlsx -p "../andes/cases/kundur/" -r tds
_ _ | Version 1.4.2.post116.dev0+g832274a7 /_\ _ _ __| |___ ___ | Python 3.9.6 on Linux, 09/26/2021 05:41:57 PM / _ \| ' \/ _` / -_|_-< | /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY. Working directory: "/home/hcui7/repos/andes/examples" Loaded config from file "/home/hcui7/.andes/andes.rc" Loaded generated Python code in "~/.andes/pycode". Parsing input file "../andes/cases/kundur/kundur_full.xlsx"... Input file parsed in 0.5879 seconds. System internal structure set up in 0.0417 seconds. -> System connectivity check results: No islanded bus detected. A total of 1 island(s) detected. Each island has a slack bus correctly defined and enabled. -> Power flow calculation Sparse solver: KLU Solution method: NR method Sparse addition: Fast in-place (kvxopt) Power flow initialized. 0: |F(x)| = 14.9282832 1: |F(x)| = 3.608627841 2: |F(x)| = 0.1701107882 3: |F(x)| = 0.002038626956 4: |F(x)| = 3.745103977e-07 Converged in 5 iterations in 0.0057 seconds. Report saved to "kundur_full_out.txt" in 0.0025 seconds. -> Time Domain Simulation Summary: Sparse Solver: KLU Simulation time: 0-20.0 s. Fixed step size: h=33.33 ms. Shrink if not converged. Initialization for dynamics was successful in 0.0208 seconds. <Toggler 1>: Line.Line_8 status changed to 0 at t=2.0 sec. 100%|████████████████████████████████| 100/100 [00:01<00:00, 56.43%/s] Simulation completed in 1.7721 seconds. Outputs to "kundur_full_out.lst" and "kundur_full_out.npz". Outputs written in 0.0345 seconds. -> Single process finished in 2.8082 seconds.
!pwd
/home/hcui7/repos/andes/examples
import os
os.path.isfile('../andes/cases/kundur/kundur_full.xlsx')
True
To run a simulation using PSS/E raw and dyr files, pass the dyr file to argument --addfile
.
For example:
!andes run ../andes/cases/kundur/kundur.raw --addfile ../andes/cases/kundur/kundur_full.dyr -r tds
_ _ | Version 1.4.2.post116.dev0+g832274a7 /_\ _ _ __| |___ ___ | Python 3.9.6 on Linux, 09/26/2021 05:42:01 PM / _ \| ' \/ _` / -_|_-< | /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY. Working directory: "/home/hcui7/repos/andes/examples" Loaded config from file "/home/hcui7/.andes/andes.rc" Loaded generated Python code in "~/.andes/pycode". Parsing input file "../andes/cases/kundur/kundur.raw"... MODIFIED KUNDUR'S TWO-AREA TEST SYSTEM, DISTRIBUTED WITH ANDES SEE THE BOOK "POWER SYSTEM STABILITY AND CONTROL" FOR ORIGINAL DATA Input file parsed in 0.0021 seconds. Parsing additional file "../andes/cases/kundur/kundur_full.dyr"... Addfile parsed in 0.2092 seconds. System internal structure set up in 0.0216 seconds. -> System connectivity check results: No islanded bus detected. A total of 1 island(s) detected. Each island has a slack bus correctly defined and enabled. -> Power flow calculation Sparse solver: KLU Solution method: NR method Sparse addition: Fast in-place (kvxopt) Power flow initialized. 0: |F(x)| = 3.175850023 1: |F(x)| = 3.176155228e-08 Converged in 2 iterations in 0.0021 seconds. Report saved to "kundur_out.txt" in 0.0009 seconds. -> Time Domain Simulation Summary: Sparse Solver: KLU Simulation time: 0-20.0 s. Fixed step size: h=33.33 ms. Shrink if not converged. Initialization for dynamics was successful in 0.0195 seconds. <Toggler Toggler_1>: Line.Line_8 status changed to 0 at t=2.0 sec. 100%|████████████████████████████████| 100/100 [00:01<00:00, 73.88%/s] Simulation completed in 1.3536 seconds. Outputs to "kundur_out.lst" and "kundur_out.npz". Outputs written in 0.0328 seconds. -> Single process finished in 1.7896 seconds.
lst
file¶!cat kundur_full_out.lst
0, Time [s], Time [s] 1, delta GENROU 1, $\delta$ GENROU 1 2, delta GENROU 2, $\delta$ GENROU 2 3, delta GENROU 3, $\delta$ GENROU 3 4, delta GENROU 4, $\delta$ GENROU 4 5, omega GENROU 1, $\omega$ GENROU 1 6, omega GENROU 2, $\omega$ GENROU 2 7, omega GENROU 3, $\omega$ GENROU 3 8, omega GENROU 4, $\omega$ GENROU 4 9, e1q GENROU 1, $e'_q$ GENROU 1 10, e1q GENROU 2, $e'_q$ GENROU 2 11, e1q GENROU 3, $e'_q$ GENROU 3 12, e1q GENROU 4, $e'_q$ GENROU 4 13, e1d GENROU 1, $e'_d$ GENROU 1 14, e1d GENROU 2, $e'_d$ GENROU 2 15, e1d GENROU 3, $e'_d$ GENROU 3 16, e1d GENROU 4, $e'_d$ GENROU 4 17, e2d GENROU 1, $e''_d$ GENROU 1 18, e2d GENROU 2, $e''_d$ GENROU 2 19, e2d GENROU 3, $e''_d$ GENROU 3 20, e2d GENROU 4, $e''_d$ GENROU 4 21, e2q GENROU 1, $e''_q$ GENROU 1 22, e2q GENROU 2, $e''_q$ GENROU 2 23, e2q GENROU 3, $e''_q$ GENROU 3 24, e2q GENROU 4, $e''_q$ GENROU 4 25, LAG_y TGOV1 1, $y_{LAG}$ TGOV1 1 26, LAG_y TGOV1 2, $y_{LAG}$ TGOV1 2 27, LAG_y TGOV1 3, $y_{LAG}$ TGOV1 3 28, LAG_y TGOV1 4, $y_{LAG}$ TGOV1 4 29, LL_x TGOV1 1, $x'_{LL}$ TGOV1 1 30, LL_x TGOV1 2, $x'_{LL}$ TGOV1 2 31, LL_x TGOV1 3, $x'_{LL}$ TGOV1 3 32, LL_x TGOV1 4, $x'_{LL}$ TGOV1 4 33, vp EXDC2 1, $V_p$ EXDC2 1 34, vp EXDC2 2, $V_p$ EXDC2 2 35, vp EXDC2 3, $V_p$ EXDC2 3 36, vp EXDC2 4, $V_p$ EXDC2 4 37, LS_y EXDC2 1, $y_{LS}$ EXDC2 1 38, LS_y EXDC2 2, $y_{LS}$ EXDC2 2 39, LS_y EXDC2 3, $y_{LS}$ EXDC2 3 40, LS_y EXDC2 4, $y_{LS}$ EXDC2 4 41, LL_x EXDC2 1, $x'_{LL}$ EXDC2 1 42, LL_x EXDC2 2, $x'_{LL}$ EXDC2 2 43, LL_x EXDC2 3, $x'_{LL}$ EXDC2 3 44, LL_x EXDC2 4, $x'_{LL}$ EXDC2 4 45, LA_y EXDC2 1, $y_{LA}$ EXDC2 1 46, LA_y EXDC2 2, $y_{LA}$ EXDC2 2 47, LA_y EXDC2 3, $y_{LA}$ EXDC2 3 48, LA_y EXDC2 4, $y_{LA}$ EXDC2 4 49, W_x EXDC2 1, $x'_{W}$ EXDC2 1 50, W_x EXDC2 2, $x'_{W}$ EXDC2 2 51, W_x EXDC2 3, $x'_{W}$ EXDC2 3 52, W_x EXDC2 4, $x'_{W}$ EXDC2 4 53, a Bus 1, $\theta$ Bus 1 54, a Bus 2, $\theta$ Bus 2 55, a Bus 3, $\theta$ Bus 3 56, a Bus 4, $\theta$ Bus 4 57, a Bus 5, $\theta$ Bus 5 58, a Bus 6, $\theta$ Bus 6 59, a Bus 7, $\theta$ Bus 7 60, a Bus 8, $\theta$ Bus 8 61, a Bus 9, $\theta$ Bus 9 62, a Bus 10, $\theta$ Bus 10 63, v Bus 1, $V$ Bus 1 64, v Bus 2, $V$ Bus 2 65, v Bus 3, $V$ Bus 3 66, v Bus 4, $V$ Bus 4 67, v Bus 5, $V$ Bus 5 68, v Bus 6, $V$ Bus 6 69, v Bus 7, $V$ Bus 7 70, v Bus 8, $V$ Bus 8 71, v Bus 9, $V$ Bus 9 72, v Bus 10, $V$ Bus 10 73, p PV 2, $p$ PV 2 74, p PV 3, $p$ PV 3 75, p PV 4, $p$ PV 4 76, q PV 2, $q$ PV 2 77, q PV 3, $q$ PV 3 78, q PV 4, $q$ PV 4 79, p Slack 1, $p$ Slack 1 80, q Slack 1, $q$ Slack 1 81, Id GENROU 1, $I_d$ GENROU 1 82, Id GENROU 2, $I_d$ GENROU 2 83, Id GENROU 3, $I_d$ GENROU 3 84, Id GENROU 4, $I_d$ GENROU 4 85, Iq GENROU 1, $I_q$ GENROU 1 86, Iq GENROU 2, $I_q$ GENROU 2 87, Iq GENROU 3, $I_q$ GENROU 3 88, Iq GENROU 4, $I_q$ GENROU 4 89, vd GENROU 1, $V_d$ GENROU 1 90, vd GENROU 2, $V_d$ GENROU 2 91, vd GENROU 3, $V_d$ GENROU 3 92, vd GENROU 4, $V_d$ GENROU 4 93, vq GENROU 1, $V_q$ GENROU 1 94, vq GENROU 2, $V_q$ GENROU 2 95, vq GENROU 3, $V_q$ GENROU 3 96, vq GENROU 4, $V_q$ GENROU 4 97, tm GENROU 1, $\tau_m$ GENROU 1 98, tm GENROU 2, $\tau_m$ GENROU 2 99, tm GENROU 3, $\tau_m$ GENROU 3 100, tm GENROU 4, $\tau_m$ GENROU 4 101, te GENROU 1, $\tau_e$ GENROU 1 102, te GENROU 2, $\tau_e$ GENROU 2 103, te GENROU 3, $\tau_e$ GENROU 3 104, te GENROU 4, $\tau_e$ GENROU 4 105, vf GENROU 1, $v_f$ GENROU 1 106, vf GENROU 2, $v_f$ GENROU 2 107, vf GENROU 3, $v_f$ GENROU 3 108, vf GENROU 4, $v_f$ GENROU 4 109, XadIfd GENROU 1, $X_{ad}I_{fd}$ GENROU 1 110, XadIfd GENROU 2, $X_{ad}I_{fd}$ GENROU 2 111, XadIfd GENROU 3, $X_{ad}I_{fd}$ GENROU 3 112, XadIfd GENROU 4, $X_{ad}I_{fd}$ GENROU 4 113, Pe GENROU 1, $P_e$ GENROU 1 114, Pe GENROU 2, $P_e$ GENROU 2 115, Pe GENROU 3, $P_e$ GENROU 3 116, Pe GENROU 4, $P_e$ GENROU 4 117, Qe GENROU 1, $Q_e$ GENROU 1 118, Qe GENROU 2, $Q_e$ GENROU 2 119, Qe GENROU 3, $Q_e$ GENROU 3 120, Qe GENROU 4, $Q_e$ GENROU 4 121, psid GENROU 1, $\psi_d$ GENROU 1 122, psid GENROU 2, $\psi_d$ GENROU 2 123, psid GENROU 3, $\psi_d$ GENROU 3 124, psid GENROU 4, $\psi_d$ GENROU 4 125, psiq GENROU 1, $\psi_q$ GENROU 1 126, psiq GENROU 2, $\psi_q$ GENROU 2 127, psiq GENROU 3, $\psi_q$ GENROU 3 128, psiq GENROU 4, $\psi_q$ GENROU 4 129, psi2q GENROU 1, $\psi_{aq}$ GENROU 1 130, psi2q GENROU 2, $\psi_{aq}$ GENROU 2 131, psi2q GENROU 3, $\psi_{aq}$ GENROU 3 132, psi2q GENROU 4, $\psi_{aq}$ GENROU 4 133, psi2d GENROU 1, $\psi_{ad}$ GENROU 1 134, psi2d GENROU 2, $\psi_{ad}$ GENROU 2 135, psi2d GENROU 3, $\psi_{ad}$ GENROU 3 136, psi2d GENROU 4, $\psi_{ad}$ GENROU 4 137, psi2 GENROU 1, $\psi_a$ GENROU 1 138, psi2 GENROU 2, $\psi_a$ GENROU 2 139, psi2 GENROU 3, $\psi_a$ GENROU 3 140, psi2 GENROU 4, $\psi_a$ GENROU 4 141, Se GENROU 1, $S_e(|\psi_{a}|)$ GENROU 1 142, Se GENROU 2, $S_e(|\psi_{a}|)$ GENROU 2 143, Se GENROU 3, $S_e(|\psi_{a}|)$ GENROU 3 144, Se GENROU 4, $S_e(|\psi_{a}|)$ GENROU 4 145, XaqI1q GENROU 1, $X_{aq}I_{1q}$ GENROU 1 146, XaqI1q GENROU 2, $X_{aq}I_{1q}$ GENROU 2 147, XaqI1q GENROU 3, $X_{aq}I_{1q}$ GENROU 3 148, XaqI1q GENROU 4, $X_{aq}I_{1q}$ GENROU 4 149, paux TGOV1 1, $P_{aux}$ TGOV1 1 150, paux TGOV1 2, $P_{aux}$ TGOV1 2 151, paux TGOV1 3, $P_{aux}$ TGOV1 3 152, paux TGOV1 4, $P_{aux}$ TGOV1 4 153, pout TGOV1 1, $P_{out}$ TGOV1 1 154, pout TGOV1 2, $P_{out}$ TGOV1 2 155, pout TGOV1 3, $P_{out}$ TGOV1 3 156, pout TGOV1 4, $P_{out}$ TGOV1 4 157, wref TGOV1 1, $\omega_{ref}$ TGOV1 1 158, wref TGOV1 2, $\omega_{ref}$ TGOV1 2 159, wref TGOV1 3, $\omega_{ref}$ TGOV1 3 160, wref TGOV1 4, $\omega_{ref}$ TGOV1 4 161, pref TGOV1 1, $P_{ref}$ TGOV1 1 162, pref TGOV1 2, $P_{ref}$ TGOV1 2 163, pref TGOV1 3, $P_{ref}$ TGOV1 3 164, pref TGOV1 4, $P_{ref}$ TGOV1 4 165, wd TGOV1 1, $\omega_{dev}$ TGOV1 1 166, wd TGOV1 2, $\omega_{dev}$ TGOV1 2 167, wd TGOV1 3, $\omega_{dev}$ TGOV1 3 168, wd TGOV1 4, $\omega_{dev}$ TGOV1 4 169, pd TGOV1 1, $P_d$ TGOV1 1 170, pd TGOV1 2, $P_d$ TGOV1 2 171, pd TGOV1 3, $P_d$ TGOV1 3 172, pd TGOV1 4, $P_d$ TGOV1 4 173, LL_y TGOV1 1, $y_{LL}$ TGOV1 1 174, LL_y TGOV1 2, $y_{LL}$ TGOV1 2 175, LL_y TGOV1 3, $y_{LL}$ TGOV1 3 176, LL_y TGOV1 4, $y_{LL}$ TGOV1 4 177, vout EXDC2 1, $v_{out}$ EXDC2 1 178, vout EXDC2 2, $v_{out}$ EXDC2 2 179, vout EXDC2 3, $v_{out}$ EXDC2 3 180, vout EXDC2 4, $v_{out}$ EXDC2 4 181, vref EXDC2 1, $V_{ref}$ EXDC2 1 182, vref EXDC2 2, $V_{ref}$ EXDC2 2 183, vref EXDC2 3, $V_{ref}$ EXDC2 3 184, vref EXDC2 4, $V_{ref}$ EXDC2 4 185, Se EXDC2 1, $S_e(|V_{out}|)$ EXDC2 1 186, Se EXDC2 2, $S_e(|V_{out}|)$ EXDC2 2 187, Se EXDC2 3, $S_e(|V_{out}|)$ EXDC2 3 188, Se EXDC2 4, $S_e(|V_{out}|)$ EXDC2 4 189, vi EXDC2 1, $V_i$ EXDC2 1 190, vi EXDC2 2, $V_i$ EXDC2 2 191, vi EXDC2 3, $V_i$ EXDC2 3 192, vi EXDC2 4, $V_i$ EXDC2 4 193, LL_y EXDC2 1, $y_{LL}$ EXDC2 1 194, LL_y EXDC2 2, $y_{LL}$ EXDC2 2 195, LL_y EXDC2 3, $y_{LL}$ EXDC2 3 196, LL_y EXDC2 4, $y_{LL}$ EXDC2 4 197, W_y EXDC2 1, $y_{W}$ EXDC2 1 198, W_y EXDC2 2, $y_{W}$ EXDC2 2 199, W_y EXDC2 3, $y_{W}$ EXDC2 3 200, W_y EXDC2 4, $y_{W}$ EXDC2 4 201, vcmp_zi PQ 0, $vcmp$ PQ 0 202, vcmp_zi PQ 1, $vcmp$ PQ 1 203, vcmp_zl PQ 0, $vcmp$ PQ 0 204, vcmp_zl PQ 1, $vcmp$ PQ 1 205, vcmp_zu PQ 0, $vcmp$ PQ 0 206, vcmp_zu PQ 1, $vcmp$ PQ 1 207, qlim_zi PV 2, $qlim$ PV 2 208, qlim_zi PV 3, $qlim$ PV 3 209, qlim_zi PV 4, $qlim$ PV 4 210, qlim_zl PV 2, $qlim$ PV 2 211, qlim_zl PV 3, $qlim$ PV 3 212, qlim_zl PV 4, $qlim$ PV 4 213, qlim_zu PV 2, $qlim$ PV 2 214, qlim_zu PV 3, $qlim$ PV 3 215, qlim_zu PV 4, $qlim$ PV 4 216, qlim_ql PV 2, $qlim$ PV 2 217, qlim_ql PV 3, $qlim$ PV 3 218, qlim_ql PV 4, $qlim$ PV 4 219, qlim_qu PV 2, $qlim$ PV 2 220, qlim_qu PV 3, $qlim$ PV 3 221, qlim_qu PV 4, $qlim$ PV 4 222, qlim_zi Slack 1, $qlim$ Slack 1 223, qlim_zl Slack 1, $qlim$ Slack 1 224, qlim_zu Slack 1, $qlim$ Slack 1 225, qlim_ql Slack 1, $qlim$ Slack 1 226, qlim_qu Slack 1, $qlim$ Slack 1 227, plim_zi Slack 1, $plim$ Slack 1 228, plim_zl Slack 1, $plim$ Slack 1 229, plim_zu Slack 1, $plim$ Slack 1 230, plim_ql Slack 1, $plim$ Slack 1 231, plim_qu Slack 1, $plim$ Slack 1 232, SL_z0 GENROU 1, $SL$ GENROU 1 233, SL_z0 GENROU 2, $SL$ GENROU 2 234, SL_z0 GENROU 3, $SL$ GENROU 3 235, SL_z0 GENROU 4, $SL$ GENROU 4 236, SL_z1 GENROU 1, $SL$ GENROU 1 237, SL_z1 GENROU 2, $SL$ GENROU 2 238, SL_z1 GENROU 3, $SL$ GENROU 3 239, SL_z1 GENROU 4, $SL$ GENROU 4 240, LAG_lim_zi TGOV1 1, $lim_{LAG}$ TGOV1 1 241, LAG_lim_zi TGOV1 2, $lim_{LAG}$ TGOV1 2 242, LAG_lim_zi TGOV1 3, $lim_{LAG}$ TGOV1 3 243, LAG_lim_zi TGOV1 4, $lim_{LAG}$ TGOV1 4 244, LAG_lim_zl TGOV1 1, $lim_{LAG}$ TGOV1 1 245, LAG_lim_zl TGOV1 2, $lim_{LAG}$ TGOV1 2 246, LAG_lim_zl TGOV1 3, $lim_{LAG}$ TGOV1 3 247, LAG_lim_zl TGOV1 4, $lim_{LAG}$ TGOV1 4 248, LAG_lim_zu TGOV1 1, $lim_{LAG}$ TGOV1 1 249, LAG_lim_zu TGOV1 2, $lim_{LAG}$ TGOV1 2 250, LAG_lim_zu TGOV1 3, $lim_{LAG}$ TGOV1 3 251, LAG_lim_zu TGOV1 4, $lim_{LAG}$ TGOV1 4 252, LL_LT1_z0 TGOV1 1, $LT_{LL}$ TGOV1 1 253, LL_LT1_z0 TGOV1 2, $LT_{LL}$ TGOV1 2 254, LL_LT1_z0 TGOV1 3, $LT_{LL}$ TGOV1 3 255, LL_LT1_z0 TGOV1 4, $LT_{LL}$ TGOV1 4 256, LL_LT1_z1 TGOV1 1, $LT_{LL}$ TGOV1 1 257, LL_LT1_z1 TGOV1 2, $LT_{LL}$ TGOV1 2 258, LL_LT1_z1 TGOV1 3, $LT_{LL}$ TGOV1 3 259, LL_LT1_z1 TGOV1 4, $LT_{LL}$ TGOV1 4 260, LL_LT2_z0 TGOV1 1, $LT_{LL}$ TGOV1 1 261, LL_LT2_z0 TGOV1 2, $LT_{LL}$ TGOV1 2 262, LL_LT2_z0 TGOV1 3, $LT_{LL}$ TGOV1 3 263, LL_LT2_z0 TGOV1 4, $LT_{LL}$ TGOV1 4 264, LL_LT2_z1 TGOV1 1, $LT_{LL}$ TGOV1 1 265, LL_LT2_z1 TGOV1 2, $LT_{LL}$ TGOV1 2 266, LL_LT2_z1 TGOV1 3, $LT_{LL}$ TGOV1 3 267, LL_LT2_z1 TGOV1 4, $LT_{LL}$ TGOV1 4 268, SL_z0 EXDC2 1, $SL$ EXDC2 1 269, SL_z0 EXDC2 2, $SL$ EXDC2 2 270, SL_z0 EXDC2 3, $SL$ EXDC2 3 271, SL_z0 EXDC2 4, $SL$ EXDC2 4 272, SL_z1 EXDC2 1, $SL$ EXDC2 1 273, SL_z1 EXDC2 2, $SL$ EXDC2 2 274, SL_z1 EXDC2 3, $SL$ EXDC2 3 275, SL_z1 EXDC2 4, $SL$ EXDC2 4 276, LL_LT1_z0 EXDC2 1, $LT_{LL}$ EXDC2 1 277, LL_LT1_z0 EXDC2 2, $LT_{LL}$ EXDC2 2 278, LL_LT1_z0 EXDC2 3, $LT_{LL}$ EXDC2 3 279, LL_LT1_z0 EXDC2 4, $LT_{LL}$ EXDC2 4 280, LL_LT1_z1 EXDC2 1, $LT_{LL}$ EXDC2 1 281, LL_LT1_z1 EXDC2 2, $LT_{LL}$ EXDC2 2 282, LL_LT1_z1 EXDC2 3, $LT_{LL}$ EXDC2 3 283, LL_LT1_z1 EXDC2 4, $LT_{LL}$ EXDC2 4 284, LL_LT2_z0 EXDC2 1, $LT_{LL}$ EXDC2 1 285, LL_LT2_z0 EXDC2 2, $LT_{LL}$ EXDC2 2 286, LL_LT2_z0 EXDC2 3, $LT_{LL}$ EXDC2 3 287, LL_LT2_z0 EXDC2 4, $LT_{LL}$ EXDC2 4 288, LL_LT2_z1 EXDC2 1, $LT_{LL}$ EXDC2 1 289, LL_LT2_z1 EXDC2 2, $LT_{LL}$ EXDC2 2 290, LL_LT2_z1 EXDC2 3, $LT_{LL}$ EXDC2 3 291, LL_LT2_z1 EXDC2 4, $LT_{LL}$ EXDC2 4 292, LA_lim_zi EXDC2 1, $lim_{LA}$ EXDC2 1 293, LA_lim_zi EXDC2 2, $lim_{LA}$ EXDC2 2 294, LA_lim_zi EXDC2 3, $lim_{LA}$ EXDC2 3 295, LA_lim_zi EXDC2 4, $lim_{LA}$ EXDC2 4 296, LA_lim_zl EXDC2 1, $lim_{LA}$ EXDC2 1 297, LA_lim_zl EXDC2 2, $lim_{LA}$ EXDC2 2 298, LA_lim_zl EXDC2 3, $lim_{LA}$ EXDC2 3 299, LA_lim_zl EXDC2 4, $lim_{LA}$ EXDC2 4 300, LA_lim_zu EXDC2 1, $lim_{LA}$ EXDC2 1 301, LA_lim_zu EXDC2 2, $lim_{LA}$ EXDC2 2 302, LA_lim_zu EXDC2 3, $lim_{LA}$ EXDC2 3 303, LA_lim_zu EXDC2 4, $lim_{LA}$ EXDC2 4
We found a limitation of using andes plot
from within Notebook/iPython. The figure won't be displayed correctly. The workaround is to save the image as a file and display it from the notebook.
Please let us know if you have better solutions.
!andes plot kundur_full_out.lst 0 5 6 --save
Figure saved to "kundur_full_out_1.png". Figure(640x480)
from IPython.display import Image
Image("kundur_full_out_1.png")
xargs
for index loop up¶A convenient tool in Linux/macOS is xargs
, which turns the standard output of one program into arguments for another.
andes plot --xargs
accepts an input of search pattern for variable names and returns a list of arguments, including the matched indices, that can be understood by andes plot
.
A convenient tool in Linux/macOS/Windows with MSYS2 is xargs
, which turns the standard output of one program into arguments for another.
andes plot --xargs
accepts an input of search pattern for variable names and returns a list of arguments, including the matched indices, that can be understood by andes plot
.
xargs
for index lookup¶A convenient tool in Linux/macOS is xargs
, which turns the standard output of one program into arguments for another.
andes plot --xargs
accepts an input of search pattern for variable names and returns a list of arguments, including the matched indices, that can be understood by andes plot
.
To illustrate, let's look at an example output of andes plot --xargs
.
!andes plot kundur_full_out.lst --xargs "omega GENROU"
Traceback (most recent call last): File "/home/hcui7/mambaforge/envs/a/bin/andes", line 33, in <module> sys.exit(load_entry_point('andes', 'console_scripts', 'andes')()) File "/home/hcui7/repos/andes/andes/cli.py", line 210, in main return func(cli=True, **vars(args)) File "/home/hcui7/repos/andes/andes/main.py", line 664, in plot tdsplot(**kwargs) File "/home/hcui7/repos/andes/andes/plot.py", line 941, in tdsplot tds_data = TDSData(filename[0]) File "/home/hcui7/repos/andes/andes/plot.py", line 49, in __init__ self.load_lst() File "/home/hcui7/repos/andes/andes/plot.py", line 102, in load_lst with open(self._lst_file, 'r') as fd: FileNotFoundError: [Errno 2] No such file or directory: '/home/hcui7/repos/andes/examples/kundur_full_out.lst'
The output consists of the lst file name, the default x-axis index 0
, and the indices for the found variables. The full output can be passed to andes plot
without modification.
We use the following command to pass the arguments:
!andes plot kundur_full_out.lst --xargs "omega GENROU" | xargs andes plot
Traceback (most recent call last): File "/home/hcui7/mambaforge/envs/a/bin/andes", line 33, in <module> sys.exit(load_entry_point('andes', 'console_scripts', 'andes')()) File "/home/hcui7/repos/andes/andes/cli.py", line 210, in main return func(cli=True, **vars(args)) File "/home/hcui7/repos/andes/andes/main.py", line 664, in plot tdsplot(**kwargs) File "/home/hcui7/repos/andes/andes/plot.py", line 941, in tdsplot tds_data = TDSData(filename[0]) File "/home/hcui7/repos/andes/andes/plot.py", line 49, in __init__ self.load_lst() File "/home/hcui7/repos/andes/andes/plot.py", line 102, in load_lst with open(self._lst_file, 'r') as fd: FileNotFoundError: [Errno 2] No such file or directory: '/home/hcui7/repos/andes/examples/kundur_full_out.lst' usage: andes plot [-h] [--xmin LEFT] [--xmax RIGHT] [--ymax YMAX] [--ymin YMIN] [--find FIND | -a XARGS] [--exclude EXCLUDE] [-x XLABEL] [-y YLABEL] [-s] [-f SAVE_FORMAT] [--dpi DPI] [--font-size FONT_SIZE] [--line-width LINE_WIDTH] [-g] [-t TITLE] [--greyscale] [-d] [-n] [--ytimes YTIMES] [-c] [--hline1 HLINE1] [--hline2 HLINE2] [--vline1 VLINE1] [--vline2 VLINE2] filename [x] [y ...] andes plot: error: the following arguments are required: filename, y
where |
is the pipe operator in shell for piping the standard output of the left-hand side to the right-hand side, xargs
captures the pipe-in and appends it to andes plot
.
The command is equivalent to manually running
!andes plot kundur_full_out.lst 5 6 7 8
Figure saved to "kundur_full_out_3.png". Figure(640x480)
Remove the saved png
image files.
!rm -v *.png
removed 'kundur_full_out_1.png' removed 'kundur_full_out_2.png' removed 'kundur_full_out_3.png'
!andes misc -C
_ _ | Version 1.4.2.post116.dev0+g832274a7 /_\ _ _ __| |___ ___ | Python 3.9.6 on Linux, 09/26/2021 05:42:08 PM / _ \| ' \/ _` / -_|_-< | /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY. "/home/hcui7/repos/andes/examples/kundur_full_out.npz" removed. "/home/hcui7/repos/andes/examples/kundur_full_out.lst" removed.