# -*- coding: utf-8 -*- # ============================================================================= # Copyright (C) 2018 Mercados Electricos de Centroamérica. All rights reserved # ============================================================================= """Crea las estructuras con numeración secuencial de buses, circuitos y nombres de circuitos """ from numpy import array from numpy import zeros from utils.idx_brch import BUS_I, BUS_J, CKT def setbus(net): """Lee la información de la red y crea una serie con los códigos de nodos y su numeración correlativa. """ b = net['bus_i'].append(net['bus_j']).drop_duplicates().sort_values() b = b.reset_index(drop=True) return b def setbranch(net, b): """Utiliza la información de la red, lod códigos de nodos y su numeración correlativa para generar un listado con de los circuitos de acuerdo a la numeración correlativo del nodo. """ br = net.copy() for i in range(0, net.shape[0]): br.loc[i, 'bus_i'] = b[b == br['bus_i'][i]].index[0] br.loc[i, 'bus_j'] = b[b == br['bus_j'][i]].index[0] br = br.sort_values(['bus_i', 'bus_j']) return br.values def setvariable(variable): l=variable.shape[0] z=zeros(l) for i in range(0,variable.shape[0]): z[i]=variable[i] return z def setvariable_s(variable): (l,n)=variable.shape z=zeros((l,n)) for i in range(0,l): for j in range(0,n): z[i,j]=variable.iloc[i,j] return z def setvariable_p(variable, n): z=zeros((n,5)) m=0 for j in range(0,n): for i in range(0,5): z[j,i]=variable[m] m=m+1 return z def branchnames(b, br): """Devuelve un array con los nombres de los circuitos. """ brnames = [] for i in range(0, br.shape[0]): brnames.append("-".join([str(b[br[i, BUS_I]]),str(b[br[i, BUS_J]])])) brnames = array(brnames) return brnames