please I need help to complete the descriptive statistics and representation of the following figures.

3 次查看(过去 30 天)
need help for the descriptive statistics of the following parameters depending on the year (time). but my variables are in 4D difficult for me to manipulate them please. my problem is with the extraction of carbonate variables, etc.. also the representation of these variables as a function of time in a format like (example: 2000,2003...)
need help for the descriptive statistics of the following parameters depending on the year (time). but my variables are in 4D difficult for me to manipulate them please. my problem is with the extraction of carbonate variables, etc.. also the representation of these variables as a function of time in a format like (example: 2000,2003...)
Ocolor=("global-analysis-forecast-bio-001-028-monthly_1693423231336.nc")
ncdisp (Ocolor)
lon=double(ncread(Ocolor,"longitude"));
lat=double(ncread(Ocolor,"latitude"));
dep=double(ncread(Ocolor,"depth")
[Lon,Lat]=meshgrid(lon,lat);
Time=double(ncread(Ocolor,"time"));
%Carbonate System
AT=ncread(Ocolor,"talk");
pbH=ncread(Ocolor,"ph");
DIC=ncread(Ocolor,"dissic");
PCO2=ncread(Ocolor,"spco2");
%Nutrient
NO3=ncread(Ocolor,"no3");
O2=ncread(Ocolor,"o2");
PO4=ncread(Ocolor,"po4");
Si=ncread(Ocolor,"si");
Fe=ncread(Ocolor,"fe");
%Primary Production
Phyc=ncread(Ocolor,"phyc"); %total phytoplankton
Nppv=ncread(Ocolor,"nppv"); %Total Primary Production of Phyto
Chl=ncread(Ocolor,"chl");
  2 个评论
dpb
dpb 2023-9-11
d=dir('*.zip');
unzip(d.name)
Ocolor=("global-analysis-forecast-bio-001-028-monthly_1693423231336.nc");
ncdisp (Ocolor);
OK, that looks pretty straightforward to index into by desired direction, give us an example of what specific "summary statistics" you're looking for for a given variable...
Victor Ebolo
Victor Ebolo 2023-9-11
编辑:Victor Ebolo 2023-9-12
@dpb Good evening please I would like to have the average, max, min, standard deviation. Linear regression between pH, talk, DIC, Chl for example. And represented for example the pH on a surface of longitude, latitude and depth. Then I could do the rest myself
Thank you in advance for your help.

请先登录,再进行评论。

采纳的回答

William Rose
William Rose 2023-9-11
fileIn="global-analysis-forecast-bio-001-028-monthly_1693423231336.nc";
t=ncread(fileIn,'time');
The time data is stored as integers representing hours since 01-Jan-1950. Therefore we convert hours to seconds and convert seconds to datetimes, as shown below:
dt=datetime(t*3600,'ConvertFrom','epochtime','Epoch','1950-01-01');
To confirm that the code above worked, we display the first three date-time values:
disp(dt(1:3)')
16-Nov-2020 00:00:00 16-Dec-2020 12:00:00 16-Jan-2021 12:00:00
Get info about the .nc file:
fInfo=ncinfo(fileIn);
Display fInfo.Dimensions (below). We see the data file includes data for 32 times, 8 latitudes, 9 longitudes, 3 depths.
Load some carbonate data and display the array size:
spco2=ncread(fileIn,"spco2");
disp(size(spco2))
9 8 32
This suggests that spco2 is given on a 9x8 long,lat grid, at 32 times.
You said you want descriptive statistics, and information across time. You can do that as follows:
spco2meanAll=mean(spco2,'All') % mean spco2 across all locations and times
spco2meanAll = 36.2425
Next, we find the mean spCO2 at each time, by averaging across all locations. We do this by averaging across dimensions 1 and 2. We squeeze the result to eliminate uneeded dimensions from the result.
spco2meant=squeeze(mean(spco2,[1 2])); % mean spco2 across all locations, each time is separate
Plot mean spco2 for each month versus time:
plot(dt,spco2meant,'-rx');
xlabel('Time'), ylabel('pCO_2 (Pa)')
grid on; title('Mean pCO_2 versus time')
which produces the figure below.
The plot shows that pCO2 reaches a local minimum in December of each year.
Best wishes with your research!
  4 个评论
Victor Ebolo
Victor Ebolo 2023-9-12
@William Rose thank you .
please could you have a script that can allow me to have figures like the one I sent above? I would like to represent a distribution of this data. I used surf(lon,lat,pH) but it shows error.
William Rose
William Rose 2023-9-12
unzip('global-analysis-forecast-bio-001-028-monthly_1693423231336.zip')
fileIn=("global-analysis-forecast-bio-001-028-monthly_1693423231336.nc");
fInfo=ncinfo(fileIn);
t=ncread(fileIn,'time');
dt=datetime(t*3600,'ConvertFrom','epochtime','Epoch','1950-01-01');
spco2=ncread(fileIn,"spco2");
latitude=ncread(fileIn,"latitude");
longitude=ncread(fileIn,"longitude");
spco2meanT=squeeze(mean(spco2,[1 2])); % mean spco2 at each time, across all lat,long
spco2meanLL=mean(spco2,3); % mean spco2 at each Lat & Long, across all times
Plot the mean pCO2 at each Lat,Long:
surf(latitude,longitude,spco2meanLL)
ylabel('Longitude (+E)'); xlabel('Latitude (+N)'); zlabel('pCO_2')
title('Time-averaged pCO_2 at each Lat,Long')
colorbar; view(90,-90)
This looks good.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by