微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

尝试计算时小型 xarray 对象杀死 Dask 工作器

如何解决尝试计算时小型 xarray 对象杀死 Dask 工作器

我正在使用每小时温度数据集,并尝试将其缩减为给定年份中给定国家/地区的每日最高/最低/平均值。我的代码如下:

def daily_temps_year(country,year,utc_offset):
    '''
    Takes in a country and a year and creates daily totals for that country (assuming the country spans a single time zone).
    '''
    full_year = xr.open_mfdataset(FILEPATH + year + '_*.nc')
    full_year = full_year.rename({'longitude': 'lon','latitude': 'lat'})
    full_year = full_year.assign_coords({"lon": (((full_year.lon + 180) % 360) - 180)})
    mask_3d = regionmask.defined_regions.natural_earth.countries_110.mask_3D(full_year)
    country = mask_3d.isel(region=(mask_3d.names == country))
    country = country.drop(['region','names','abbrevs'])
    country = country.squeeze(dim='region',drop=True)
    country_temp_full = full_year.where(country,drop=True)
    country_temp_full = country_temp_full.assign_coords({'time': country_temp_full.time+pd.timedelta(utc_offset,unit='h')})
    daily_avg = country_temp_full.resample(time='1D').mean()
    daily_max = country_temp_full.resample(time='1D').max()
    daily_min = country_temp_full.resample(time='1D').min()
    daily_avg = daily_avg.rename({'t2m': 'mean_temp'})
    daily_max = daily_max.rename({'t2m': 'max_temp'})
    daily_min = daily_min.rename({'t2m': 'min_temp'})
    merged_temp_full = xr.merge([daily_avg,daily_max,daily_min])
    return merged_temp_full

我在 2017 年运行了 Mali 的代码,它返回一个大小为 5.69 MB 的数组。当我尝试显示最大值、在数组上调用 .compute() 或将文件保存为 netCDF 时,dask 工作器会被杀死。 xr.open_mfdataset 打开的完整 2017 数据集大约为 40 GB,我在分布式计算集群上运行代码。当我打印出客户端对象时,它确认有 40 个工人和 160 GB 的内存,所以我不确定为什么它会超载。任何建议都会很棒!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。