Plot variables from WRF-NetCDF

조회 수: 24 (최근 30일)
Emanuel Valdes
Emanuel Valdes 2019년 3월 18일
댓글: Philip Anderson 2024년 11월 1일 19:52
I'm trying to plot the variable T2 (temperature at 2meters) from my netCDF file, made in Weather Research and Forecasting (WRF) Model. I was following the example of this video: https://www.youtube.com/watch?v=PJurb-IPKM8
Here is my code:
filename = 'wrfout_d03_2018-06-01_00';
ncdisp(filename);
temp = ncread (filename,'T2');
lat = ncread (filename,'XLAT');
lon = ncread (filename,'XLONG');
mapin = pcolor(lon,lat,temp')
load coast
hold on
plot(long,lat,'k','LineWidth',1.5)
plot(long+360,lat,'k','LineWidth',1.5)
The problem is that my variables have 3 dimensions instead of 2. Is there any way of get latitude and longitude from variables XLAT and XLONG?
  댓글 수: 3
Emanuel Valdes
Emanuel Valdes 2019년 3월 18일
편집: Emanuel Valdes 2019년 3월 18일
Sorry, I'm not getting your question. T2 it's temperature at 2 meters of height. I guess this is my problem:
Philip Anderson
Philip Anderson 2024년 11월 1일 19:52
Look at the size of "temp" (and lat etc): likely something like 195x285x8 . The last dimension (x8) are 8 consecutive records, spaced at ~10 minute apart. lat and long don't actually change, and you can pick just one of the T2 records, (e.g. 1st) then use
temp2D = squeeze(temp(:,:,1));
lat2D = squeeze(lat(:,:,1));
etc.
Apologies for my clunky Matlab.

댓글을 달려면 로그인하십시오.

답변 (1개)

Werner Barros
Werner Barros 2019년 10월 22일
You can use the function squeeze(variable)

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by