Temperature contour surface plot

24 vues (au cours des 30 derniers jours)
Juan
Juan le 18 Nov 2019
Commenté : Ashfaq Ahmed le 14 Juil 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;

Réponse acceptée

Juan
Juan le 21 Nov 2019
Modifié(e) : Juan le 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 commentaires
Diana Berriel Bueno
Diana Berriel Bueno le 6 Juil 2022
Thanks! It was very useful
Ashfaq Ahmed
Ashfaq Ahmed le 14 Juil 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by