使用PyPFconvert将PyPSA网络转换为PowerFactory时遭遇KeyError错误的解决方法求助
PyPFconvert将PyPSA网络转换为PowerFactory时遭遇KeyError错误的解决方法求助
最近我在尝试用pypfconvert工具把PyPSA的电网模型转换成PowerFactory格式,运行以下代码时遇到了KeyError错误:
converter.create_project(auto_gen_types=True, sym_av_mode='constv')
完整的错误堆栈信息如下:
File c:\Users\elid_ra\.conda\envs\env_desys\Lib\site-packages\pandas\core\indexes\base.py:3812, in Index.get_loc(self, key) 3811 try: -> 3812 return self._engine.get_loc(casted_key) 3813 except KeyError as err: File pandas/_libs/index.pyx:167, in pandas._libs.index.IndexEngine.get_loc() File pandas/_libs/index.pyx:196, in pandas._libs.index.IndexEngine.get_loc() File pandas/_libs/hashtable_class_helper.pxi:7088, in pandas._libs.hashtable.PyObjectHashTable.get_item() File pandas/_libs/hashtable_class_helper.pxi:7096, in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: '11830 AC' The above exception was the direct cause of the following exception: Cell In[18], line 1 ----> 1 converter.create_project(auto_gen_types=True, sym_av_mode='constv') File h:\PYPFconvert\pypfconvert\pypfconvert\pypsa2pf.py:327, in Pypsa2Pf.create_project(...) 325 # create topology ... -> 3824 self._check_indexing_error(key) KeyError: '11830 AC'
从错误信息来看,工具在查找'11830 AC'这个索引时找不到,我自己初步猜测可能是PyPSA模型里的元件引用有问题,但还没定位到具体原因。有没有大佬能给点排查思路或者解决方法?我自己梳理了几个可能的排查方向:
- 检查PyPSA模型中是否存在ID为
'11830 AC'的母线或其他电力元件,比如发电机、线路等 - 验证模型内元件间的引用一致性,比如有没有某个元件引用了不存在的母线ID
'11830 AC' - 查看pypfconvert处理AC母线的逻辑是否有特殊格式要求,比如是否允许ID包含空格或特定后缀
麻烦各位帮忙看看,谢谢!
内容来源于stack exchange
相关产品推荐
相关产品推荐

