Step1: 首先安装ubuntu,无法启动报错:
WslRegisterDistribution failed with error: 0x8007019e
Error: 0x8007019e ?????? Linux ? Windows ????????? ?wsl.exe --install? ?????
?????????? https://aka.ms/wslinstall
以PowerShell(shift+ctrl+“+”管理员)运行,安装windows的子系统支持
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
重启,未果,再翻翻网上的解决方法,
1.开启Windows Subsystem for Linux:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
2.开启虚拟机特性:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
还是不行,重新安装重启电脑
wsl –update
行不通,再从Microsoft 下载 WSL 2内核更新包:WSL2 Linux kernel update package for x64 machines
安装未果,重启电脑,重新安装
成功安装wsl2,进入下一步。【cd=change directory】
运行伟大的一键安装脚本: ls cd ./main.sh
Step2: 安装miniconda,
step3: 安装cdsapi url key
pip install cdsapi 终端安装
import cdsapi
from datetime import date, timedelta
import os
client = cdsapi.Client()
# 指定保存目录,确保路径存在
save_dir = "/mnt/e/DownloadData/ERA5downloaddata"
if not os.path.exists(save_dir):
os.makedirs(save_dir)
# 定义起始和结束日期(左闭右开,不包含2023年1月1日)
start_date = date(2020, 1, 1)
end_date = date(2020, 1, 3)
delta = timedelta(days=1)
current_date = start_date
while current_date < end_date:
year_str = current_date.strftime("%Y")
month_str = current_date.strftime("%m")
day_str = current_date.strftime("%d")
request = {
"variable": ["2m_temperature"],
"year": year_str,
"month": month_str,
"day": day_str,
"daily_statistic": "daily_mean",
"time_zone": "utc+08:00",
"frequency": "1_hourly",
"area": [34, 115, 30, 119]
}
# 文件名格式为 yyyymmdd.nc,保存到指定目录
file_name = f"{year_str}{month_str}{day_str}.nc"
file_path = os.path.join(save_dir, file_name)
client.retrieve("derived-era5-land-daily-statistics", request).download(file_path)
print(f"Downloaded: {file_path}")
current_date += delta
Comments NOTHING