问题描述
此处 ds1
(jan) 和 ds2
(feb) 的样本总数为 100(1900 年 - 2000 年)
ds1 = xr.open_dataset('data1_jan.nc',decode_times=False) #.load()
ds2 = xr.open_dataset('data1_feb.nc',decode_times=False) #.load()
我从数据中选择随机时间作为例子。 50
fnu1 = ds1.isel(time=np.random.randint(0,ds1.time.size,n))
Now I want to extract similer random timesteps (50) from the second data file
fnu2 = ds2.isel(time=(dss.prec == ds1.time))
错误是:
ValueError: cannot reindex or align along dimension 'time' because the index has duplicate values
解决方法
也许这样的事情会有所帮助:
new_ds1 = ds1.where(ds1['time'].isin(ds2['time']),drop=True)
new_ds2 = ds2.where(ds2['time'].isin(new_ds1['time']),drop=True)