Hi, I'd like to see the temperature on a surface map of lon (-20 20) and lat (-10 10).I'd like to have an idea so that this script gives me a better visual like on the figure?

5 visualizaciones (últimos 30 días)
if true
  %annual average surface temperature map for the gulf of guinea
%%Define variables
clear all ; close all;clc
ncfile = readtable('tropical_atlantic.csv') ; %loads temperature file
lon = ncfile.LONGITUDE ;nx = length(long) ;%obtains longiturdes and their size
lat = ncfile.LATITUDE ; ny = length(lat) ; %obtains latitudes and their size
time = ncfile.DATE ; nt = length(time) ; %reads the time variable and obtains its size
sst = ncfile.x_DEG_C ; %gets sea surface temperature value 
%initialisation 
N=100
lon0=-20; lon1=20; lat0=-10:lat1=10;
x=linespace(lon0,lon1,N);
y=linespace(lat0,lat1,N);
end
if true
  %ineterpolate temperature 
[X,Y]=meshgrid (lon,lat) S=scartteredInterpolant (lon,lat, sst); 
Z=S(X,Y);
m_proj('miller',...
'lat',[min(y(:)) max(y(:))],...
'lon',[min(x(:)) max(x(:))])
m_pcolor(X,Y,Z);
shading flat;
m_coast('patch',[.7 .7 .7])
m_grid('box','fancy')
colorbar
title(' SST from 2005 to 2007');
 end
  |My problem is that the interpolation gives extremely large values. Can anyone come up with an idea to get interpolation values that more or less reflect reality? Or perhaps another method of displaying my data on a map similar to the one I sent? Initially my temperature is below 30 but this method gives me temperatures above 60 which doesn't suit me. Any help is welcome.Thanks in advance |

Respuesta aceptada

KSSV
KSSV el 28 de Mzo. de 2024
You need to make the values lying outside the given scattered points to NaN. For outside values, the function will extrapolate which gives higher values.
clc; clear all ;
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1650731/tropical_atlantic.csv') ;
%annual average surface temperature map for the gulf of guinea
%%Define variables
lon = T.LONGITUDE ; nx = length(lon) ;%obtains longiturdes and their size
lat = T.LATITUDE ; ny = length(lat) ; %obtains latitudes and their size
time = T.DATE ; nt = length(time) ; %reads the time variable and obtains its size
sst = T.x_DEG_C ; %gets sea surface temperature value
%initialisation
N=100 ;
lon0=-20; lon1=20; lat0=-10; lat1=10;
x=linspace(lon0,lon1,N);
y=linspace(lat0,lat1,N);
%ineterpolate temperature
[X,Y]=meshgrid (lon,lat);
S=scatteredInterpolant(lon,lat, sst);
S.ExtrapolationMethod = 'none' ; %<---- this does the trick
Z=S(X,Y);
%
m_proj('miller',...
'lat',[lat0 lat1],...
'lon',[lon0 lon1])
m_pcolor(X,Y,Z);
shading flat;
m_coast('patch',[.7 .7 .7])
m_grid('box','fancy')
colorbar
title(' SST from 2005 to 2007');

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by