Cooling and heating degree days with CDO

Recently at work, I had to calculate cooling and heating degree days per annum for future climate projections. Eurostat provides both metrics only for the past. I found a convenient option to calculate both using a bash script and CDO for flexible base/threshold temperatures. This post presents my solution without any further ado.