Python Forum
IndexError: index 10 is out of bounds for axis 0 with size 10 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: IndexError: index 10 is out of bounds for axis 0 with size 10 (/thread-40682.html)

Pages: 1 2


IndexError: index 10 is out of bounds for axis 0 with size 10 - Mehboob - Sep-06-2023

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


RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - Gribouillis - Sep-06-2023

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.


RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - Mehboob - Sep-06-2023

(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


RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - deanhystad - Sep-06-2023

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?


RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - Mehboob - Sep-08-2023

(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?


RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - Mehboob - Sep-08-2023

(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



RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - deanhystad - Sep-08-2023

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.


RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - Mehboob - Sep-10-2023

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


RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - deanhystad - Sep-10-2023

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.


RE: IndexError: index 10 is out of bounds for axis 0 with size 10 - Mehboob - Sep-11-2023

(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