Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have noted that there are many question in this forum regarding which API to use in order to perform a certain task. The method I prefer is to record a python script while performing the task manually in the GUI.

Stop recording and open the script. For example if I manually change Qload at bus 205 to 600 Mvar the recorded script will be:

psspy.load_chng_4(205,r"""1""",[_i,_i,_i,_i,_i,_i],[_f, 600.0,_f,_f,_f,_f])

Now I see which API is used to perform the change (loadchng4) and I can read about the API in the manual. Only the parameter values that I changed are written to the script and the other parameters are represented with their default values (i for integers and _f for floats). For a data changing API this means that they are not changed, i.e. keeping their old values. For API adding new components, like loaddata_4, the default values will take the same values as for actitivty READ.

It is only necessary to enter the argument up to the last one to be changed. In my example I am changing the second real argument so the rest of the real arguments can be skipped:

psspy.load_chng_4(205,r"""1""",[_i,_i,_i,_i,_i,_i],[_f, 600.0])

Since I am not changing any integer arguments I can skip those defaults and just enter an empty list for the integer arguments:

psspy.load_chng_4(205,r"""1""",[],[_f, 600.0])

It is also possible to pass argument with their keyword name. In this case the second real is named realar2:

psspy.load_chng_4(205,r"""1""",realar2= 600.0)

Integer arguments are named intgar, for example

psspy.load_chng_4(205,r"""1""",realar2= 200.0,intgar3=6)

to change the third integer (zone number) to 6. Note that the order of keyword arguments doesn't matter. The integer argument can be given after the real argument.

I have noted that there are many question in this forum regarding which API to use in order to perform a certain task. The method I prefer is to record a python script while performing the task manually in the GUI.

Stop recording and open the script. For example if I manually change Qload at bus 205 to 600 Mvar the recorded script will be:

psspy.load_chng_4(205,r"""1""",[_i,_i,_i,_i,_i,_i],[_f, 600.0,_f,_f,_f,_f])

Now I see which API is used to perform the change (loadchng4) and I can read about the API in the manual. Only the parameter values that I changed are written to the script and the other parameters are represented with their default values (( i for integers and _f for floats). For a data changing API this means that they are not changed, i.e. keeping their old values. For API adding new components, like loaddata_4, the default values will take the same values as for actitivty READ.

It is only necessary to enter the argument up to the last one to be changed. In my example I am changing the second real argument so the rest of the real arguments can be skipped:

psspy.load_chng_4(205,r"""1""",[_i,_i,_i,_i,_i,_i],[_f, 600.0])

Since I am not changing any integer arguments I can skip those defaults and just enter an empty list for the integer arguments:

psspy.load_chng_4(205,r"""1""",[],[_f, 600.0])

It is also possible to pass argument with their keyword name. In this case the second real is named realar2:

psspy.load_chng_4(205,r"""1""",realar2= 600.0)

Integer arguments are named intgar, for example

psspy.load_chng_4(205,r"""1""",realar2= 200.0,intgar3=6)

to change the third integer (zone number) to 6. Note that the order of keyword arguments doesn't matter. The integer argument can be given after the real argument.

I have noted that there are many question in this forum regarding which API to use in order to perform a certain task. The method I prefer is to record a python script while performing the task manually in the GUI.

Stop recording and open the script. For example if I manually change Qload at bus 205 to 600 Mvar the recorded script will be:

psspy.load_chng_4(205,r"""1""",[_i,_i,_i,_i,_i,_i],[_f, 600.0,_f,_f,_f,_f])

Now I see which API is used to perform the change (loadchng4) and I can read about the API in the manual. Only the parameter values that I changed are written to the script and the other parameters are represented with their default values ( i for integers and _f for floats). For a data changing API this means that they are not changed, i.e. keeping their old values. For API adding new components, like loaddata_4, the default values will take the same values as for actitivty READ.

It is only necessary to enter the argument up to the last one to be changed. In my example I am changing the second real argument so the rest of the real arguments can be skipped:

psspy.load_chng_4(205,r"""1""",[_i,_i,_i,_i,_i,_i],[_f, 600.0])

Since I am not changing any integer arguments I can skip those defaults and just enter an empty list for the integer arguments:

psspy.load_chng_4(205,r"""1""",[],[_f, 600.0])

It is also possible to pass argument with their keyword name. In this case the second real is named realar2:

psspy.load_chng_4(205,r"""1""",realar2= 600.0)

Integer arguments are named intgar, for example

psspy.load_chng_4(205,r"""1""",realar2= 200.0,intgar3=6)
600.0,intgar3=6)

to change the third integer (zone number) to 6. Note that the order of keyword arguments doesn't matter. The integer argument can be given after the real argument.