Project

General

Profile

About dry and humid heatwaves

Added by Farhan Saleem over 2 years ago

Hello,

I would appreciate it if someone can assist with a code to calculate the "specific number of heatwaves days where relative humidity > 66% and < 33%".
[whereas, a heatwave event is defined as one in which temperatures exceeded the 90th percentile of the daily mean temperature for at least three consecutive days, respectively]. Thank you
I also attached the daily input data files (i.e., temperature and humidity).

Regards,
Farhan


Replies (9)

RE: About dry and humid heatwaves - Added by Karin Meier-Fleischer over 2 years ago

Hi Farhan,

I have written - without guarantee - a script that should calculate "specific number of heatwaves days" for the case rhum > 66pctl and rhum < 33pctl.

#!/usr/bin/env ksh

tmpfile="$HOME/Downloads/tmp.nc" 
rhumfile="$HOME/Downloads/rhum.nc" 
tmp90="$HOME/Downloads/tmp90pctl.nc" 
rhum66="$HOME/Downloads/rhum66pctl.nc" 
rhum33="$HOME/Downloads/rhum33pctl.nc" 
heatwave="$HOME/Downloads/heatwave_event.nc" 

#-- delete old files
rm $tmp90  $rhum66 $rhum33 \
   $HOME/Downloads/heatwave_event.nc \
   $HOME/Downloads/heatwave_days_rhum_gt_66pctl.nc \
   $HOME/Downloads/heatwave_days_rhum_gt_33pctl.nc

#-- compute the 90th percentile for eca_hwfi:
#--     TGn90 is calculated as the 90th percentile of daily mean temperatures 
#--        of a five day window centred on each calendar day of a given climate 
#--     reference period
echo "----> compute tmp 90pctl" 
cdo -timpctl,90 $tmpfile  -timselmin,5 $tmpfile -timselmax,5 $tmpfile $tmp90

#-- to get rid of the ERROR: 
#--     cdo    eca_hwfi (Abort): Input streams have different time values!
cdo -add $tmp90 -sub $tmpfile $tmpfile $HOME/Downloads/tmp90pctl_with_timesteps.nc
tmp90="$HOME/Downloads/tmp90pctl_with_timesteps.nc" 

#-- a heatwave event is defined as one in which temperatures exceeded the 
#-- 90th percentile of the daily mean temperature for at least three 
#-- consecutive days, respectively

echo "----> compute heatwave_event.nc" 
cdo eca_hwfi,3 $tmpfile $tmp90 $heatwave

echo "----> compute rhum >66%" 
cdo -timpctl,66 $rhumfile  -timselmin,5 $rhumfile -timselmax,5 $rhumfile \
     $rhum66

echo "----> compute rhum <33%" 
cdo -timpctl,33 $rhumfile  -timselmin,5 $rhumfile -timselmax,5 $rhumfile \
     $rhum33

echo "---->  heatwave n-days where rhum > 66pctl" 
cdo -div $tmpfile -gt $rhumfile $rhum66 $HOME/Downloads/heatwave_days_rhum_gt_66pctl.nc

echo "---->  heatwave n-days where rhum < 33pctl" 
cdo -div $tmpfile -lt $rhumfile $rhum33 $HOME/Downloads/heatwave_days_rhum_lt_33pctl.nc

RE: About dry and humid heatwaves - Added by Farhan Saleem about 2 years ago

Dear Karin Meier-Fleischer,

Sorry for my late response and thank you for writing the script. There are some points I need to discuss with you can we communicate through email, does it work for you?

Cheers
Farhan

RE: About dry and humid heatwaves - Added by Karin Meier-Fleischer about 2 years ago

I prefer to answer questions in the forums so that other users can benefit.

What questions do you have?

RE: About dry and humid heatwaves - Added by Farhan Saleem about 2 years ago

Hi Karin Meier-Fleischer,

I have the daily precipitation data (mm) and I want to calculate the annual maxima (block maxima), Is there any cdo command to do this?

Does cdo yearmax in.nc out.nc works?

Regards,
Farhan

RE: About dry and humid heatwaves - Added by Karin Meier-Fleischer about 2 years ago

The operator yearmax is exactly what you are looking for.

From the CDO documentation https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.8.25)

YEARSTAT - yearly statistical values

This module computes statistical values over timesteps of the same year. ...

...

yearmax: Yearly maximum
                For every adjacent sequence t_1, ..., t_n of timesteps of the same year it is: o(t, x) = max{i(t′, x), t1 < t′ ≤ tn}
...

RE: About dry and humid heatwaves - Added by Farhan Saleem about 2 years ago

Dear Karin,
Thank you for the nice explanation. I would also like to ask if is there any CDO command to calculate monthly maxima using daily precipitation data.
Regards,
Farhan

RE: About dry and humid heatwaves - Added by Karin Meier-Fleischer about 2 years ago

I recommend to read the documentation because you would have found the needed operator very easy 😉 . In most cases the naming of the operators follows the same pattern, when yearly maximum yearmax is then logically is the monthly maximum monmax 😀 . See https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf

RE: About dry and humid heatwaves - Added by Farhan Saleem about 2 years ago

Thank you Karin for the help and support 😀

RE: About dry and humid heatwaves - Added by Francis Tom over 1 year ago

Dear Karin, 

Based on the codes you provided here, I would like to ask: 

1. Can I compute a heatwave using "eca_hwfi" if my input data is "daily maximum temperature" instead of the default daily mean temperature? Like use the above code but with daily maximum temperature as input.

2. Alternatively, if I use "eca_tx90p," whose input data is the daily maximum temperature, and I do the following:

cdo -timpctl,90 daily_tmax.nc  -timselmin,5 daily_tmax.nc -timselmax,5 daily_tmax.nc tmax_90pctl.nc (90th percentile of daily maximum temperatures of a five-day window centered on each calendar day)

Do I need to add "5" in front of the percentile also (cdo -timpctl,90,5)?

"compute heatwave_event" 
cdo eca_tx90p,3 daily_tmax.nc tmax_90pctl.nc heatwave.nc

Does adding "3" in front of "eca_tx90"  imply I am considering at least three consecutive days? If no, how do I compute for at least three consecutive days in "eca_tx90p"

"eca_tx90p" unit is percent, can this be converted to "number of events"?

3.In the above code "cdo -div $tmpfile -gt $rhumfile $rhum66 $HOME/Downloads/heatwave_days_rhum_gt_66pctl.nc" why did you use "div $tmpfile"?

Thank you so much

    (1-9/9)