Help with plotting world grid climate variable lat/lons
5 次查看(过去 30 天)
显示 更早的评论
I am really stuck on this one... What I am trying to do, is, convert longitude values that are from 0 to 360 to -180 to 180, and then plot sea ice concentration. The data can be downloaded here (I got year 2007)
However, it seems like half of my map is completely wrong! This is how I am doing it:
bad = -9.9692100e+36;
file = '/Users/mdortiz/Documents/NPP/Data/noaa_ice/icec.day.mean.2007.nc';
icec = ncread(file,'icec');
%%For June 20th, 2007 only
icecjune20 = icec(:,:,171); %icecjune20 is 1440 x 720 , double
%%insert NaNs where missing number is found
ind = find(icecjune20 == bad);
icecjune20(ind) = NaN;
%%Make the lat/lon grid
flat = [-89.875:0.25:89.875]; % flat is 1 x 720 ,double
flon = [0.125:0.25:359.875]; % flon is 1 x 1440 ,double
glon = zeros(size(flon)); % glon is 1 x 1440 ,double
%%This piece of code "transforms" longitude from 0 to 360, to -180 to 180
for i = 1:length(glon)
glon(i)=rem((flon(i)+180),360)-180;
end
%%Make the actual grid: for every value of icecjune20, we have a lat/lon
%%flat is now 1440 x 720
%%glon is now 1440 x 720
[flat, glon ] = meshgrid(flat,glon);
%%plot the data
%%NOTE: THIS SEEMS A BIT WEIRD...
h = figure
pcolor(glon,flat,icecjune20);
shading flat
c = colorbar;
ylabel(c,'Concentration')
load coast
hold on
plot(long,lat,'black')
title('Ice concentration 2007 June 20th')
xlabel('degrees longitude')
ylabel('degrees latitude')
%make all zeros white
myColorMap = jet(256);
myColorMap(1,:) = 1;
colormap(myColorMap);
caxis([0, 1]) %limits of the color bar
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171813/image.png)
What am I doing wrong? I need my longitudes to be in the form of -180 to 180, because the next step is to regrid this data set to another (MERRA-2) which is in this format. Any help would be appreciated!
0 个评论
回答(1 个)
Chad Greene
2019-3-4
Hi Macarena,
I wrote the recenter function in the Cimate Data Toolbox to do exactly what you want to do. It lets you move a grid's center longitude to any arbitrary longitude.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Climate Science and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!