Project

General

Profile

SUM 30MINS DATA TO 6-HOURLY netCDF4

Added by Elvis Asong about 8 years ago

OS=LINUX

Hi All,
I have several netCDF4 files and each file is separated from the other by 30 minutes time step. The start time for accumulation is 00:00:00–00:29:59 UTC. I would like to sum the data by date:

[1] "2015-04-01 00:00:00 CST" "2015-04-01 00:30:00 CST" "2015-04-01 01:00:00 CST" "2015-04-01 01:30:00 CST"
[5] "2015-04-01 02:00:00 CST" "2015-04-01 02:30:00 CST" "2015-04-01 03:00:00 CST" "2015-04-01 03:30:00 CST"
[9] "2015-04-01 04:00:00 CST" "2015-04-01 04:30:00 CST" "2015-04-01 05:00:00 CST" "2015-04-01 05:30:00 CST"
[13] "2015-04-01 06:00:00 CST" "2015-04-01 06:30:00 CST" "2015-04-01 07:00:00 CST" "2015-04-01 07:30:00 CST"
[17] "2015-04-01 08:00:00 CST" "2015-04-01 08:30:00 CST" "2015-04-01 09:00:00 CST" "2015-04-01 09:30:00 CST"
[21] "2015-04-01 10:00:00 CST" "2015-04-01 10:30:00 CST" "2015-04-01 11:00:00 CST" "2015-04-01 11:30:00 CST"
[25] "2015-04-01 12:00:00 CST" "2015-04-01 12:30:00 CST" "2015-04-01 13:00:00 CST" "2015-04-01 13:30:00 CST"
[29] "2015-04-01 14:00:00 CST" "2015-04-01 14:30:00 CST" "2015-04-01 15:00:00 CST" "2015-04-01 15:30:00 CST"
[33] "2015-04-01 16:00:00 CST" "2015-04-01 16:30:00 CST" "2015-04-01 17:00:00 CST" "2015-04-01 17:30:00 CST"
[37] "2015-04-01 18:00:00 CST" "2015-04-01 18:30:00 CST" "2015-04-01 19:00:00 CST" "2015-04-01 19:30:00 CST"
[41] "2015-04-01 20:00:00 CST" "2015-04-01 20:30:00 CST" "2015-04-01 21:00:00 CST" "2015-04-01 21:30:00 CST"
[45] "2015-04-01 22:00:00 CST" "2015-04-01 22:30:00 CST" "2015-04-01 23:00:00 CST" "2015-04-01 23:30:00 CST"
[49] "2015-04-02 00:00:00 CST" "2015-04-02 00:30:00 CST" "2015-04-02 01:00:00 CST" "2015-04-02 01:30:00 CST"
[53] "2015-04-02 02:00:00 CST" "2015-04-02 02:30:00 CST" "2015-04-02 03:00:00 CST" "2015-04-02 03:30:00 CST"
[57] "2015-04-02 04:00:00 CST" "2015-04-02 04:30:00 CST" "2015-04-02 05:00:00 CST" "2015-04-02 05:30:00 CST"
[61] "2015-04-02 06:00:00 CST" "2015-04-02 06:30:00 CST" "2015-04-02 07:00:00 CST" "2015-04-02 07:30:00 CST"
[65] "2015-04-02 08:00:00 CST" "2015-04-02 08:30:00 CST" "2015-04-02 09:00:00 CST" "2015-04-02 09:30:00 CST"
[69] "2015-04-02 10:00:00 CST" "2015-04-02 10:30:00 CST" "2015-04-02 11:00:00 CST" "2015-04-02 11:30:00 CST"
[73] "2015-04-02 12:00:00 CST" "2015-04-02 12:30:00 CST" "2015-04-02 13:00:00 CST" "2015-04-02 13:30:00 CST"
[77] "2015-04-02 14:00:00 CST" "2015-04-02 14:30:00 CST" "2015-04-02 15:00:00 CST" "2015-04-02 15:30:00 CST"
[81] "2015-04-02 16:00:00 CST" "2015-04-02 16:30:00 CST" "2015-04-02 17:00:00 CST" "2015-04-02 17:30:00 CST"
[85] "2015-04-02 18:00:00 CST" "2015-04-02 18:30:00 CST" "2015-04-02 19:00:00 CST" "2015-04-02 19:30:00 CST"
[89] "2015-04-02 20:00:00 CST" "2015-04-02 20:30:00 CST" "2015-04-02 21:00:00 CST" "2015-04-02 21:30:00 CST"
[93] "2015-04-02 22:00:00 CST" "2015-04-02 22:30:00 CST" "2015-04-02 23:00:00 CST" "2015-04-02 23:30:00 CST"
[97] "2015-04-03 00:00:00 CST" "2015-04-03 00:30:00 CST" "2015-04-03 01:00:00 CST" "2015-04-03 01:30:00 CST"
[101] "2015-04-03 02:00:00 CST" "2015-04-03 02:30:00 CST" "2015-04-03 03:00:00 CST" "2015-04-03 03:30:00 CST"
[105] "2015-04-03 04:00:00 CST" "2015-04-03 04:30:00 CST" "2015-04-03 05:00:00 CST" "2015-04-03 05:30:00 CST"
[109] "2015-04-03 06:00:00 CST" "2015-04-03 06:30:00 CST" "2015-04-03 07:00:00 CST" "2015-04-03 07:30:00 CST"
[113] "2015-04-03 08:00:00 CST" "2015-04-03 08:30:00 CST" "2015-04-03 09:00:00 CST" "2015-04-03 09:30:00 CST"
[117] "2015-04-03 10:00:00 CST" "2015-04-03 10:30:00 CST" "2015-04-03 11:00:00 CST" "2015-04-03 11:30:00 CST"
[121] "2015-04-03 12:00:00 CST" "2015-04-03 12:30:00 CST" "2015-04-03 13:00:00 CST" "2015-04-03 13:30:00 CST"
[125] "2015-04-03 14:00:00 CST" "2015-04-03 14:30:00 CST" "2015-04-03 15:00:00 CST" "2015-04-03 15:30:00 CST"
[129] "2015-04-03 16:00:00 CST" "2015-04-03 16:30:00 CST" "2015-04-03 17:00:00 CST" "2015-04-03 17:30:00 CST"
[133] "2015-04-03 18:00:00 CST" "2015-04-03 18:30:00 CST" "2015-04-03 19:00:00 CST" "2015-04-03 19:30:00 CST"
[137] "2015-04-03 20:00:00 CST" "2015-04-03 20:30:00 CST" "2015-04-03 21:00:00 CST" "2015-04-03 21:30:00 CST"
[141] "2015-04-03 22:00:00 CST" "2015-04-03 22:30:00 CST" "2015-04-03 23:00:00 CST" "2015-04-03 23:30:00 CST"

