Python——读取grib文件

借鉴https://blog.csdn.net/m0_46671865/article/details/123518243

from pathlib import Path
import xarray as xr
import cfgrib
import numpy as np
import pygrib as pg
import matlibplot

model = 'EC'
dir_path = Path(f'/data1/luox/2023021400')
dict=list(dir_path.glob('W_NAFP*'))[2:]  # list the files from last 3rd file 

# module to get the time information of EC forecast results
filename = grib_file
year = filename.name.split('_')[4][0:4] # 从文件名中提取时间信息 year
mmddHH = filename.name.split('_')[6][11:17]  # the time of the end of forecast
forecast_time = datetime.datetime.strptime(year + mmddHH, '%Y%m%d%H') # 输出预报时间 the end of forecast
datetime_str_to = forecast_time.strftime("%Y%m%d%H%M%S") # the other form of the end of forecast time
cycle_str = filename.name.split('_')[6][3:9]
cycle = year + cycle_str # the start time of forecast
d_time = self.forecast_time - da
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值