pypsa-meets-earth / pypsa-earth-sec

GNU General Public License v3.0
18 stars 16 forks source link

fix IndexError #326

Open doneachh opened 1 month ago

doneachh commented 1 month ago

Closes # (if applicable).

Changes proposed in this Pull Request

Checklist

doneachh commented 1 month ago

Hi @davide-f ! :) another bugfix to review. I am not sure, whether we have to set the "." for the cases len(x) <=3 - if not maybe we should check len(x)>3 in the else part as well.

doneachh commented 4 weeks ago

decided to check it in the else part as well, as two-digit-codes followed by a dot without anything else are looking pretty wierd ^^

davide-f commented 3 weeks ago

Wow interesting @doneachh, can you explain when that happens? The GADM is 3 code by definition and it has been a bit tested; when running Africa I have not encountered this

doneachh commented 3 weeks ago

@davide-f I recieved this error when running Africa - the two config settings which are different to the default config and could probably lead to this are:

doneachh commented 3 weeks ago

@davide-f fixed it as discussed - do you have a solution for iterating in case of multiple entries for a country (if thats possible)? Anyway solving this like that right there, havent fixed #328

doneachh commented 1 week ago

Apologies @doneachh , a little comment.

Morever, in this case with layer 0, is the GID_0 column a 3 letter code country or just 2? Because if it is 2, than we could reverse to 3 letter code here and then the other PR should not be needed. What do you think?

Its 2 letter code countries - agree! Will change it next week :)