Using CLI from Notebook#

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

The ! 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.

Set up on Windows#

Windows users will need to install MSYS2 to support most of the Linux shell commands.

To install MSYS2-base, uncomment the following line and run it:

# !conda install -c msys2 -n base --yes m2-base

Running Shell Commands#

For example, to list the directory , use !ls. This is equivalent to executing ls from the terminal.

!ls
'10. load-frequency-control.ipynb'  '6. using-cli-from-notebook.ipynb'
'1. simulate_and_plot.ipynb'	    '7. parallel-simulation.ipynb'
'2. inspect_data.ipynb'		    '8. change-setpoints.ipynb'
'3. eigenvalue.ipynb'		    '9. batch-processing.ipynb'
'4. inspect_models.ipynb'	     demonstration
'5. profiling.ipynb'		     verification

Likewise, to run andes, use !andes. Addition arguments can be passed as usual.

!andes
    _           _         | Version 1.5.7.post27.dev0+g9e0e253e
   /_\  _ _  __| |___ ___ | Python 3.9.7 on Linux, 12/14/2021 02:51:25 PM
  / _ \| ' \/ _` / -_|_-< | 
 /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY.

usage: andes [-h] [-v {1,10,20,30,40}] [--version]
             {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.
  --version             show version info and exit

Run a simulation#

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.5.7.post27.dev0+g9e0e253e
   /_\  _ _  __| |___ ___ | Python 3.9.7 on Linux, 12/14/2021 02:51:26 PM
  / _ \| ' \/ _` / -_|_-< | 
 /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY.

Working directory: "/home/hacui/repos/andes/examples"
Loaded config from file "/home/hacui/.andes/andes.rc"
Loaded generated Python code in "/home/hacui/.andes/pycode".
Parsing input file "../andes/cases/kundur/kundur_full.xlsx"...
Input file parsed in 0.1907 seconds.
System internal structure set up in 0.0213 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
Numba compilation initiated with caching.
Power flow initialized in 0.2783 seconds.
0: |F(x)| = 14.9282832
1: |F(x)| = 3.608627841
2: |F(x)| = 3.371691245
3: |F(x)| = 3.38335788
4: |F(x)| = 1.643469337
5: |F(x)| = 0.2341714002
6: |F(x)| = 0.03397375079
7: |F(x)| = 0.0009863888463
8: |F(x)| = 1.354810848e-06
9: |F(x)| = 2.629008122e-12
Converged in 10 iterations in 0.0032 seconds.
Report saved to "kundur_full_out.txt" in 0.0004 seconds.

-> Time Domain Simulation Summary:
Sparse Solver: KLU
Simulation time: 0.0-20.0 s.
Fixed step size: h=33.33 ms. Shrink if not converged.
Numba compilation initiated with caching.
PQ.vcmp out of limits <vmin>

 idx  | Flag | Input Value | Limit
------+------+-------------+------
 PQ_1 | zl   | 0.833       | 0.900


Initialization for dynamics completed in 0.0724 seconds.
Initialization was successful.
<Toggler 1>: Line.Line_8 status changed to 0 at t=2.0 sec.            
100%|███████████████████████████████| 100/100 [00:00<00:00, 190.42%/s]
Simulation completed in 0.5252 seconds.
Outputs to "kundur_full_out.lst" and "kundur_full_out.npz".
Outputs written in 0.0172 seconds.
-> Single process finished in 1.2101 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.5.7.post27.dev0+g9e0e253e
   /_\  _ _  __| |___ ___ | Python 3.9.7 on Linux, 12/14/2021 02:51:27 PM
  / _ \| ' \/ _` / -_|_-< | 
 /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY.

Working directory: "/home/hacui/repos/andes/examples"
Loaded config from file "/home/hacui/.andes/andes.rc"
Loaded generated Python code in "/home/hacui/.andes/pycode".
Parsing input file "../andes/cases/kundur/kundur_full.xlsx"...
Input file parsed in 0.1863 seconds.
System internal structure set up in 0.0211 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
Numba compilation initiated with caching.
Power flow initialized in 0.2750 seconds.
0: |F(x)| = 14.9282832
1: |F(x)| = 3.608627841
2: |F(x)| = 3.371691245
3: |F(x)| = 3.38335788
4: |F(x)| = 1.643469337
5: |F(x)| = 0.2341714002
6: |F(x)| = 0.03397375079
7: |F(x)| = 0.0009863888463
8: |F(x)| = 1.354810848e-06
9: |F(x)| = 2.629008122e-12
Converged in 10 iterations in 0.0031 seconds.
Report saved to "kundur_full_out.txt" in 0.0005 seconds.

-> Time Domain Simulation Summary:
Sparse Solver: KLU
Simulation time: 0.0-20.0 s.
Fixed step size: h=33.33 ms. Shrink if not converged.
Numba compilation initiated with caching.
PQ.vcmp out of limits <vmin>

 idx  | Flag | Input Value | Limit
------+------+-------------+------
 PQ_1 | zl   | 0.833       | 0.900


Initialization for dynamics completed in 0.0723 seconds.
Initialization was successful.
<Toggler 1>: Line.Line_8 status changed to 0 at t=2.0 sec.            
100%|███████████████████████████████| 100/100 [00:00<00:00, 189.36%/s]
Simulation completed in 0.5281 seconds.
Outputs to "kundur_full_out.lst" and "kundur_full_out.npz".
Outputs written in 0.0172 seconds.
-> Single process finished in 1.2030 seconds.

!pwd
/home/hacui/repos/andes/examples
import os

os.path.isfile('../andes/cases/kundur/kundur_full.xlsx')
True

PSS/E RAW and DYR Files#

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.5.7.post27.dev0+g9e0e253e
   /_\  _ _  __| |___ ___ | Python 3.9.7 on Linux, 12/14/2021 02:51:29 PM
  / _ \| ' \/ _` / -_|_-< | 
 /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY.

Working directory: "/home/hacui/repos/andes/examples"
Loaded config from file "/home/hacui/.andes/andes.rc"
Loaded generated Python code in "/home/hacui/.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.0018 seconds.
Parsing additional file "../andes/cases/kundur/kundur_full.dyr"...
Addfile parsed in 0.1488 seconds.
System internal structure set up in 0.0219 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
Numba compilation initiated with caching.
Power flow initialized in 0.2857 seconds.
0: |F(x)| = 3.175850023
1: |F(x)| = 3.176155228e-08
Converged in 2 iterations in 0.0007 seconds.
Report saved to "kundur_out.txt" in 0.0005 seconds.

-> Time Domain Simulation Summary:
Sparse Solver: KLU
Simulation time: 0.0-20.0 s.
Fixed step size: h=33.33 ms. Shrink if not converged.
Numba compilation initiated with caching.
Initialization for dynamics completed in 0.0718 seconds.
Initialization was successful.
<Toggler Toggler_1>: Line.Line_8 status changed to 0 at t=2.0 sec.    
100%|███████████████████████████████| 100/100 [00:00<00:00, 189.92%/s]
Simulation completed in 0.5265 seconds.
Outputs to "kundur_out.lst" and "kundur_out.npz".
Outputs written in 0.0173 seconds.
-> Single process finished in 1.1752 seconds.

Check the output 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,                 v EXDC2 1,                  $E_{term}$ EXDC2 1
   178,                 v EXDC2 2,                  $E_{term}$ EXDC2 2
   179,                 v EXDC2 3,                  $E_{term}$ EXDC2 3
   180,                 v EXDC2 4,                  $E_{term}$ EXDC2 4
   181,              vout EXDC2 1,                   $v_{out}$ EXDC2 1
   182,              vout EXDC2 2,                   $v_{out}$ EXDC2 2
   183,              vout EXDC2 3,                   $v_{out}$ EXDC2 3
   184,              vout EXDC2 4,                   $v_{out}$ EXDC2 4
   185,              vref EXDC2 1,                   $V_{ref}$ EXDC2 1
   186,              vref EXDC2 2,                   $V_{ref}$ EXDC2 2
   187,              vref EXDC2 3,                   $V_{ref}$ EXDC2 3
   188,              vref EXDC2 4,                   $V_{ref}$ EXDC2 4
   189,                Se EXDC2 1,            $S_e(|V_{out}|)$ EXDC2 1
   190,                Se EXDC2 2,            $S_e(|V_{out}|)$ EXDC2 2
   191,                Se EXDC2 3,            $S_e(|V_{out}|)$ EXDC2 3
   192,                Se EXDC2 4,            $S_e(|V_{out}|)$ EXDC2 4
   193,                vi EXDC2 1,                       $V_i$ EXDC2 1
   194,                vi EXDC2 2,                       $V_i$ EXDC2 2
   195,                vi EXDC2 3,                       $V_i$ EXDC2 3
   196,                vi EXDC2 4,                       $V_i$ EXDC2 4
   197,              LL_y EXDC2 1,                    $y_{LL}$ EXDC2 1
   198,              LL_y EXDC2 2,                    $y_{LL}$ EXDC2 2
   199,              LL_y EXDC2 3,                    $y_{LL}$ EXDC2 3
   200,              LL_y EXDC2 4,                    $y_{LL}$ EXDC2 4
   201,               W_y EXDC2 1,                     $y_{W}$ EXDC2 1
   202,               W_y EXDC2 2,                     $y_{W}$ EXDC2 2
   203,               W_y EXDC2 3,                     $y_{W}$ EXDC2 3
   204,               W_y EXDC2 4,                     $y_{W}$ EXDC2 4

Plot and save to file#

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)

Display image#

from IPython.display import Image
Image("kundur_full_out_1.png")
../_images/ex5_28_0.png

Using 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.

Using 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"
kundur_full_out.lst 0 5 6 7 8

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
Figure(640x480)

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(640x480)

Cleanup#

Remove the saved png image files.

!rm -v *.png
removed 'kundur_full_out_1.png'
!andes misc -C
    _           _         | Version 1.5.7.post27.dev0+g9e0e253e
   /_\  _ _  __| |___ ___ | Python 3.9.7 on Linux, 12/14/2021 02:51:35 PM
  / _ \| ' \/ _` / -_|_-< | 
 /_/ \_\_||_\__,_\___/__/ | This program comes with ABSOLUTELY NO WARRANTY.

"/home/hacui/repos/andes/examples/kundur_out.lst" removed.
"/home/hacui/repos/andes/examples/kundur_out.npz" removed.
"/home/hacui/repos/andes/examples/kundur_full_out.txt" removed.
"/home/hacui/repos/andes/examples/kundur_full_out.npz" removed.
"/home/hacui/repos/andes/examples/kundur_out.txt" removed.
"/home/hacui/repos/andes/examples/kundur_full_out.lst" removed.