Temperature contour surface plot

3 views (last 30 days)
Juan
Juan on 18 Nov 2019
Commented: Ashfaq Ahmed on 14 Jul 2022
Hi,
I am trying to generate a 'simple' temperature map of the surface of the ocean for an specific region. However, all I get is a latitudinal gradient with no variations across longitudes (see figure). The data comes in three columns: latitude, longitude and temperature.
My code so far:
woa18SST=csvread('woa18_SST_5deg.csv',2,0,[2,0,40507,2]);
woa18SST=array2table(woa18SST,'VariableNames',{'Lat','Lon','SST'});
area1=woa18SST(woa18SST.Lat>=-30,:);
area1=area1(area1.Lat<=30,:);
figure
ax=worldmap([-30 30],[120 200])
load coastlines
surfm(area1.Lat, area1.Lon, area1.SST);
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(ax, land, 'FaceColor', [0.8 0.7 0.5])
tightmap;

Accepted Answer

Juan
Juan on 21 Nov 2019
Edited: Juan on 21 Nov 2019
So in case this might be useful for anyone I managed to solve this myself. My new code uses netCDF data rather than the threee column csv file. Iam sure is not pretty but seems to work OK.
%annual average surface temperature map for the western tropical pacific using data from the WORLD OCEAN ATLAS 2018 https://www.nodc.noaa.gov/OC5/woa18/woa18data.html
%%Define variables
clc; clear all ;
ncfile = 'woa18_decav_t00_04.nc' ; %loads temperature file
long = ncread(ncfile,'lon') ;nx = length(long) ;%obtains longiturdes and their size
lat = ncread(ncfile,'lat') ; ny = length(lat) ; %obtains latitudes and their size
time = ncread(ncfile,'time') ; nt = length(time) ; %reads the time variable and obtains its size
sst = ncread(ncfile,'t_an') ; %gets sea surface temperature value
[X,Y] = meshgrid(long,lat) ; % transform longitudes and latitudes into a grid of lon long x lat dimension
%% in case salinty wants to be used
ncfileS = 'woa18_decav_s00_04.nc' ; %loads salinity file
sal = ncread(ncfileS,'s_an'); %defines salinity variable
%%generates map
figure('Color','white'); %creates figure
ax=worldmap([-30 30],[130 -120]) % loads world map with the limits for the western tropical pacific
setm(ax,'mapprojection','mercator','Origin', [0 180 0]) %changes projection and changes origin reference for coordinates
levels=[18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34]; % creates levels for contours
geoshow(double(Y),double(X),sst','DisplayType','texturemap') %creates surface map of temperature
cb = contourcbar('peer',ax,'Location','southoutside'); %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 the Western Pacific Warm Pool
geoshow(double(Y),double(X),sst','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
and here is the final product.
  2 Comments
Ashfaq Ahmed
Ashfaq Ahmed on 14 Jul 2022
Hi @Juan! Thank you for this answer. It helped me a lot to understand the general process. However, when I try to plot a sea surface temperature within a small geographical location, say,
geolimits([41.25 41.75],[-71.45 -71.20])
I don't get any result using your algorithm. This is my .mat file (attached). Can you kindly give me an advice on this? Thank you again for your time.

Sign in to comment.

More Answers (0)

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!