insarlab / PyAPS

Python-based Atmospheric Phase Screen
GNU General Public License v3.0
64 stars 26 forks source link

Error when downloading the ECMWF HRES data #23

Closed xhuang-jpl closed 8 months ago

xhuang-jpl commented 1 year ago

Hi, I try to download the ECMWF HRES data through the API as the code shown below,

import pyaps3 as pa

date_ref = '20120419'
hr_ref = '16'
date_second = '20121105'
hr_second = '22'
snwe = [38,40,-124,-121]

filedir = '/scratch/test'

#Download the ECMWF data
grb_file_ref = pa.ECMWFdload([date_ref], hr=hr_ref, filedir=filedir, datatype = 'an', model='HRES', snwe=snwe)
grb_file_second = pa.ECMWFdload([date_second], hr=hr_second, filedir=filedir, datatype = 'an', model='HRES', snwe=snwe)

there is an error showing no module named pa

Traceback (most recent call last):
  File "/scratch/xhuang/isce3_test/SanAndreas/donwload.py", line 12, in <module>
    grb_file_ref = pa.ECMWFdload([date_ref], hr=hr_ref, filedir=filedir, datatype = 'an', model='HRES', snwe=snwe)[0]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/xhuang/python/miniconda3/envs/isce3/lib/python3.11/site-packages/pyaps3/autoget.py", line 139, in ECMWFdload
    from pa.ecmwfapi import ECMWFDataServer
ModuleNotFoundError: No module named 'pa'

Thank you!

yunjunz commented 8 months ago

My local testing shows that #23 fixed the error above, but then the following error is shown. I guess it is an account setup issue. @scottstanie, @xhuang-jpl does the downloading works for you now?

Downloading 1 of 1: /Users/yunjunz/Downloads/HRES_N38_N40_W124_W121_20120419_16.grb 
{'dataset': 'HRES', 'type': 'an', 'date': '20120419', 'time': '16', 'step': '0', 'levtype': 'pl', 'levelist': 'all', 'grid': '0.10/0.10', 'param': '129/130/133', 'target': '/Users/yunjunz/Downloads/HRES_N38_N40_W124_W121_20120419_16.grb'}
2024-02-29 11:26:22 ECMWF API python library 1.4.1
2024-02-29 11:26:22 ECMWF API at https://api.ecmwf.int/v1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yunjunz/tools/PyAPS/src/pyaps3/autoget.py", line 163, in ECMWFdload
    server.retrieve(indict)
  File "/Users/yunjunz/tools/PyAPS/src/pyaps3/ecmwfapi.py", line 489, in retrieve
    c = APIRequest(self.url, "datasets/%s" % (dataset,), self.email, self.key, self.trace, verbose=self.verbose)
  File "/Users/yunjunz/tools/PyAPS/src/pyaps3/ecmwfapi.py", line 369, in __init__
    user = self.connection.call("%s/%s" % (self.url, "who-am-i"))
  File "/Users/yunjunz/tools/PyAPS/src/pyaps3/ecmwfapi.py", line 136, in wrapped
    return func(self, *args, **kwargs)
  File "/Users/yunjunz/tools/PyAPS/src/pyaps3/ecmwfapi.py", line 319, in call
    raise APIException("ecmwf.API error 1: %s" % (self.last["error"],))
pyaps3.ecmwfapi.APIException: 'ecmwf.API error 1: Invalid token'
scottstanie commented 8 months ago

Ah sorry, I didn't actually test whether it would work because I had been hearing people say how slow the download was this week.

xhuang-jpl commented 8 months ago

Thank you @yunjunz and @scottstanie for taking care of this issue. I also heard similar things from ppl in the RAiDER team. In addition, the HRES is also not free access. I thought it was free when I did this test.

yunjunz commented 8 months ago

the HRES is also not free access.

Yeah, it looks like so: https://www.ecmwf.int/en/forecasts/accessing-forecasts. Thanks for the info @xhuang-jpl. I think we could close this issue now.