[英]How to get a specific information from the header of a netcdf file using python?
[英]Python - How to get variable from netcdf file on a specific location and at different level
我正在學習如何從WRF輸出netcdf文件中繪制各種變量。 我的要求是提取某個經度/緯度(8.4875°N,76.9525°E)的變量,以便使用matplotlib軟件包繪制SkewT輪廓。
我在此SO頁面netcdf4提取物中找到了一個類似的問題, 即lat lon的子集 。 但是,它的位置是一組邊界。
查看X射線 。 您需要做一些工作來制作SkewT圖表,但是訪問和匯總netCDF數據集和變量將非常容易。 下面只是幾個例子。
import xray
ds = xray.open_dataset('your_wrf_file.nc')
ds_point = ds.sel(lon=76.9525, lat=8.4875)
ds_point['Temperature'].plot() # plot profile at point assuming Temperature had dimensions of (level, lat, lon)
df = ds_point.to_dataframe() # export dataset to Pandas.DataFrame
temp_array = ds_point['Temperature'].values # access the underlying numpy array of the "Temperature" variable
我通常要做的是在使用ncl,python,R等進行繪圖之前,使用CDO從命令行中提取最接近網格點的列:
cdo remapnn,lon=76.9525/lat=8.4875 wrf_file.nc pnt_file.nc
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.