I want to represent the temperature variation at specific points of the equatorial atlantic ocean
2 次查看(过去 30 天)
显示 更早的评论
I would like to make a card like the one in the picture
clear all; close all; clc
ncfile = ('example.nc'); %loads temperature file
ncdisp(ncfile) %info about ncfile
sst = ncread(ncfile, 'to');
lon = ncread(ncfile,'longitude');
lat = ncread(ncfile,'latitude');
% Read in the sea_ice_fraction data and store in a new variable called ice:
%gets sea surface temperature value
time = ncread(ncfile,'time') ; nt = length(time) ; %reads the time variable and obtains its size
[X,Y] = meshgrid(lon,lat) ; % transform longitudes and latitudes into a grid of lon long x lat dimension
%%generates map
figure('Color','white'); %creates figure
ax=worldmap([55 70],[50 52]); % loads world map with the limits for atlantic ocean
newx= reshape(X, 383, 523);
nsst = permute(data,[1 3 2]);
nsst = reshape(nsst,[],size(data,2),1);
nsst= reshape(data, []);
%setm(ax,'mapprojection','mercator','Origin', [180 0 180]) %changes projection and changes origin reference for coordinates
levels=[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ]; % creates levels for contours
geoshow(double(Y),double(X),nsst,'DisplayType','texturemap') %creates surface map of temperature
cb = contourcbar('peer',ax,'Location','northoutside'); %creates colorbar
caxis([15 35]) %defines limits for colorbar
colormap(jet) %sets color scheme
set(get(cb,'XLabel'),'String','SST (^oC)') %title for color bar
set(cb,'Position',[0.23 0.2417 0.5750 0.0335]) %adjust location and size of color bar
%levels=[28]; %sets level for contour defining specific
geoshow(double(Y),double(X),data,'DisplayType', 'contour','LevelList',levels,'LineColor','black') %plots temperature contour defining the western Pacific Warm Pool
hold on
land = shaperead('landareas.shp', 'UseGeoCoords', true); %define land areas
geoshow(land, 'FaceColor', [0 0 0]) % plots land areas in black
0 个评论
采纳的回答
Voss
2023-8-22
unzip example.zip
ncfile = ('example.nc'); %loads temperature file
ncdisp(ncfile) %info about ncfile
sst = ncread(ncfile, 'to');
lon = double(ncread(ncfile,'longitude'));
lat = double(ncread(ncfile,'latitude'));
time = ncread(ncfile,'time');
nt = length(time);
[X,Y] = meshgrid(lon,lat);
figure('Color','white');
ax = worldmap([min(lat) max(lat)],[min(lon) max(lon)]); % loads world map with the limits for the data
nsst = permute(sst(:,:,:,1),[2 1 3]);
c_limits = [min(nsst,[],'all') max(nsst,[],'all')];
geoshow(double(Y),double(X),nsst,'DisplayType','texturemap') %creates surface map of temperature
cb = contourcbar('peer',ax,'Location','northoutside'); %creates colorbar
caxis(c_limits) %defines limits for colorbar
colormap(jet) %sets color scheme
set(get(cb,'XLabel'),'String','SST (^oC)') %title for color bar
levels = ceil(c_limits(1)*10)/10:0.1:floor(c_limits(2)*10)/10; % levels for contour
geoshow(double(Y),double(X),nsst,'DisplayType', 'contour','LevelList',levels,'LineColor','black') %plots temperature contour defining the western Pacific Warm Pool
land = shaperead('landareas.shp', 'UseGeoCoords', true); %define land areas
geoshow(land, 'FaceColor', [0 0 0]) % plots land areas in black
2 个评论
Voss
2023-8-23
You can use time, sure. I picked the first time:
nsst = permute(sst(:,:,:,1),[2 1 3]);
% ^ first time index
but you can use any value up to nt. The result will be a different contour/surface plot corresponding to the time index you pick.
To smooth out the surface, you can add 'FaceColor','interp' to the first geoshow call, as below:
unzip example.zip
ncfile = ('example.nc'); %loads temperature file
ncdisp(ncfile) %info about ncfile
sst = ncread(ncfile, 'to');
lon = double(ncread(ncfile,'longitude'));
lat = double(ncread(ncfile,'latitude'));
time = ncread(ncfile,'time');
nt = length(time);
[X,Y] = meshgrid(lon,lat);
figure('Color','white');
ax = worldmap([min(lat) max(lat)],[min(lon) max(lon)]); % loads world map with the limits for the data
nsst = permute(sst(:,:,:,1),[2 1 3]);
c_limits = [min(nsst,[],'all') max(nsst,[],'all')];
geoshow(double(Y),double(X),nsst,'DisplayType','texturemap','FaceColor','interp') %creates surface map of temperature
cb = contourcbar('peer',ax,'Location','northoutside'); %creates colorbar
caxis(c_limits) %defines limits for colorbar
colormap(jet) %sets color scheme
set(get(cb,'XLabel'),'String','SST (^oC)') %title for color bar
levels = ceil(c_limits(1)*10)/10:0.1:floor(c_limits(2)*10)/10; % levels for contour
geoshow(double(Y),double(X),nsst,'DisplayType', 'contour','LevelList',levels,'LineColor','black') %plots temperature contour defining the western Pacific Warm Pool
land = shaperead('landareas.shp', 'UseGeoCoords', true); %define land areas
geoshow(land, 'FaceColor', [0 0 0]) % plots land areas in black
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!