How to set level values of a variable in a nc file

1 回表示 (過去 30 日間)
Karthik M
Karthik M 2021 年 9 月 8 日
コメント済み: Karthik M 2021 年 9 月 11 日
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 件のコメント
Karthik M
Karthik M 2021 年 9 月 9 日
Thank you for the response

サインインしてコメントする。

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 9 月 9 日
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 件のコメント
Karthik M
Karthik M 2021 年 9 月 10 日
Thanks @Walter Roberson for your deatiled eplaination
kindly help for the below steps using 2 nc files
want to save file in nc format for 1st file before plot and same for next ...
Need to subtract (present to past year) compare 2 years same month of extracted chlor_a data
[+ve] value means max chlor_a conc. [-ve] value means less conc.
This comparison will identify max persistence of chlor_a
objective to find particular month chlor conc. hotspot for successive years
I couldn't able to arrive what I want
regards
Karthik M
Karthik M 2021 年 9 月 11 日
kindly help for the below steps using 2 nc files
want to save file in nc format for 1st file before plot and same for next ...
Need to subtract (present to past year) compare 2 years same month of extracted chlor_a data
[+ve] value means max chlor_a conc. [-ve] value means less conc.
This comparison will identify max persistence of chlor_a
objective to find particular month chlor conc. hotspot for successive years
I couldn't able to arrive what I want
regards

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by