Ask Your Question

waltterval's profile - activity

2023-09-28 20:05:48 -0500 received badge  Nice Question (source)
2017-06-25 00:58:26 -0500 received badge  Taxonomist
2016-05-09 21:11:55 -0500 marked best answer Problem with numpy and matplotlib

Hi, if I run import numpy, matplotlib for any IDLE all is ok ,but if I did that into PSSE I got:

ImportError: DLL load failed: No se puede encontrar el módulo especificado (Did not find the specified module)

Any idea about the problem?

Thanks for tour help, Waltter

2016-05-09 21:11:50 -0500 marked best answer Bad Version number

Hi, I try to run this script

import sys, os
sys.path.insert(0, r"C:\Program Files\PTI\PSSE33\PSSBIN")  # xx --> substitute xx with Version Number here.
os.environ['PATH'] = r"C:\Program Files\PTI\PSSE33\PSSBIN" + ";" + os.environ['PATH']
import redirect
redirect.psse2py()  # this redirects PSS(R)E progress, report output to Python Shell/Console
import psspy

CASE = r"H:\PortableAppscom\Documents\PSSE group\PSSPY\EMT_CAMax_SEP_12_Exp_PA_SN.sav"

psspy.psseinit(12000)
psspy.case(CASE)

But I got a pop up

"Bad version number 33 for program PSSE Was expecting 32"

I have installed both version.

Can you help me to find the problem?

Thanks, Waltter

2013-12-30 18:35:22 -0500 received badge  Famous Question (source)
2013-11-07 20:59:03 -0500 received badge  Famous Question (source)
2013-06-10 10:01:37 -0500 received badge  Famous Question (source)
2013-05-01 17:22:23 -0500 received badge  Notable Question (source)
2013-04-26 09:57:56 -0500 commented answer Load Dynamic Model Library

Thank you, That is exactly what I was looking for!!!

2013-04-25 20:25:47 -0500 received badge  Popular Question (source)
2013-04-22 11:35:11 -0500 asked a question Load Dynamic Model Library

I need to find a way to load a *.dll(Dynamic Model Library, with use models) into a simulation that I run with python.

Do you know if there is a python api to do it?

Regards, Waltter

2013-04-10 09:31:02 -0500 received badge  Notable Question (source)
2012-11-26 09:34:17 -0500 commented answer .out output file + excel

@JervisW Yes it is. You can use the module dyntool to read the .out, then you can use excelpy to export to excel or matplotlib to graph, etc. I will edit my answer with an example.

2012-11-21 10:17:43 -0500 answered a question .out output file + excel

You can not do it. .out is a binary file, you can not open with excel, notepad or any program different that PSSE.

PSSE has a tool to export the data to excel file.

Regards, Waltter

EDITED Example to export to excel

import os
import sys
import numpy as np

# Ajustamos las variables de entorno para el PSSE
sys.path.insert(0,r"C:\Archivos de programa\PTI\PSSE33\PSSBIN")
os.environ['PATH'] = r"C:\Archivos de programa\PTI\PSSE33\PSSBIN" + ";" + os.environ['PATH']
import excelpy
import dyntools

# Para la información de las frecuencias
contingenciaf = ["Contingencia"]
nodos = ["nodo"]
nfmin = ["fmin"]
nfmax = ["fmax"]
nffinal = ["ffinal"]

"""
Comienza a extraer la información para cada uno de los *.out
"""
OutNames = [Out1, Out2]
Ruta = os.getcwd()


for OutName in OutNames:
    rootDir = Ruta + "\\"
    logFile = file(rootDir + "Reporte_" + OutName + "_Din.txt", "w")
    logFile1 = file(rootDir + "Errores_" + OutName + "_Din.txt", "w")
    sys.stdout = logFile  # Las salidas
    sys.stderr = logFile1  # Los errores

    outFile = dyntools.CHNF(OutName + ".out")

    #Extrae información del archivo *.out
    short_title, chanid_dict, chandata_dict = outFile.get_data()

    # Datos de las frecuencias
    freq_chanList = range(51, 62)
    for freqchan in freq_chanList:
        frecuencia = np.add(np.multiply(np.array(chandata_dict[freqchan]), 60), 60)
        nfmin.append(frecuencia.min())
        nfmax.append(frecuencia.max())
        nffinal.append(frecuencia[len(frecuencia) - 1])
        nodos.append(chanid_dict[freqchan])
    for n in range(1,(len(freq_chanList) + 1)):
        contingenciaf.append(OutName)

    logFile.close()
    logFile1.close()

