Project

General

Profile

Computing accumulated rainfall anomalies for each year

Added by Jayantha Obeysekera over 3 years ago

Hi,
I am new to CDO but I enjoy it very much.

I do have a question. I have gridded, daily rainfall values for a period of 50 years. I need to compute the accumulated values of rainfall anomalies for each year. Mathematically, it is y = cumsum(rainfall(x,t)-mean(x,all in the same year). Any suggestions how I can this?
Thank you


Replies (3)

RE: Computing accumulated rainfall anomalies for each year - Added by Karin Meier-Fleischer over 3 years ago

Hi Jayantha,

I think that the calculation could be done with a shell script as follows:

#!/usr/bin/env ksh

infile="your-infile.nc" 

cdo -yearmean $infile ymean.nc
cdo -sub $infile ymean.nc yanom.nc
cdo -timcumsum yanom.nc outfile.nc

-Karin

RE: Computing accumulated rainfall anomalies for each year - Added by Karin Meier-Fleischer over 3 years ago

If you want the timcumsum for each year separated you have to loop over each single year.

RE: Computing accumulated rainfall anomalies for each year - Added by Jayantha Obeysekera over 3 years ago

Jayantha Obeysekera wrote:

Hi,
I am new to CDO but I enjoy it very much.

I do have a question. I have gridded, daily rainfall values for a period of 50 years. I need to compute the accumulated values of rainfall anomalies for each year. Mathematically, it is y = cumsum(rainfall(x,t)-mean(x,all in the same year). Any suggestions how I can this?
Thank you

Thanks you Karin for your help below.
#!/usr/bin/env ksh

infile="your-infile.nc"

cdo -yearmean $infile ymean.nc
cdo -sub $infile ymean.nc yanom.nc
cdo -timcumsum yanom.nc outfile.nc

Can I use operator chaining for this? I tried but it did not seem to work.

    (1-3/3)