UMEP-dev / UMEP

Urban Multi-scale Environmental Predictor
https://umep-docs.readthedocs.io/
59 stars 15 forks source link

Unable to download and processed ERA5 data #380

Closed phemiobe closed 2 years ago

phemiobe commented 2 years ago

Hello, I have the error when I want to download ERA5 data "AttributeError: 'NoneType' object has no attribute 'flush'". Please any idea on how to resolve this. I have upgraded my supy(SuPy version: 2022.2.17)

QGIS version: 3.22.3-Białowieża
QGIS code revision: 1628765ec7
Qt version: 5.15.2
Python version: 3.9.5
GDAL version: 3.4.1
GEOS version: 3.10.0-CAPI-1.16.0
PROJ version: Rel. 8.2.1, January 1st, 2022
PDAL version: 2.3.0 (git-version: 9f35b7)
Algorithm started at: 2022-03-06T20:24:29
Algorithm 'Meteorological Data: Download data (ERA5)' starting…
Input parameters:
{ 'CRS' : QgsCoordinateReferenceSystem('EPSG:4326'), 'DATEINIEND' : '2000-02-27T00:00:00', 'DATEINISTART' : '2000-02-20T00:00:00', 'INPUT_POINT' : '3.294379,6.592047 [EPSG:4326]', 'OUTPUT_DIR' : 'C:\\Users\\User\\Documents\\Objective _1\\SUEWS_Project\\met_data\\met_2000' }
SuPy version: 2022.2.17 
INPUT PARAMETERS:
lat = 3.294379
lon = 6.592047
Start = 2000-02-20T00:00:00
End = 2000-02-27T00:00:00
C:\Users\User\Documents\Objective _1\SUEWS_Project\met_data\met_2000
Traceback (most recent call last):
File "C:\Users/User/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\preprocessor\copernicusera5_algorithm.py", line 160, in processAlgorithm
sp.util.gen_forcing_era5(lat, lon, startDate, endDate, dir_save=outputDir)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\supy\util\_era5.py", line 709, in gen_forcing_era5
list_fn_sfc, list_fn_ml = load_filelist_era5(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\supy\util\_era5.py", line 611, in load_filelist_era5
download_era5(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\supy\util\_era5.py", line 511, in download_era5
download_cds(path_dir_save / fn_sfc, dict_req)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\supy\util\_era5.py", line 444, in download_cds
c.retrieve(**dict_req)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\cdsapi\api.py", line 350, in retrieve
result.download(target)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\cdsapi\api.py", line 173, in download
return self._download(self.location, self.content_length, target)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\cdsapi\api.py", line 123, in _download
with tqdm(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\tqdm\std.py", line 1107, in __init__
self.sp = self.status_printer(self.fp)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\tqdm\std.py", line 339, in status_printer
sys.stderr.flush()
AttributeError: 'NoneType' object has no attribute 'flush'

Execution failed after 172.25 seconds (2 minutes 52 seconds)

Loading resulting layers
Algorithm 'Meteorological Data: Download data (ERA5)' finished.
phemiobe commented 2 years ago

My request was successfully submitted but the algorithm did not process it. CDSAPI request.

sunt05 commented 2 years ago

related to #375

sunt05 commented 2 years ago

Hi @phemiobe I assume you are using umep-processing for this task, which, as mentioned by @biglimp in #375, should have resolved a similar issue.

To check if this is really an issue at the SuPy side, could you please test the following code in the python console and let me know the results/problem?

Thanks!

import supy as sp
sp.util.gen_forcing_era5(20, 20, '2020-12-01', '2020-12-02', dir_save='C:\Users\User\Documents\Objective _1\SUEWS_Project\met_data\met_2000')
phemiobe commented 2 years ago

The code was able to download and processed the data into the specified directory.

thanks

sunt05 commented 2 years ago

Good to know.

I guess there might be some issue at the QGIS side that somehow the connection between the GUI and underlying python code is lost, hence the issue, which, however, is indeed out of our control at the moment.

Please feel free to add more details if this issue persists.

sunt05 commented 2 years ago

Hi there, please let us know if the issue persists. If so, please provide more info for us to address the issue. Otherwise, please close the issue.