""" Crea los reportes en formato csv """
reporte = Ruta + '\\' + u'InfoDinámica.xlsx'
xl = excelpy.workbook(xlsfile=reporte, sheet="Frecuencia",
                              overwritesheet=True, mode='w')
xl.show_alerts(False)

# Reporte de Frecuencias
xl.worksheet_add_end(sheet="Frecuencia")
xl.set_range(1, 'a', zip(contingenciaf))
xl.set_range(1, 'b', zip(nodos))
xl.set_range(1, 'c', zip(nfmin))
xl.set_range(1, 'd', zip(nfmax))
xl.set_range(1, 'e', zip(nffinal))

xl.save(reporte)
xl.close()
2012-11-07 17:29:21 -0500 received badge  Famous Question (source)
2012-10-28 02:17:10 -0500 received badge  Famous Question (source)
2012-10-25 23:57:47 -0500 commented answer Can we create a single line diagram(sld) from raw data using python?

@JervisW Yes, I would.

2012-10-15 18:22:35 -0500 received badge  Popular Question (source)
2012-10-09 10:20:22 -0500 commented answer Will this generate a QV curve?

@JervisW just a little fix to your code pu = [x for x in np.arange(1.2, 0.8, -0.05)] , you use step=0.05, but is has to be negative because is a decrement

2012-09-30 20:28:27 -0500 received badge  Famous Question (source)
2012-09-27 23:22:14 -0500 commented question Error with psspy.two_winding_chng_4

@JervisW thank you

2012-09-27 09:16:20 -0500 commented question Error with psspy.two_winding_chng_4

@JervisW Yes, I'm using PSSE33 and I didn't know that I have to use the i. I modified my question with the answer

2012-09-26 16:17:47 -0500 asked a question Error with psspy.two_winding_chng_4

test.py file

psspy.two_winding_chng_4(i=22421, j=27421, ckt=r"""3""", realar1=0.00435, realar2=0.148)

Hi,

I run the file test.py into test.sav and I get the following message. I don't see any problem with my code. Can you help me?

Executing Python file:E:\REvBdD\2013\corregidas\Septiembre_2\test.py keyword argument realar1=0.00435 not used keyword argument realar2=0.148 not used Messages for api TWO_WINDING_CHNG_4 Messages for two-winding transformer circuit "3" from 22421 [NCUS-23 23.000] to 27421 [NCUS-115 115.00]: (001972) Error: Vector group "YNd1" not found; set to "YNd1" (002030) No power flow data changed for two-winding transformer circuit "3" from 22421 [NCUS-23 23.000] to 27421 [NCUS-115 115.00]


SOLUTION

Well the problem was that psspy.twowindingchng_4 in realar has inputs and outputs realar1 is an input so the right name is realari1 the same problem is with realar2.

The corrected code is

psspy.two_winding_chng_4(i=22421, j=27421, ckt=r"""3""", realari1=0.00435, realari2=0.148)
2012-09-26 09:31:09 -0500 received badge  Citizen Patrol (source)
2012-09-04 14:03:51 -0500 marked best answer Problem whit ZipFile

Hi, I'm reading the post "All you need to analyse the electricity market pt 2" (http://www.whit.com.au/blog/2012/07/all-you-need-to-analyse-the-electricity-market-pt-2/), when I try to run the script "extractzip.py", I get this error

Traceback (most recent call last):

File "H:\PortableAppscom\Documents\PSSE group\PSSPY\extractzip.py", line 10, in <module>

opened_zipfile = ZipFile(zippedfile)

File "C:\Python27\lib\zipfile.py", line 684, in init

self._GetContents()

File "C:\Python27\lib\zipfile.py", line 710, in _GetContents

self._RealGetContents()

File "C:\Python27\lib\zipfile.py", line 720, in _RealGetContents

endrec = _EndRecData(fp)

File "C:\Python27\lib\zipfile.py", line 197, in _EndRecData

fpin.seek(0, 2)

AttributeError: addinfourl instance has no attribute 'seek'

