Python Forum
IndexError: index 10 is out of bounds for axis 0 with size 10
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndexError: index 10 is out of bounds for axis 0 with size 10
#1
i am trying to run a Github repo for voltage control of various distribution system like IEEE10 bus, 23 bus and 30 bus system. When main files calls runpf.py file for power flow calculations it calls another file ext2int to convert external numbering to internal, which generates error as given below,
'bs[n2i[ppc["branch"][:, T_BUS].astype(int)]] ).astype(bool)'. I have created issues to this repo on github as well, but did not find any response. project line is given below. Plz help me out to resolve this issue,.
Link: https://github.com/sogno-platform/covee
Reply
#2
Normally in Python when an array has size 10, the valid indexes go from 0 to 9, so that 10 is indeed an invalid index.
Reply
#3
(Sep-06-2023, 07:33 AM)Gribouillis Wrote: Normally in Python when an array has size 10, the valid indexes go from 0 to 9, so that 10 is indeed an invalid index.

thanks for replying, sir actually input data including load and pv profile size is 10, when ext2int file converts externa numbering from 1-10 to 0-9, it generates error. i have replaced different cases but same issue persists
Reply
#4
The error message looks like a numpy index error. What is load_profile? I looked at the pypower source for ext2int() and it looks like the return type is a case dict. I don't have enough curiosity to install the package or dig through all the source to learn what that dictionary looks like. Could you print out load_profile before and after calling ext2int?
Reply
#5
(Sep-06-2023, 03:12 PM)deanhystad Wrote: The error message looks like a numpy index error. What is load_profile? I looked at the pypower source for ext2int() and it looks like the return type is a case dict. I don't have enough curiosity to install the package or dig through all the source to learn what that dictionary looks like. Could you print out load_profile before and after calling ext2int?

Dear deanhystad, I appreciate your response and consideration. Actually dictionary does not contain the load profile, rather grid data including Bus data, branch information and generator data and i have already printed it before and after calling ext2int. however, I am giving Load profile in form of excel sheet which can be shard if you say?
Reply
#6
(Sep-08-2023, 06:47 PM)Mehboob Wrote:
(Sep-06-2023, 03:12 PM)deanhystad Wrote: The error message looks like a numpy index error. What is load_profile? I looked at the pypower source for ext2int() and it looks like the return type is a case dict. I don't have enough curiosity to install the package or dig through all the source to learn what that dictionary looks like. Could you print out load_profile before and after calling ext2int?

I am sending you a file that contains the contents of dictionary before and after applying ext2int along-with load and pv profile with case(grid file), not two much lengthy and the paper which is implemented in this code. i am trying to resolve the issue since 6 months but struck here, if you could go through it, it will be very helpful for me to continue my PhD research

Attached Files

Thumbnail(s)
   

.docx   contnet of ppc.docx (Size: 21.03 KB / Downloads: 48)
.csv   Load_profile10.csv (Size: 153.58 KB / Downloads: 25)
.csv   PV_profile10.csv (Size: 101.8 KB / Downloads: 23)
.py   case_10_nodes.py (Size: 3.45 KB / Downloads: 33)
Reply
#7
The issue as reported in the repository.
Error:
line 128, in run_power_flow bus[i][PD] = load_profile[i] IndexError: index22 is out of bounds for axis 0 with size 22
That code has moved thing a little. Line above is now line 122.
        for i in range(int(nb)):
            bus[i][PD] = load_profile[i]    <- Error is here according to msg.
            bus[i][QD] = 0.0
            if self.active_ESS != None and any(bus[i][BUS_I] == float(self.active_ESS[k]) for k in range(len(self.active_ESS))):
                if active_power_ess[s]:
                    bus[i][PD] = load_profile[i]-active_power_ess[s]
                    s +=1
So what is nb?
What is load_profile? My guess is this is a numpy array. What is the shape? What is supposed to make sure that ppc["bus"] and load_profile compatible?

I wish you had posted the error trace with your issue instead of a screenshot. I would like to know who called run_Power_Flow so I could see what arguments are passed.
Reply
#8
(Sep-08-2023, 09:09 PM)deanhystad Wrote: The issue as reported in the repository.
Error:
line 128, in run_power_flow bus[i][PD] = load_profile[i] IndexError: index22 is out of bounds for axis 0 with size 22
That code has moved thing a little. Line above is now line 122.
        for i in range(int(nb)):
            bus[i][PD] = load_profile[i]    <- Error is here according to msg.
            bus[i][QD] = 0.0
            if self.active_ESS != None and any(bus[i][BUS_I] == float(self.active_ESS[k]) for k in range(len(self.active_ESS))):
                if active_power_ess[s]:
                    bus[i][PD] = load_profile[i]-active_power_ess[s]
                    s +=1
So what is nb?
What is load_profile? My guess is this is a numpy array. What is the shape? What is supposed to make sure that ppc["bus"] and load_profile compatible?

I wish you had posted the error trace with your issue instead of a screenshot. I would like to know who called run_Power_Flow so I could see what arguments are passed.

Actually, this was the error in initial stages and i myself tried to overcome this by changing the range of for loop. here 'nb' is the number of buses, as python starts indexing from zero, range of for loop should be ended with 'nb-1' you can see the corrected code in the image attached. First i incorporated 23 bus, then changed to 10 bus in order to check that,whether error is due to load profile, but same error persists for any type of system, e.g. 23 bus, 10 bus etc. Main file with title 'covee_main' is calling the run power flow at line 87, (page 4 of 5 in docx file) the same is attached as well for your reference plz.

Attached Files

Thumbnail(s)
   

.docx   covee_main.docx (Size: 14.95 KB / Downloads: 49)
Reply
#9
What is the value of nb? What is the shape of load_profile (assuming it is a numpy array)?

Please stop posting screenshots and word documents. Post text.
Reply
#10
(Sep-10-2023, 01:10 PM)deanhystad Wrote: What is the value of nb? What is the shape of load_profile (assuming it is a numpy array)?

Please stop posting screenshots and word documents. Post text.

for 10 bus system, value of nb (10,13) while shape of load_profile is 9
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation IndexError: Replacement index 2 out of range for positional args tuple - help? MrKnd94 2 6,410 Oct-14-2022, 09:57 PM
Last Post: MrKnd94
  IndexError: list index out of range dolac 4 1,924 Jul-25-2022, 03:42 PM
Last Post: deanhystad
  IndexError: list index out of range Anldra12 2 1,449 May-03-2022, 01:39 PM
Last Post: Anldra12
  For loop index out of bounds armitron121 2 2,686 Feb-08-2022, 04:23 PM
Last Post: armitron121
  Sample labels from excel file in order to put them on x-axis and y-axis of a plot hobbyist 11 4,394 Sep-14-2021, 08:29 AM
Last Post: hobbyist
  IndexError: list index out of range rf_kartal 6 2,862 Sep-07-2021, 02:36 PM
Last Post: Larz60+
  IndexError: list index out of range Laplace12 1 2,233 Jun-22-2021, 10:47 AM
Last Post: Yoriz
  IndexError: list index out of range brunolelli 11 6,576 Mar-25-2021, 11:36 PM
Last Post: brunolelli
  IndexError: list index out of range ramu4651 2 3,755 Jan-24-2021, 01:45 PM
Last Post: buran
  IndexError: index 10 is out of bounds for axis 0 with size 1 vahid89 1 12,275 Jan-07-2021, 06:19 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020