How to fix an inversed projection with m_map, pcolor ?

9 views (last 30 days)
I have an Netcdf files that includes latitude longitude and Sea Surface Temperature (SST) values. I would like to use m_pcolor to map out the SST on a gulf map I have already created. The code I have currently looks like this:
%%Read the data file;
f=dir('*.nc');
ncdisp('2017_SST_MED_SST_L4_NRT_OBSERVATIONS_010_004_a_V2_1537451234041.nc')
lon = ncread('2017_SST_MED_SST_L4_NRT_OBSERVATIONS_010_004_a_V2_1537451234041.nc','lon') ;
lat = ncread('2017_SST_MED_SST_L4_NRT_OBSERVATIONS_010_004_a_V2_1537451234041.nc','lat') ;
SST = ncread('2017_SST_MED_SST_L4_NRT_OBSERVATIONS_010_004_a_V2_1537451234041.nc','analysed_sst') ;
time = ncread('2017_SST_MED_SST_L4_NRT_OBSERVATIONS_010_004_a_V2_1537451234041.nc','time') ;
%%Zone;
chzon='TGM'; %chzon name of the zone
latmin=35.5
latmax=45.5
lonmin=5.0
lonmax=15.5
%%Geoloc destination;
klatz=[latmin:0.0625:latmax]; %0.0625 define the step of the data from the original file
klonz=[lonmin:0.0625:lonmax];
latlim=[latmin latmax];
lonlim=[lonmin lonmax];
%%Projection;
for i=1:365
m_proj('UTM','lon',lonlim,'lat',latlim);
m=klonz(1:161) % to define the same size as the latitude axis
h1 = pcolor(m,klatz,SST(1:161,:,i));
set(h1,'edgecolor','none');
shading flat;
axis image;
colorbar;
end
%%Grid;
grey=[0.9 0.9 0.9];
m_coast('patch',grey,'edgecolor','none') %for surface limit
m_coast('linewidth',1,'color','b'); %for line limits
m_grid
The problem in here that the map I get is inversed while I properly define the zone I want to plot in, while the grid shows exactly the limits of the zone but without containing the data set of longitude latitude and SST. (the attached photos shows the current problem):
M_pcolor :
The grid shows the appropriate zone as it is supposed to be:
I might be wrong, but I think it is a matter of type of data but am not really good with this, because format are like
  • SST (169x161x365 double)
  • klonz (1x169 double)
  • klatz (1x161 double)
Any Ideas ? Thanks in advance !

Accepted Answer

Silver
Silver on 25 Sep 2018
I have fixed the problem, it was the transpose :
h1 = pcolor(m',klatz',SST(1:161,:,i)');
But when I try to add:
%%Grid;
grey=[0.9 0.9 0.9];
m_coast('patch',grey,'edgecolor','none') %for surface limit
m_coast('linewidth',1,'color','b'); %for line limits
m_grid
my data disappears completely and leaves me with a half white and half green figure of Meditareaneen's coastline but my data has disappeared completely. And is it not problem of ordering my code. And any idea why I always have error messages when I try to use packages such as m_coast? By the way , I have already reset my path just in case using
rehash toolboxcache;

More Answers (0)

Community Treasure Hunt

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

Start Hunting!