I thik the problem is with "ZipFile(zippedfile)", maybe python has problem whit the filename in variable zippedfile.

I will appreciate your help.

Thanks in advance for you replies. Waltter Valdez

2012-08-29 16:44:18 -0500 commented answer Bus load transfer

You're right @JervisW

2012-08-23 10:14:37 -0500 answered a question Bus load transfer

You should use

psspy.fnsl(options6 = 1)
2012-08-21 12:25:28 -0500 commented answer How to determine the requirement of a bus reactor?

@amaity maybe open a long line only in one end, fixed capacitors, very long lines

2012-08-21 11:55:11 -0500 commented answer What is the API for generating the .qv files?

@amaity Not, I was trying to do a QV curve in node with ZIB and got an error, then asked to PSSE and told me that.

2012-08-21 11:23:33 -0500 commented answer What is the API for generating the .qv files?

@amaity I'm not adding a zero impedance branch (ZIB), what I did is change parameters in ZIB to be treated as a normal branch, This is becuase the API dosn't permit get QV curve if the bus is joined with a ZIB

2012-08-20 16:56:20 -0500 commented answer What does it mean PSSE blow up?

@JervisW I updated my answer

2012-08-20 16:00:19 -0500 answered a question What is the API for generating the .qv files?

Hi, This is a script that I use to do that task

You can use it with more than one case and get the curve for varius nodes

I get the .qv file, QV curves in .pdf file and the Mvar reserve in .csv files.


I didn't have time to translate the comments

# created by: Waltter Valdez
#Este script es para sacar las curvas QV de las contingencias

import sys, os
sys.path.insert(0, r"C:\Program Files\PTI\PSSE33\PSSBIN")
# xx --> substitute xx with Version Number here.
os.environ['PATH'] = r"C:\Program Files\PTI\PSSE33\PSSBIN" + ";" + os.environ['PATH']
import redirect
redirect.psse2py()
# this redirects PSS(R)E progress, report output to Python Shell/Console

import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
import pssarrays
import matplotlib.pyplot as plt
import csv

psspy.psseinit(50000)

Ruta = os.getcwd()
casos = ('ERT-MaxAbr12-UT_ST', 'ERT-MedAbr12-UT_ST', '')
"""No se debe quitar las comillas simples del final, estas permiten usar el
python incluso con un solo escenario """

archSub = Ruta + '\\' + 'subsistemas_QV.sub'
archMon = Ruta + '\\' + 'monitoreo_QV.mon'
archCon = Ruta + '\\' + 'contingencias_QV.con'

nodos = (28161, 28181, 27421, 27461)
"""# En nodos se debe introducir los numeros de los buses en los cuales
se desea obtener las curvas QV"""

psspy.progress_output(2, 'reportePro', [2, 0])
# Crea casos y QV por gobernador
for casoN in casos:
    if casoN != '':
        carpeta = Ruta + '\\' + casoN
        if not os.path.isdir(carpeta):
            os.makedirs(carpeta)
        caso = Ruta + '\\' + casoN + '.sav'
        Difaxx = carpeta + '\\' + 'Difaxx-' + casoN + '.dfx'
        progreso = carpeta + '\\' + 'Progreso_' + casoN + '.txt'
        psspy.progress_output(2, progreso, [2, 0])
        psspy.case(caso)
        psspy.branch_data(27371, 27372, r"""1""",
             [_i, _i, _i, _i, _i, _i], [0.1E-05, _f, _f, _f, _f, _f, _f, _f,
                 _f, _f, _f, _f, _f, _f, _f])
        """Do it if you have Zero branch..."""
        psspy.fnsl([1, 0, 0, 1, 1, 0, 0, 0])
        psspy.dfax([1, 1], archSub, archMon, archCon, Difaxx)
        for nodo in nodos:
            nodo1 = str(nodo)
            archivoqv = carpeta + '\\' + 'QV_' + nodo1
            ierr2 = psspy.qv_engine([0, 0, 0, 0, 0, 0, 1, 0, 0, nodo],
            [0.5, 1.2, 0.5, 0.01], Difaxx, "", archivoqv)
            if ierr2 != 0:
                continue
            # Change these values as required.
            qvfile = 'QV_' + nodo1 + ".qv"
            qvfile1 = carpeta + '\\''QV_' + nodo1 + ".qv"
            contingencias = pssarrays.qv_summary(qvfile1).colabel
            reserva = ["Reserva (Mvars)"]
            contingencia = ["Contingencias"]
            plt.cla()
            ierr, cval = psspy.notona(nodo)
            for colabel in contingencias:
                rlst = pssarrays.qv_solution(qvfile1, colabel)
                v = rlst.vsetpoint
                q = rlst.mgenmvar
                contingencia.append(colabel)
                reserva.append(min(rlst.mgenmvar)[0])
                plt.plot(v, q)

            reporteReserva = carpeta + '\\' + 'Reporte_Reserva_' + qvfile + '.csv'
            csv_out = open(reporteReserva, 'wb')
            mywriter = csv.writer(csv_out)
            rows = zip(contingencia, reserva)
            mywriter.writerows(rows)
            csv_out.close()

            plt.legend(contingencias, loc='upper right')
            plt.title(qvfile[0:-3] + "_" + cval[0:-7])
            plt.ylabel('MVAr')
            plt.xlabel('Voltaje(p.u.)')
            plt.grid(True)
            plt.savefig(carpeta + '\\' + qvfile[0:-3] + '.pdf', format=None, orientation='portrait')
