Count precipitation days by month from annual file
Added by Jed Kaplan almost 13 years ago
Hello CDO'ers,
I would like to calculate the number of days per month with nonzero precipitation from a file that contains daily precipitation rate values over a whole year. I have seen that with the CDO operator "eca_pd" I can sum up rain days, but if I use this on my file, I can only calculate the annual sum. Is there any way to get what I want with CDO short of extracting each month individually from the original file, processing it, and then having 12 separate files that I would have to reassemble using, e.g., the "mergetime" operator?
The file I am working with is here, in case you would like to experiment yourself.
ftp://ftp.cdc.noaa.gov/Datasets/20thC_ReanV2/Dailies/gaussian/monolevel/prate.2000.nc
Many thanks in advance for your help!
Jed
Replies (2)
RE: Count precipitation days by month from annual file - Added by Jed Kaplan almost 13 years ago
Never mind, I wrote a script to do this.
#!/bin/sh for (( year=1871; year<=1999; year++ )) do echo $year curl -O ftp://ftp.cdc.noaa.gov/Datasets/20thC_ReanV2/Dailies/gaussian/monolevel/prate.$year.nc echo cdo -s -b 32 delname,time_bnds -mulc,86400 prate.$year.nc tmp1.nc for (( i=1; i<=12; i++ )) do m=`printf "%02i\n" $i` cdo -s selmon,$i tmp1.nc tmp2.nc cdo -s eca_pd,1 tmp2.nc precmon/$m.nc done cd precmon files=`ls *.nc` cdo -s mergetime $files ../wetdays/$year.nc rm *.nc cd .. rm prate.$year.nc tmp1.nc tmp2.nc done
RE: Count precipitation days by month from annual file - Added by Ralf Mueller almost 13 years ago
You may have a look at operators consecsum and consects
regards
ralf