此处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)