I am able to read the netcdf file format. But how to calculate average? Suppose I have to calculate the average from 1st January to 5th January, then again 6th January to 10th January and so on.....Below is the program to read the values.
조회 수: 1 (최근 30일)
이전 댓글 표시
ncid = netcdf.open('data.nc', 'NC_NOWRITE');
[ndim,nvar,natt,unlim] = netcdf.inq(ncid);
[dimname,dimlength]=netcdf.inqDim(ncid,0);
[dimname,dimlength]=netcdf.inqDim(ncid,1);
[dimname,dimlength]=netcdf.inqDim(ncid,2);
[dimname,dimlength]=netcdf.inqDim(ncid,3);
netcdf.inqDim(ncid,dimids);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 0);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 1);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 2);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 3);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 4);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 5);
lat = netcdf.getVar(ncid,0,0,72);
lon = netcdf.getVar(ncid,1,0,144);
precJanuary = netcdf.getVar(ncid,4,[0 0 0 0],[144 72 1 1]); % for january data
But how to calculate average? Suppose I have to calculate the average from 1st January to 5th January, then again 6th January to 10th January and so on.....
[Edited for code formatting -AU]
댓글 수: 0
채택된 답변
Ashish Uthama
2014년 8월 20일
I assume you know about mean but want to find out how to index into a netcdf variable to extract specific parts?
What does precJanuary contain? It looks like a 144x72x1x1 variable. Is that precipitation across an area for one day or one month? Your comment appears to indicate that its for the month. If so, there is no way to get the average for 1st to 5th since that information is already lost.
Is the third dimension your time dimension? Does your file contain precipitation data on a per day basis? i.e is the time dimension varying as one per day or month or?
Note: if you find the netcdf.* interface cumbersome. Consider using ncdisp and ncread. You are overwriting variables like varname, dimlength etc and its not clear what your intentions are with those multiple lines.
(Girija - it helps to add more information when you ask a question, there is higher chance of getting a better answer quickly).
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!