Project

General

Profile

About compound dry-warm events

Added by Michael Akin almost 2 years ago

Hello,
I would appreciate it if someone can assist with a cdo code to calculate the "sum of occurrences of an event where Precipitation < P25 and Temperature > T75"
[P25 and T75 are 25 and 75 percentiles of precipitation and temperature, respectively]. Thank you


Replies (5)

RE: About compound dry-warm events - Added by Karin Meier-Fleischer almost 2 years ago

Hi Michael,

the following example describes how you can do the selection. Temperature variable tsurf, precipitation variable precip

cdo -timpctl,75 -selvar,tsurf $infile \
                -timmin -selvar,tsurf $infile \
                -timmax -selvar,tsurf \
                infile.nc tsurf_75pctl.nc

cdo -timpctl,25 -selvar,precip $infile \
                -timmin -selvar,precip $infile \
                -timmax -selvar,precip \
                infile.nc precip_25pctl.nc

cdo -gt -selvar,tsurf  infile.nc tsurf_75pctl.nc  out_tsurf.nc
cdo -lt -selvar,precip infile.nc precip_25pctl.nc out_precip.nc

cdo -chname,tsurf,mask -mul out_tsurf.nc out_precip.nc masked_gtT75_ltP25.nc

cdo -timsum -mul -selvar,tsurf  infile.nc masked_gtT75_ltP25.nc outfile_tsurf.nc
cdo -timsum -mul -selvar,precip infile.nc masked_gtT75_ltP25.nc outfile_precip.nc

-Karin

RE: About compound dry-warm events - Added by Guilherme Martins almost 2 years ago

I'm note sure, but I think is missing something in the last command:

cdo -timsum -gtc,0 -mul -selvar,tsurf infile.nc masked_gtT75_ltP25.nc outfile_tsurf.nc
cdo -timsum -gtc,0 -mul -selvar,precip infile.nc masked_gtT75_ltP25.nc outfile_precip.nc

The question would not be to know the sum of occurrences? I put gtc,0.

RE: About compound dry-warm events - Added by Michael Akin almost 2 years ago

Karin and Guilherme, thank you so much for your help.

Guilherme, what is the difference between putting "gtc,0" in the last line?

RE: About compound dry-warm events - Added by Karin Meier-Fleischer almost 2 years ago

Good point. Guilherme is right, you are looking for the "sum of occurrences of an event where Precipitation < P25 and Temperature > T75".

The result of my approach is the sum of the data values when the condition is True. The operator -gtc,0 creates a mask where the value is 1 if the condition is True or 0 if False. The timsum then sums it up (count) the occurences.

RE: About compound dry-warm events - Added by Michael Akin almost 2 years ago

Thank you so much, I appreciate it.

    (1-5/5)