Jenkins - WCR / Tests / Declarative: Post Actions
failed
Sep 23, 2024 in 0s
climada_petals.test.test_tc_forecast_integr.TestTCForecast.test_data_extraction_from_ecmwf failed
Send us feedback
Details
climada_petals.test.test_tc_forecast_integr.TestTCForecast.test_data_extraction_from_ecmwf
FileNotFoundError: Error while downloading BUFR TC tracks: No tracks found at ftp://{}/{}
Stack trace
target_dir = None, remote_dir = '20240923120000'
@staticmethod
def fetch_bufr_ftp(target_dir=None, remote_dir=None):
"""
Fetch and read latest ECMWF TC track predictions from the FTP
dissemination server. If target_dir is set, the files get downloaded
persistently to the given location. A list of opened file-like objects
gets returned.
Parameters
----------
target_dir : str
An existing directory to write the files to. If
None, the files get returned as tempfiles.
remote_dir : str, optional
If set, search this ftp folder for
forecast files; defaults to the latest. Format:
yyyymmddhhmmss, e.g. 20200730120000
Returns
-------
[filelike]
"""
con = ftplib.FTP(host=ECMWF_FTP.host.str(),
user=ECMWF_FTP.user.str(),
passwd=ECMWF_FTP.passwd.str())
try:
if remote_dir is None:
# Read list of directories on the FTP server
remote = pd.Series(con.nlst())
# Identify directories with forecasts initialised as 00 or 12 UTC
remote = remote[remote.str.contains('120000|000000$')]
# Select the most recent directory (names are formatted yyyymmddhhmmss)
remote = remote.sort_values(ascending=False)
remote_dir = remote.iloc[0]
# Connect to the directory
con.cwd(remote_dir)
# Filter to files with 'tropical_cyclone' in the name: each file is a forecast
# ensemble for one event
remotefiles_temp = fnmatch.filter(con.nlst(), '*tropical_cyclone*')
# Filter to forecast ensemble files only
remotefiles = fnmatch.filter(remotefiles_temp, '*ECEP*')
if len(remotefiles) == 0:
msg = 'No tracks found at ftp://{}/{}'
msg.format(ECMWF_FTP.host.dir(), remote_dir)
> raise FileNotFoundError(msg)
E FileNotFoundError: No tracks found at ftp://{}/{}
../../../../petals_branches/branches/PR-128/workspace/climada_petals/hazard/tc_tracks_forecast.py:215: FileNotFoundError
The above exception was the direct cause of the following exception:
self = <climada_petals.test.test_tc_forecast_integr.TestTCForecast testMethod=test_data_extraction_from_ecmwf>
def test_data_extraction_from_ecmwf(self):
"""Test realtime TC tracks data retrieval from ECMWF"""
tr_forecast = TCForecast()
> tr_forecast.fetch_ecmwf()
../../../../petals_branches/branches/PR-128/workspace/climada_petals/test/test_tc_forecast_integr.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../petals_branches/branches/PR-128/workspace/climada_petals/hazard/tc_tracks_forecast.py:149: in fetch_ecmwf
files = self.fetch_bufr_ftp(target_dir, remote_dir)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
target_dir = None, remote_dir = '20240923120000'
@staticmethod
def fetch_bufr_ftp(target_dir=None, remote_dir=None):
"""
Fetch and read latest ECMWF TC track predictions from the FTP
dissemination server. If target_dir is set, the files get downloaded
persistently to the given location. A list of opened file-like objects
gets returned.
Parameters
----------
target_dir : str
An existing directory to write the files to. If
None, the files get returned as tempfiles.
remote_dir : str, optional
If set, search this ftp folder for
forecast files; defaults to the latest. Format:
yyyymmddhhmmss, e.g. 20200730120000
Returns
-------
[filelike]
"""
con = ftplib.FTP(host=ECMWF_FTP.host.str(),
user=ECMWF_FTP.user.str(),
passwd=ECMWF_FTP.passwd.str())
try:
if remote_dir is None:
# Read list of directories on the FTP server
remote = pd.Series(con.nlst())
# Identify directories with forecasts initialised as 00 or 12 UTC
remote = remote[remote.str.contains('120000|000000$')]
# Select the most recent directory (names are formatted yyyymmddhhmmss)
remote = remote.sort_values(ascending=False)
remote_dir = remote.iloc[0]
# Connect to the directory
con.cwd(remote_dir)
# Filter to files with 'tropical_cyclone' in the name: each file is a forecast
# ensemble for one event
remotefiles_temp = fnmatch.filter(con.nlst(), '*tropical_cyclone*')
# Filter to forecast ensemble files only
remotefiles = fnmatch.filter(remotefiles_temp, '*ECEP*')
if len(remotefiles) == 0:
msg = 'No tracks found at ftp://{}/{}'
msg.format(ECMWF_FTP.host.dir(), remote_dir)
raise FileNotFoundError(msg)
localfiles = []
LOGGER.info('Fetching BUFR tracks:')
for rfile in tqdm.tqdm(remotefiles, desc='Download', unit=' files'):
if target_dir:
lfile = Path(target_dir, rfile).open('w+b')
else:
lfile = tempfile.TemporaryFile(mode='w+b')
con.retrbinary('RETR ' + rfile, lfile.write)
lfile.seek(0)
localfiles.append(lfile)
except ftplib.all_errors as err:
con.quit()
> raise type(err)('Error while downloading BUFR TC tracks: ' + str(err)) from err
E FileNotFoundError: Error while downloading BUFR TC tracks: No tracks found at ftp://{}/{}
../../../../petals_branches/branches/PR-128/workspace/climada_petals/hazard/tc_tracks_forecast.py:233: FileNotFoundError
Loading