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

6 ビュー (過去 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 Center および File ExchangeModel Building and Assessment についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by