I want to recenter spatial data from a grid of -180 to 180 lon to a grid of 0 - 360 lon. Using the command wrapTo360 leads to the issue below (see 2nd figure - you can see that the data > 180 shows an error). How can I reshape the rain/precipitation data accordingly so that the data is shifted correctly?
Help is very much appreciated.
dlat = load('latitude.mat');
lat = dlat.lat;
dlon = load('longitude.mat');
lon = dlon.lon;
dprec = load('rain.mat');
prec = dprec.prec;
lonW=wrapTo360(lon);
pcolor(lon,lat,prec);shading flat
pcolor(lonW,lat,prec);shading flat

 채택된 답변

Konrad
Konrad 2021년 11월 2일

0 개 추천

hi,
maybe I didn't get it, but why not just add 180?
lonW = lon + 180;

댓글 수: 3

JMSE
JMSE 2021년 11월 2일
Thanks, wrapping to 360 works, however I think there is a reshape of the rain data needed to make it work, accordingly to the new shape of the lon vector. I have tried different things with meshgrid, but cannot make it work.
Konrad
Konrad 2021년 11월 2일
편집: Konrad 2021년 11월 2일
I'm still not sure what you aim to achieve. To you want to preserve the order of your x-data (longitudes)? Then
pcolor(lon+180,lat,prec);shading flat
will give you longitudes from 0 to 360 on the x axis; everything else looks exactly like in your first plot.
In contrast, wrapTo360() changes e.g. -1 to 359, -180 to 180. So basically, the left half of your plot is moved to the right. pcolor() seems to expect sorted values, so you would have to do:
[lonW,idx] = sort(wrapTo360(lon));
precW = prec(:,idx);
figure;pcolor(lonW,lat,precW);shading flat;
Best, Konrad
JMSE
JMSE 2021년 11월 11일
Many thanks, it helped a lot.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 11월 2일

댓글:

2021년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by