Help with plotting world grid climate variable lat/lons

4 views (last 30 days)
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
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!

Answers (1)

Chad Greene
Chad Greene on 4 Mar 2019
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.

Categories

Find more on Climate Science and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!