such that the above becomes:

2015-04-01 00:00:00
2015-04-01 06:00:00
2015-04-01 12:00:00
2015-04-01 18:00:00
2015-04-02 00:00:00
2015-04-02 06:00:00 and so on ...
For example, if my data is sorted by time, I would have 12 "30 mins" time steps in 6 hours. Thus an index=1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 ... will suffice. Thus, sum all ones and you get "2015-01-01 00:00:00 UTC" , sum all twos and you get "2015-01-01 06:00:00 UTC", sum all threes and you get "2015-01-01 12:00:00 UTC" etc.

QUESTION:

- How can I implement this within CDO? I am very new to CDO commands.
- My files have no record dimension so I will like to add one to all files first.
- Then sum the 30mins timestep data to 6-hourly time step.
- The ofile should have a "time" variable with the 6-hourly time step. I can merge the ofiles using cdo mergetime *.nc4 outfile

The data files for illustration can be found here (and in the attached file list):
http://disc.sci.gsfc.nasa.gov/SSW/#keywords=GPM_3IMERGHH 03

Select 2015-04-01 to 2015-04-30 for Date Range. Spatial Bounding Box is empty. Running the following code on Linux assuming the attached file is in your current working directory the data will be downloaded quickly.

egrep -o '3B.*\.nc4' SSW_download_2016-02-26T05-59-11_65188_nM5bYSUv.inp >temp1.txt;paste SSW_download_2016-02-26T05-59-11_65188_nM5bYSUv.inp temp1.txt > temp2.txt ; awk 'system("wget "$1" -O "$2" ")' temp2.txt

SSW_download_2016-02-26T05-59-11_65188_nM5bYSUv.inp - file list you can download for illustration. (332 KB)