필터 지우기
필터 지우기

how can I take mean of fourth dimension of daily data?

조회 수: 3 (최근 30일)
Aarti Soni
Aarti Soni 2022년 9월 8일
편집: Cris LaPierre 2022년 10월 3일
I have hourly data and I want to convert it into monthly mean.
I have daily data for 20 years (.nc files) and the structure of the daily data is 180 X 360 X 4 X 8, where 8 is hourly data. I want to take mean of 8hours that will represent observation of the day and then finally want to convert it into monthly.
Any kind of help would be appreciated.
Thanks
  댓글 수: 15
Aarti Soni
Aarti Soni 2022년 10월 3일
이동: Cris LaPierre 2022년 10월 3일
Yes the SM variable contains NaN. I tried to save with values but the file size was exceeding the size (>5Mb), so I replaced all the values with NaN.
Cris LaPierre
Cris LaPierre 2022년 10월 3일
편집: Cris LaPierre 2022년 10월 3일
SM is an array of data type single. Singles are 32 bit numbers. So saving 75x100x4x8 = 240,000 singles at 4 bytes per number should yield a mat file size of approximately 960 KB, well under the 5 MB upload limit. Including Times and lev only adds 0.1 KB.

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2022년 10월 3일
편집: Cris LaPierre 2022년 10월 3일
I see your times are recorded as decimal days:
Times =
0
0.1250
0.2500
0.3750
0.5000
0.6250
0.7500
0.8750
Note that you have measurements taken at 4 levels each time (your 3rd dimension)
lev =
1
2
3
4
Therefore, the most logical way to me to compute a daily average is to compute the mean of the 8 SM values at each lon/lat pair and each level. This means the result will by lon x lat x lev (e.g. 50x50x4)
This cam be accomplished by useing the mean function and specifiying which dimension to take the mean in. Here, that is the 4th dimension, or time.
dayAvg = mean(SM,4);
Your file only contains information for a single day, so you would need to take the average of each file and then combine the results to compute a monthly average. Again, you will have a daily average for each leavel (4 values per lon/lat pair).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model Building and Assessment에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by