第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

重新網(wǎng)格化 Python xarray 坐標(biāo)

重新網(wǎng)格化 Python xarray 坐標(biāo)

胡子哥哥 2022-07-12 15:53:02
您可以通過(guò)迭代字典中的每個(gè)項(xiàng)目來(lái)做到這一點(diǎn),但是在大型數(shù)據(jù)集中它可能效率低下。def get_key(data, query):    for key, value in data.items():        if query in value[0][1]:            return key    return 'Not Found'get_key(dictonary, word)然后,即使您的查找未能找到匹配項(xiàng),您也可以調(diào)用您的函數(shù)并返回結(jié)果。# Note i changed the name of the dictionary to dicton, as dict shouldn't be used as a variable nameprint(get_key(dicton, 'three'))print(get_key(dicton, 'seven'))print(get_key(dicton, 'four'))#a#Not Found#b我有一些 0.2 度和 1 度分辨率的虛擬數(shù)據(jù)。我想對(duì) foo 進(jìn)行二次采樣,使其與 foo1 的比例相同。有什么簡(jiǎn)單的方法可以以某種方式平均和重新排列我的經(jīng)緯度坐標(biāo)嗎?import pandas as pdimport xarray as xrimport matplotlib.pyplot as plt#Set at 0.2 degree grids ishfreq=20lats=240lons=1020time=pd.date_range('2000-01',periods=freq,freq='Y')data=np.random.rand(freq,lats,lons)lat=np.linspace(-19.5,19.5,lats)lon=np.linspace(120,290,lons)foo = xr.DataArray(data, coords=[time, lat,lon], dims=['time', 'lat','lon'])foo.sel(time='2005',method='nearest').plot()plt.show()#Set at 1 degree gridsfreq1=20lats1=40 #Factor of 6 differencelons1=170time1=pd.date_range('2000-01',periods=freq1,freq='Y')data1=np.random.rand(freq1,lats1,lons1)lat1=np.linspace(-19.5,19.5,lats1)lon1=np.linspace(120,290,lons1)foo1 = xr.DataArray(data1, coords=[time1, lat1,lon1], dims=['time', 'lat','lon'])foo1.sel(time='2005',method='nearest').plot()plt.show()
查看完整描述

2 回答

?
慕妹3242003

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超6個(gè)贊

Xarray 可以線性插值緯度和經(jīng)度,就好像它們是笛卡爾坐標(biāo)一樣(如上面的示例),但這與適當(dāng)?shù)牡乩碇匦戮W(wǎng)格化不同。為此,您可能想查看xesmf



查看完整回答
反對(duì) 回復(fù) 2022-07-12
?
慕工程0101907

TA貢獻(xiàn)1887條經(jīng)驗(yàn) 獲得超5個(gè)贊

我決定最簡(jiǎn)單的方法是使用 foo1 網(wǎng)格進(jìn)行解釋。


因此:


foo2=foo.interp(lat=lat1).interp(lon=lon1)

foo2.sel(time='2005',method='nearest').plot()

應(yīng)生成準(zhǔn)確的子采樣網(wǎng)格圖。


查看完整回答
反對(duì) 回復(fù) 2022-07-12
  • 2 回答
  • 0 關(guān)注
  • 246 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)