UMEP-dev / SUEWS

Surface Urban Energy and Water Balance Scheme
https://suews.readthedocs.io/
Mozilla Public License 2.0
12 stars 6 forks source link

`KeyError: 'sfr_surf'` issue due to different SuPy versions #229

Closed becqui00 closed 8 months ago

becqui00 commented 8 months ago

Hi, I'm currently running a program with the SuPy version 2022.9.22. Since I had to install SuPy on another device, my program doesn't work anymore. I realized when I'm installing SuPy (pip install supy) I'm getting the version 2022.4.7 or even a dev version which is a different one. How can I install the version 2022.9.22 again?

Thanks for your help!

sunt05 commented 8 months ago

Hi @becqui00 ,

The 2022.9.22 version has an issue with FAI calculation and was thus revoked. Apart from some internal experimental features, the 2022..4.7 has the same functionality as 2022.9.22 and thus recommended as stable release.

The other dev versions have experimental features that are being developed - you are welcome to try out the latest dev version, but please be aware that there might be issues we have not spotted.

Thank you!

becqui00 commented 8 months ago

Hi @sunt05 , thank you for your response. Which pandas version should I use then? Because I'm getting "KeyError: 'sfr_surf'" out of the sudden, when I'm running my program which worked before.

Kind regards

sunt05 commented 8 months ago

Hi @becqui00 ,

Sorry about the inconvenience - it looks like you are using the dev, in which some input variables have been renamed to allow new variables.

The issue you met is not about pandas - it's caused by a renaming of sfr to sfr_surf - note the suffix surf - and there are several other similar cases.

My suggestion would be:

Anyway, please let me know here if further issues.

becqui00 commented 8 months ago

Hi @sunt05 , Okay I'm trying it, thank you. Anyways when I'm asking SuPy about the version with sp.show_version(), it says:


SuPy versions
-------------
supy: 2022.4.7 
supy_driver: 2021a5

I'm really confused with all that. Maybe it should be documented when there are changes made with the versions and all that. It would be easier for everyone, otherwise it is an endless maze.

Kind regards

sunt05 commented 8 months ago

Thanks @becqui00 for pointing this out! Please post the full error message here and I'll add it to the FAQ section of our documentation site.

becqui00 commented 8 months ago
Traceback (most recent call last):

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexes\base.py:3629 in get_loc
    return self._engine.get_loc(casted_key)

  File pandas\_libs\index.pyx:136 in pandas._libs.index.IndexEngine.get_loc

  File pandas\_libs\index.pyx:163 in pandas._libs.index.IndexEngine.get_loc

  File pandas\_libs\hashtable_class_helper.pxi:5198 in pandas._libs.hashtable.PyObjectHashTable.get_item

  File pandas\_libs\hashtable_class_helper.pxi:5206 in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'sfr_surf'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File ~\AppData\Local\mambaforge\envs\SUEWS\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File e:\quirin\suews\pythonprogs\qb_test_control_run_loop_one_pixel.py:369
    print(df_state_init.loc[:,'sfr_surf'])

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexing.py:961 in __getitem__
    return self._getitem_tuple(key)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexing.py:1140 in _getitem_tuple
    return self._getitem_lowerdim(tup)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexing.py:843 in _getitem_lowerdim
    return self._getitem_nested_tuple(tup)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexing.py:942 in _getitem_nested_tuple
    obj = getattr(obj, self.name)._getitem_axis(key, axis=axis)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexing.py:1205 in _getitem_axis
    return self._get_label(key, axis=axis)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexing.py:1153 in _get_label
    return self.obj.xs(label, axis=axis)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\generic.py:3849 in xs
    return self[key]

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\frame.py:3504 in __getitem__
    return self._getitem_multilevel(key)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\frame.py:3555 in _getitem_multilevel
    loc = self.columns.get_loc(key)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexes\multi.py:2869 in get_loc
    loc = self._get_level_indexer(key, level=0)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexes\multi.py:3222 in _get_level_indexer
    idx = self._get_loc_single_level_index(level_index, key)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexes\multi.py:2802 in _get_loc_single_level_index
    return level_index.get_loc(key)

  File ~\AppData\Roaming\Python\Python39\site-packages\pandas\core\indexes\base.py:3631 in get_loc
    raise KeyError(key) from err

KeyError: 'sfr_surf'
sunt05 commented 8 months ago

Thanks @becqui00 - could you please also put some of your code here that was causing the issue? So I can better describe the background with a tangible example.

sunt05 commented 8 months ago

Hi @becqui00 , please check out here the updated FAQ and see if your issue could be resolved. Please feel free to re-open this issue if necessary.