weathercdo-climate

How to apply at least three days criteria for heat wave calculation


I want to calculate heat wave occurence on the basis of percentiles. The maximum temperature has to be greater than the 90th percentile for at least three consecutive days. How can I calculate this part using cdo.

I tried to solve it using the following approach

cdo ge infile.nc 90thpctl.nc 1.nc
cdo runsum,3 1.nc 2.nc
cdo gec,3 2.nc 3.nc 
cdo timsum 3.nc ndays.nc 

Is this the approach to include at least three consecutive days criteria?


Solution

  • So, if tmax.nc is your file of daily maximum temperature, then first of all we need to construct the heat wave event by getting a 1 for every day above your 90%tile threshold.

    We need to modify those approaches to use the percentile based on the time of year to account for seasonality, so we will use the ydaypctl function. Often this is smoothed using a 15 day window to make things less noisy when using daily data, so I will apply a 15 day running mean.

    We also need a long input file for good statistics. *I will assume that the * input file runs from 25th December 1980, to 7th January 2011 so that after I apply the 15 day running mean the daily file has dates that exactly cover 1981 to 2010.

    # Average the tmax and then do seasonalized percentile
    cdo runmean,15 tmax.nc tmax15.nc
    
    # Threshold for the tmax
    cdo ydaypctl,90 tmax15.nc -ydaymin tmax15.nc -ydaymax tmax15.nc p90.nc
    
    # Make series with 1 for every day that exceeds the threshold:
    cdo -ge tmax.nc p90.nc hwday.nc
    
    

    Okay, so now we have a series of 1s for each day above the heatwave threshold, so now we want to look at the length of each and only keep events which are longer than 3 days, for this we can use the consects function

    # Now get heatwaves
    cdo consects hwday.nc hwlenall.nc
    
    # Set any len less than 2 to zero. I assume the variable is called "tmax"
    cdo -expr,'tmax = ((tmax > 2)) ? tmax : 0' hwlenall.nc hwlen3.nc
    
    # Now you can the number of events each year
    cdo yearsum -gec,3 hwlenall.nc eventsperyear.nc
    
    # And the mean duration
    cdo yearmean hwlen3.nc average_heatwave_len.nc