-2

I'm really new to this CDO thing and I feel awkward.

I have been working with netcdf files that have daily precipitation data and I would like to perform these calculations with CDO

  • First calculate the moving sum of precipitation using a 5-day window.

-Then calculate the annual maximum of the sliding sum for each year.

-And finally, calculate the 20-year average of those values

  • I don't quite follow the question. What does this mean? "5 consecutive days where the accumulated precipitation is maximum" What is the maximum in this case? It sounds like you mean annual maximum, but in that case I don't understand why you would have 5 consecutive days of the annual maximum, which sounds impossible unless there is something strange in the way the satellite precipitation is calculated – Robert Wilson Sep 17 '22 at 13:36
  • It is actually the accumulated precipitation for 5 consecutive days. The Rx5 index that comes from the Expert Team (ET) on Climate Change Detection. I have corrected the question, it would be to calculate the accumulated of 5 consecutive days in particular. – Fernando Primo Forgioni Sep 17 '22 at 13:43
  • It may happen that more than one event occurs where precipitation accumulates for 5 consecutive days, then one of those values will be the maximum precipitation accumulated in 5 consecutive days during that particular year. Sorry, I'm very nervous to bother you with this question, I hope I have been able to explain better and I'm sorry for the problems – Fernando Primo Forgioni Sep 17 '22 at 13:48
  • Ah, this question has been edited since I posted my answer and now asks for something completely different! – ClimateUnboxed Sep 17 '22 at 20:39

2 Answers2

2

Assuming everything is in a single file, the following approach, where all 3 calcs are chained, should work:

cdo -timmean -yearmax -runsum,5 infile outfile
Robert Wilson
  • 3,192
  • 11
  • 19
0

Logged on to find the question has been completely changed, so I deleted my original answer.

Robert Wilson's answer now addresses your new question perfectly, I just wanted to add that as an alternative to using the running mean, you might also think to just do simple pentad averages that are commonly employed in meteorology. In that case you would want to do

cdo timselmean,5 in.nc out.nc 

this gives you pentad averages. Then you can get the max pentad value and take the twenty year average in the same way as Robert shows, thus piping the three commands you get

cdo -timmean -yearmax -timselmean,5 in.nc out.nc 
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
  • Yes, excuse me Adrian, I am working with the performance of a satellite compared to observed data. So I am calculating that at a given time of the year there are 5 consecutive days where the accumulated precipitation is maximum in the data observed at a particular spatial point. So what I do is look for that same date for the satellite data and perform the accumulation. As I have a period of 20 years I want to make an average of the precipitation in 20 years, the problem is that I did not know how to do it in my netcdf file – Fernando Primo Forgioni Sep 17 '22 at 13:27
  • I just edited the question, it's just that I had a hard time putting into words what I was trying to do. I hope now you can understand better! – Fernando Primo Forgioni Sep 17 '22 at 13:33
  • Can you explain how you can get 5 consecutive days of maximum precipitation? I don't follow how that can actually occur in one year never mind every year – Robert Wilson Sep 17 '22 at 13:39
  • It is actually the accumulated precipitation for 5 consecutive days. The Rx5 index that comes from the Expert Team (ET) on Climate Change Detection – Fernando Primo Forgioni Sep 17 '22 at 13:40
  • Your update just now is equally confusing. Is your question really "How do I calculate the 20-year average of annual maximum precipitation in a 5-day window"? – Robert Wilson Sep 17 '22 at 13:47
  • It may happen that more than one event occurs where precipitation accumulates for 5 consecutive days, then one of those values will be the maximum precipitation accumulated in 5 consecutive days during that particular year. Sorry, I'm very nervous to bother you with this question, I hope I have been able to explain better and I'm sorry for the problems – Fernando Primo Forgioni Sep 17 '22 at 13:48
  • Things are no clearer, unfortunately. Your question currently defines an event as one where precipitation accumulates for 5 consecutive days, but you want the average of 20 years of those events. But you say these events occur more than once a year. How do you get 20 events in 20 years if more than 1 occurs per year? – Robert Wilson Sep 17 '22 at 13:54
  • I am looking for the event where this accumulated precipitation is the highest during the year. I would choose only 1 event per year, that is why I seek to calculate the average value – Fernando Primo Forgioni Sep 17 '22 at 13:59
  • So. You want to first calculate the rolling sum of preciptation using a 5-day window. Then you want to calculate the annual maximum of the rolling sum for each year. And finally you want to calculate the 20 year mean of those values? Is that correct? – Robert Wilson Sep 17 '22 at 14:02
  • Yes, I really know how to excuse my clumsiness! – Fernando Primo Forgioni Sep 17 '22 at 14:03
  • Can you please rewrite the question to reflect this? – Robert Wilson Sep 17 '22 at 14:14