2012-08-17 08:47:16 -0500 received badge  Notable Question (source)
2012-08-16 10:53:33 -0500 answered a question What does it mean PSSE blow up?

That could be or not for incorrect data. Blown up is relationed with the change in Deltavmag / vmag between iterations.

Before you run FNSL you must check:

  1. MW dispatched on machines
  2. VSched onplants
  3. Status of shunts

Then run FNSL with Flat start

If blow up persist try:

  1. Ignore reactive limit
  2. Block tap changer
  3. Block switched shunt
  4. Use other solution algorithm

I don't have a code to do the chek, but I think the following one is a good start

# OVERLOADED MACHINE SUMMARY
psspy.geol(0, 1, 1)
# GENERATORS AT VAR LIMITS:
psspy.gens(0, 1, 2, 0)
# TRANSFORMERS CONTROLLING VOLTAGE (VIOLATIONS)
psspy.tlst(0, 1, 1, 0)
#switched shunts
ierr, iarray = psspy.aswshint(sid = -1, flag = 2, string = ['NUMBER', 'STATUS'])
print iarray
2012-08-16 10:03:19 -0500 commented answer Extract contingencies for dfax file?

@JervisW I did a little change to your script, I updated my question to post the final code. Thank you

2012-08-16 09:56:13 -0500 marked best answer Extract contingencies for dfax file?

Hi all? I want to know if exists a way to extract the name of the contingencies from a dfax files. I have a dfax file, and I'm lookig for an API that give the contingencies in a variable. Is this possible?


Well I took the code that Jervis wrote and did a little change.

With Jervis'code I got this answer ["'S1'\n", "'S2'\n", "'S3'\n", "'S4'\n", "'S5'\n", "'S6'\n", "'S7'\n", "'S8'\n", "'S9'\n", "'S10'\n", "'S11'\n", "'S12'\n", "'S13'\n", "'S14'\n", "'S15'\n", "'S16'\n", "'S17'\n", "'S18'\n", "'S19'\n", "'S20'\n", "'S21'\n", "'S22'\n", "'S23'\n", "'S24'\n", "'S25'\n", "'S26'\n", "'S27'\n", "'S28'\n", "'S30'\n", "'S31'\n", "'S32'\n"]

With the changed code I got what I really need: ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'S11', 'S12', 'S13', 'S14', 'S15', 'S16', 'S17', 'S18', 'S19', 'S20', 'S21', 'S22', 'S23', 'S24', 'S25', 'S26', 'S27', 'S28', 'S30', 'S31', 'S32']

Here is the code:

contingency_names = []
with open('Contingencias_SER_EMT2012_SAL2.con') as confile:

    for line in confile:
        if line.strip().lower().startswith('contingency'):
        # assumes the last word on the line is the contingency name.
            words = line.split(' ')
            name = words[-1]
            contingency_names.append(name)
            contingency_ID = []
            for contingency_name in contingency_names:
                contingency_ID.append(contingency_name[1:-2])

print "\n contingency_ID = ", contingency_ID
2012-08-16 09:56:06 -0500 received badge  Scholar (source)