vergauwenthomas / MetObs_toolkit

A toolkit for using non-traditional meteorological observations
https://vergauwenthomas.github.io/MetObs_toolkit/
MIT License
12 stars 5 forks source link

'lat' key not found when no metadata is given #392

Closed vergauwenthomas closed 12 months ago

vergauwenthomas commented 12 months ago

Multiple methods rely on the 'lat' and 'lon' column. Like in the reprof the dataset:

 if ((not self.metadf['lat'].isnull().all()) &
            (not self.metadf['lon'].isnull().all())):
            add_info += '    *Coordinates are available for all stations. \n'

So make sure these columns are always in the metadf attribute but filled with Nan if data is unknown.

Traceback (most recent call last):

File ~/anaconda3/envs/metobs_dev/lib/python3.9/site-packages/pandas/core/indexes/base.py:3790 in get_loc return self._engine.get_loc(casted_key)

File index.pyx:152 in pandas._libs.index.IndexEngine.get_loc

File index.pyx:181 in pandas._libs.index.IndexEngine.get_loc

File pandas/_libs/hashtable_class_helper.pxi:7080 in pandas._libs.hashtable.PyObjectHashTable.get_item

File pandas/_libs/hashtable_class_helper.pxi:7088 in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'lat'

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

Traceback (most recent call last):

File ~/anaconda3/envs/metobs_dev/lib/python3.9/site-packages/spyder_kernels/py3compat.py:356 in compat_exec exec(code, globals, locals)

File ~/Documents/VLINDER_github/MetObs_toolkit/development/developscript.py:50 dataset.show()

File ~/Documents/VLINDER_github/MetObs_toolkit/metobs_toolkit/dataset.py:303 in show print_dataset_info(self, show_all_settings)

File ~/Documents/VLINDER_github/MetObs_toolkit/metobs_toolkit/printing.py:30 in print_dataset_info print(dataset)

File ~/Documents/VLINDER_github/MetObs_toolkit/metobs_toolkit/dataset.py:152 in str if ((not self.metadf['lat'].isnull().all()) &

File ~/anaconda3/envs/metobs_dev/lib/python3.9/site-packages/pandas/core/frame.py:3896 in getitem indexer = self.columns.get_loc(key)

File ~/anaconda3/envs/metobs_dev/lib/python3.9/site-packages/pandas/core/indexes/base.py:3797 in get_loc raise KeyError(key) from err

KeyError: 'lat'