查找最近網(wǎng)格點(diǎn)【NCL處理NC數(shù)據(jù)】

在使用NCL處理nc文件時(shí),

如果是wrfout結(jié)果,可以用“wrf_ij_to_ll”、“wrf_ll_to_ij ”或者“wrf_user_xy_to_ll”函數(shù)找到距離特定位置(如觀測(cè)點(diǎn))對(duì)應(yīng)的網(wǎng)格文件中最近的網(wǎng)格點(diǎn);

如果是普通的netcdf文件,可能用distance和nearest關(guān)鍵字找不到想要的函數(shù),ncl在介紹時(shí)用了“closest”關(guān)鍵字。我們簡(jiǎn)單看一下兩個(gè)函數(shù)的差異:

wrf_ll_to_ij : Finds the nearest model grid indices (i,j) to the specified location(s) in longitude and latitude (deprecated). 翻譯為:查找經(jīng)度和緯度到指定位置最近的模型網(wǎng)格索引(i,j)。(不建議使用,6.6版本ncl建議使用更新的wrf_user_xy_to_ll等函數(shù))。

getind_latlon2d :Returns the indices (subscripts) of two-dimensional latitude/longitude arrays closest to a user-specified latitude/longitude coordinate pair.? 翻譯為:返回最接近用戶(hù)指定的緯度/經(jīng)度坐標(biāo)對(duì)的二維緯度/經(jīng)度數(shù)組的索引(下標(biāo))。

還有個(gè)特殊的重要問(wèn)題:有的矩形網(wǎng)格的nc文件中,lat和lon是線(xiàn)性變化的,所以是一緯數(shù)組。而上述函數(shù)使用的是二維數(shù)組作為被查閱的數(shù)據(jù),這時(shí)候就要將一維的數(shù)據(jù)轉(zhuǎn)換為二維數(shù)據(jù),方法如下:

? ? ? ? nlat_1d = dimsizes(lat_1d)

nlon_1d = dimsizes(lon_1d)

lat2d = conform_dims((/nlat_1d(0),nlon_1d(0)/),lat_1d,0) ;構(gòu)建netcdf文件二維經(jīng)緯度

lon2d = conform_dims((/nlat_1d(0),nlon_1d(0)/),lon_1d,1)

構(gòu)建好了就可以使用上述找最近距離的函數(shù)了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容