GIS4WRF / gis4wrf

QGIS toolkit 🧰 for pre- and post-processing πŸ”¨, visualizing πŸ”, and running simulations πŸ’» in the Weather Research and Forecasting (WRF) model πŸŒ€
https://gis4wrf.github.io
MIT License
159 stars 36 forks source link

Met Data Download Error #217

Closed selamib closed 2 years ago

selamib commented 2 years ago

An error has occurred while executing Python code:

RuntimeError: `C:\Users\selam\OneDrive\Belgeler\gis4wrf\datasets\met\ds083.0\Analysis\200706151200-200706151800\dos-wget.522447.bat' not recognized as a supported file format.

image

Traceback (most recent call last): File "C:/Users/selam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\plugin\ui\widget_datasets.py", line 660, in populate_met_data_tree folder_meta, file_metas = read_grib_folder_metadata(time_range_folder) File "C:/Users/selam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\readers\grib_metadata.py", line 32, in read_grib_folder_metadata return read_grib_files_metadata(paths) File "C:/Users/selam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\readers\grib_metadata.py", line 44, in read_grib_files_metadata meta = read_grib_file_metadata(path) File "C:/Users/selam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gis4wrf\core\readers\grib_metadata.py", line 60, in read_grib_file_metadata ds = gdal.Open(path, gdal.GA_ReadOnly) File "C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib\site-packages\osgeo\gdal.py", line 3173, in Open return _gdal.Open(*args) RuntimeError: `C:\Users\selam\OneDrive\Belgeler\gis4wrf\datasets\met\ds083.0\Analysis\200706151200-200706151800\dos-wget.522447.bat' not recognized as a supported file format.

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] QGIS version: 3.14.16-Pi Pi, df27394552

Python Path: C:/PROGRA~1/QGIS3~1.14/apps/qgis/./python C:/Users/selam/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/selam/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins C:/PROGRA~1/QGIS3~1.14/apps/qgis/./python/plugins C:\PROGRA~1\QGIS3~1.14\apps\Python37 C:\PROGRA~1\QGIS3~1.14\apps\Python37\Scripts C:\Program Files\QGIS 3.14\bin\python37.zip C:\PROGRA~1\QGIS3~1.14\apps\Python37\DLLs C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib C:\Program Files\QGIS 3.14\bin C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib\site-packages C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib\site-packages\win32 C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib\site-packages\win32\lib C:\PROGRA~1\QGIS3~1.14\apps\Python37\lib\site-packages\Pythonwin C:/Users/selam/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:\Users\selam\AppData\Local\gis4wrf\python37 C:\Users\selam\AppData\Local\gis4wrf\python37\lib\site-packages

letmaik commented 2 years ago

This code is responsible for the error, as it only filters out .aux.xml currently: https://github.com/GIS4WRF/gis4wrf/blob/082aa1ac805fc60fe4d5251a89254a0cf4bb8fa1/gis4wrf/core/readers/grib_metadata.py#L28-L32

It should be changed to be more clever and instead of filtering out non-GRIB files by file extension, check for the magic bytes at the beginning of each GRIB file, which are 47 52 49 42 ("GRIB"). Note that GRIB files here have no file extension, otherwise it would be easier.