简单目录

小记
科研任务需要,仅分享🛵~~
官网注册账号
官网地址https://data.marine.copernicus.eu/product/GLOBAL_MULTIYEAR_WAV_001_032/services
“注册账号(so easy),才可以下载数据集哦~~“
CMEMS下载数据集脚本
🍕🍕整个脚本自己修改需要的时间、变量以及经纬度!!!🌈🌈
脚本中下载的是0.2度分辨率的全球有效波高,
时间分辨率3h,
每天0、3、6、9、12、15、18、21的数据,
年份是1990-1999.
…
import copernicusmarine
import os
# Copernicus Marine Service 用户认证
USERNAME = "***" # 自己用户名
PASSWORD = "*****" # 自己账户密码
# 设置下载参数
DATASET_ID = "cmems_mod_glo_wav_my_0.2deg_PT3H-i" # 数据集ID,按需修改即可
VARIABLES = ["VHM0"] # 需要下载的变量,修改名称即可
MIN_LON, MAX_LON = -180, 179.8000030517578 # 经度范围
MIN_LAT, MAX_LAT = -89.80000305175781, 89.80000305175781 # 纬度范围
OUTPUT_DIR = "./SWH/" # 输出目录
os.makedirs(OUTPUT_DIR, exist_ok=True) # 创建目录
# 下载函数
def download_data(year):
start_datetime = f"{year}-01-01T00:00:00" # 这里也是按照自己需求修改时间
end_datetime = f"{year}-12-31T23:00:00"
output_filename = f"wave_{year}.nc"
output_path = os.path.join(OUTPUT_DIR, output_filename)
try:
print(f"Downloading data for year {year}...")
result_path = copernicusmarine.subset(
dataset_id=DATASET_ID,
variables=VARIABLES,
minimum_longitude=MIN_LON,
maximum_longitude=MAX_LON,
minimum_latitude=MIN_LAT,
maximum_latitude=MAX_LAT,
start_datetime=start_datetime,
end_datetime=end_datetime,
output_filename=output_filename,
output_directory=OUTPUT_DIR,
username=USERNAME,
password=PASSWORD
)
print(f"Year {year} download complete! File saved to: {result_path}")
except Exception as e:
print(f"Error downloading data for year {year}: {str(e)}")
# 主程序:遍历年份下载数据
if __name__ == "__main__":
for year in range(1990, 2000): # 下载年份自行修改
download_data(year)
print("All downloads completed!")
欢迎大家使用🎯 !!!