Quiver plot for Wind data of reanalysis

I plan to use Matlab to plot wind of reanalysis that I downloaded from this website: https://psl.noaa.gov/data/gridded/data.ncep.reanalysis2.pressure.html
However, the result is not as expected. I send the sample of data in this posting.
I hope the result is like the image below (run by other software).
I use the following Matlab script:
lon1=load('lon.txt');
lat1=load('lat.txt');
u=load('u.txt');
v=load('v.txt');
coast=load('world_coastline.txt');
lon1q=repmat(lon1',73,1);
lat1q=repmat(lat1,1,144);
quiver(lon1q, lat1q,u',v',1,'k','LineWidth',1)
hold on
plot(coast(:,1), coast(:,2),'k','LineWidth',1.0)
xlim([90 110]);
ylim([-8 8]);
hold off
set(gca,'TickDir','out','FontName','Times New Roman','LineWidth',1);
Hoewever, the result is strange, as given below:
I tried several combinations, and found the quiver below to give somewhat similar results (still different).
quiver(lon1q, flipud(lat1q),flipud(u'),(v')*-1,1,'k','LineWidth',1)
Result
Perhaps some of you have used quiver plots for data reanalysis, and please share your experiences. Thank you very much.

 Accepted Answer

Part of the issue is a mismatch between your coastline data and your quiver data. If you zoom all the way out, you will see what I mean.
load windData
[lat1q,lon1q]=meshgrid(lat1,lon1);
quiver(lon1q, lat1q,u,v,1,'k','LineWidth',1)
hold on
plot(coast(:,1), coast(:,2),'k','LineWidth',1.0)
hold off
set(gca,'TickDir','out','FontName','Times New Roman','LineWidth',1);
Use wrapTo180 on the longitudinal data to fix that.
figure
quiver(wrapTo180(lon1q), lat1q,u,v,1,'k','LineWidth',1)
hold on
plot(coast(:,1), coast(:,2),'k','LineWidth',1.0)
hold off
set(gca,'TickDir','out','FontName','Times New Roman','LineWidth',1);
If you have the Mapping Toolbox, you could do the following. To me, the coastlines look a little better.
figure
axesm('eqdcylin')%,"MapLonLimit",[90 110],"MapLatLimit",[-8 8]);
plotm(coast(:,2), coast(:,1),'k','LineWidth',1.0)
[Lon,Lat] = meshgrid(lon1,lat1);
quiverm(Lat,Lon,u',v')
I'm not sure I like the idea of arbitrarily flipping matrices to try to get an expected output. Do you have any information on how the other software processes the data? Are you sure you are using the same data in both places?

4 Comments

Thank you @Cris LaPierre I just downloaded the data from the above link (Monthly Mean data). The data coverage: 1979/01/01 to 2021/10/31. To test the quiver, I just plotted the data for the first observation (may be 1979/01 or 1979/01). My first figure is plotted using NCL (https://www.ncl.ucar.edu/Applications/vector.shtml)
Thank you. That is helpful information. It looks like the u and v values you have shared here are different from the ones you are using in NCL. If I download the data directly from the website, are create the quiver plot using it, I get something similar to your original plot. I have to save the variables to a mat file to upload it here.
% load data
load windData
% ncdisp('uwnd.mon.mean.nc')
% lat = double(ncread('uwnd.mon.mean.nc','lat'));
% lon = double(ncread('uwnd.mon.mean.nc','lon'));
% uU = double(ncread('uwnd.mon.mean.nc','uwnd'));
% u = squeeze(uU(:,:,1,1));
% t = double(ncread('uwnd.mon.mean.nc','time'));
% l = double(ncread("uwnd.mon.mean.nc",'level'));
%
% ncdisp('vwnd.mon.mean.nc')
% vV = double(ncread('vwnd.mon.mean.nc','vwnd'));
% v = squeeze(vV(:,:,1,1));
% Determine date of plotted data ('hours since 1800-1-1 00:00:00')
d=datetime(1800,1,1) + hours(t(1))
d = datetime
01-Jan-1979
% Determine level (millibar)
l(1)
ans = 1000
coast=load('world_coastline.txt');
% Create plot
[LN,LT] = meshgrid(lon,lat);
quiver(wrapTo180(LN),LT,u',v')
hold on
plot(coast(:,1), coast(:,2),'k','LineWidth',1.0)
hold off
xlim([90 110]);
ylim([-8 8]);
set(gca,'TickDir','out','FontName','Times New Roman','LineWidth',1);
Thank you @Cris LaPierre . It is really helpfull. I've checked my data, the data is the same as yours, but the data processing process is slightly different, where I replaced missing_value with NaN, for example:
ncid1 = netcdf.open('uwnd.mon.mean.nc');
varid1 = netcdf.inqVarID(ncid1,'uwnd');
v_longway = netcdf.getVar(ncid1,varid1);
missing_value = netcdf.getAtt(ncid1,varid1,'missing_value');
v_longway(v_longway==missing_value)=NaN;
v=double(v_longway(:,:,1,1));
netcdf.close(ncid1);
does this affect the results?
But it solved, thank you again.
No, your code returns the same result as mine. I checked using isequal. However, your code is assigning the variable v to what should be u (comes from uwnd, not vwnd).
That gave me the insight to figure out what was happening. When I check your u and v matrices, they are the same. You accidentally loaded the uwnd data for both the u and v components. That means the original quiver command was
quiver(lon1q, lat1q,u',u',1,'k','LineWidth',1)
% ^^

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!