0

I have dekad rainfall from CHIRPS in netCDF: https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_dekad/netcdf/

1 dekad data in nc format is for 1 year ie. chirps-v2.0.1981.dekads.nc Then I merge all the nc files into single nc ncrcat *.nc merge.nc

Lastly, I would like to calculate 3-dekad rainfall accumulation (the result will equal to monthly accumulation) from dekad data, with rolling dekad accumulation. For example:

rain1981.01.1 + rain1981.01.2 + rain1981.01.3
rain1981.01.2 + rain1981.01.3 + rain1981.02.1
rain1981.01.3 + rain1981.02.1 + rain1981.02.2
...
rain2019.12.1 + rain2019.12.2 + rain2019.12.3

How to do that using CDO or NCO?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
user97103
  • 235
  • 1
  • 7

1 Answers1

0

I just found the solution for my above question. Here's the step using CDO.

  • Clip all downloaded nc files using bounding box: for fl in *.nc; do cdo sellonlatbox,94,145,-12,7 $fl clip"_"$fl; done
  • Merge all clipped nc files using: cdo mergetime clip_*.nc timeseries.nc
  • Calculate monthly accumulation: cdo runsum,3 input.nc output.nc

The output will produce 3-dekad rainfall accumulation with time information YYYY.MM.DD and the DD only have value 1,11 and 21 based on original input. Last step I would like to extract it into 3 difference file (extract1.nc, extract11.nc and extract21.nc). I used this formula: cdo selday,1 input.nc output.nc Change value 1 with 11 or 21 for next calculation.

user97103
  • 235
  • 1
  • 7
  • Please modify both your question and answer, so that it has some value to other users. It is not clear from either your question or your answer what you are trying to achieve. If you want a monthly sum, you just need to use monsum in cdo. – Robert Wilson Jul 07 '20 at 14:14
  • Yes I want to calculate monthly sum, but using dekad data and rolling. I am not sure if monsum is correct tool if the data ```rain1981.01.3, rain1981.02.1, and rain1981.02.2``` as explain in the example above. – user97103 Jul 07 '20 at 14:29
  • As I have said, you need to clarify the question. If you want a monthly sum, there is no reason to calculate a rolling sum. All you need to do is add the 3 numbers together. – Robert Wilson Jul 07 '20 at 14:35
  • The question is still confusing. If you want the monthly sum, you do not need to calculate any rolling stats. The question also still makes it seem that you want to modify the original data. – Robert Wilson Jul 07 '20 at 14:40
  • Hi I am sorry, I am not good on writing a question, would you please help me to edit it to make it clear for everybody? – user97103 Jul 07 '20 at 14:46
  • As I have said, I am not clear what you are actually trying to achieve. You have not explained why you calculating rolling sums, when there seems to be no reason for doing this. If all you want to do is calculate the monthly sum, then just ask that. – Robert Wilson Jul 07 '20 at 15:15