How to set level values of a variable in a nc file
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Karthik M
am 8 Sep. 2021
Kommentiert: Karthik M
am 11 Sep. 2021
Hi Friends
With the below code
ncfile_1 = 'A20150322015059.L3m_MO_CHL_chlor_a_4km.nc';
lat_1 = ncread(ncfile_1,'lat') ;
lon_1 = ncread(ncfile_1,'lon') ;
chlor_a_1 = ncread(ncfile_1,'chlor_a');
[X_1,Y_1] = meshgrid(lon_1,lat_1) ;
xi_1 = linspace(30,100,1000) ;
yi_1 = linspace(0,30,1000) ;
[Xi_1,Yi_1] = meshgrid(xi_1,yi_1);
iwant_1 = interp2(X_1,Y_1,chlor_a_1',Xi_1,Yi_1)' ;
pcolor(xi_1,yi_1,iwant_1'); shading interp;
c = colorbar;
cmap = jet(255);
cmap(:,3) = 0;
colormap(cmap)
caxis([-5, 5])
I could able to interpolate and plot chlor_a conc. with respective x ,y need to display the minimum and maximum level of chlorophyll value for example min value <=10 and max value >= 0.
I have tried with this code but shows error
if chlor_a_1>=0 && chlor_a_1<=10
disp(chlor_a_1);
[Xi_1,Yi_1,chlor_a_1] = peaks;
plot(Xi_1,Yi_1,chlor_a_1,49)
kindly help
regards
3 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 9 Sep. 2021
hello again3
so I tried to a few things to get the min and max points of the data and display them (the big crosses)
I am still unsure about what was the intention : this is not clear to me : min value <=10 and max value >= 0.
your "raw" data has min value = 0.0593 and max value = 84.0117 but at the end you plot C axis is limited to 5 , so I guessed that the intention to find the max point is for the data after i's being truncated to scale 0 to 5 , so I decided to remove the data outside that range otherwise the max point will not be located at value = 5 . Now when you say min value <=10 and max value >= 0., I don't know what this 10 means
Code is :
ncfile_1 = 'A20150322015059.L3m_MO_CHL_chlor_a_4km.nc';
lat_1 = ncread(ncfile_1,'lat') ;
lon_1 = ncread(ncfile_1,'lon') ;
chlor_a_1 = ncread(ncfile_1,'chlor_a');
[X_1,Y_1] = meshgrid(lon_1,lat_1) ;
nn = 1000;
xi_1 = linspace(30,100,nn) ;
yi_1 = linspace(0,30,nn) ;
[Xi_1,Yi_1] = meshgrid(xi_1,yi_1);
iwant_1 = interp2(X_1,Y_1,chlor_a_1',Xi_1,Yi_1)' ;
% I could able to interpolate and plot chlor_a conc. with respective x ,y
% need to display the minimum and maximum level of chlorophyll value for example min value <=10 and max value >= 0.
% I have tried with this code but shows error
% rescale data between 0 and 10 (or 5 ?)
ind = find(iwant_1<0 | iwant_1>5);
iwant_1(ind) = NaN; % remove data out of range
% find min and max points
[min_val,min_ind] = min(iwant_1',[],'all','linear');
[r1,c1]=ind2sub(nn,min_ind);
x_min = xi_1(c1);
y_min = yi_1(r1);
[max_val,max_ind] = max(iwant_1',[],'all','linear');
[r2,c2]=ind2sub(nn,max_ind);
x_max = xi_1(c2);
y_max = yi_1(r2);
% plot
figure(1)
pcolor(xi_1,yi_1,iwant_1'); shading interp;
c = colorbar;
cmap = jet(255);
cmap(:,3) = 0;
colormap(cmap)
caxis([-5, 5])
hold on
plot(x_min,y_min,'k +', 'MarkerSize', 40);
plot(x_max,y_max,'m +', 'MarkerSize', 40);
hold off
legend('','min','max');
% if chlor_a_1>=0 && chlor_a_1<=10
% disp(chlor_a_1);
% [Xi_1,Yi_1,chlor_a_1] = peaks;
% plot(Xi_1,Yi_1,chlor_a_1,49)
10 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!