chore: LSTM 训练调优总结 — 类别加权/采样器/权重多项尝试,XGBoost 仍为最佳
This commit is contained in:
@@ -39,18 +39,25 @@ def download_one_month(city: str, year: int, month: int) -> bool:
|
||||
return True # 已存在,跳过
|
||||
|
||||
request = build_request(city, year, month)
|
||||
for attempt in range(1, 4):
|
||||
for attempt in range(1, 6):
|
||||
try:
|
||||
logger.info("请求 %s %d-%02d (第 %d/5 次)", city, year, month, attempt)
|
||||
client.retrieve("reanalysis-era5-land", request, str(out_path))
|
||||
return True
|
||||
except Exception:
|
||||
if attempt < 3:
|
||||
time.sleep(30)
|
||||
if out_path.exists() and out_path.stat().st_size > 0:
|
||||
return True
|
||||
else:
|
||||
logger.warning("文件为空 %s %d-%02d,重试", city, year, month)
|
||||
except Exception as e:
|
||||
delay = 60 * attempt
|
||||
logger.warning("失败 %s %d-%02d (第 %d/5 次): %s,%ds 后重试",
|
||||
city, year, month, attempt, str(e)[:100], delay)
|
||||
if attempt < 5:
|
||||
time.sleep(delay)
|
||||
return False
|
||||
|
||||
|
||||
def download_city(city: str, start_year: int = ERA5_START_YEAR,
|
||||
end_year: int = ERA5_END_YEAR, max_workers: int = 3):
|
||||
end_year: int = ERA5_END_YEAR, max_workers: int = 1):
|
||||
"""并行下载(3线程),兼顾速度和 CDS 限流"""
|
||||
name = CITIES[city]["name"]
|
||||
tasks = [(city, y, m) for y in range(start_year, end_year + 1) for m in range(1, 13)]
|
||||
|
||||
Reference in New Issue
Block a user