def tmy_hdd_cdd(t_dry, hdd_threshold=13, hdd_ref=18, cdd_threshold=26,
    cdd_ref=24):
    """
    from TMY temp calculate heating (hdd) and cooling degree-days (cdd)


    from a TMY list with 8760 hourly values for temperature calculate
    the heating degree-days (hdd) and the cooling degree-days (cdd)

    calculation principle: iterate over all days of the year, consider
    only those days with average temperature equal or below the temperature
    hdd_threshold (equal or above cdd_threshold for cooling DD).
    Add up in the heat_degree_days the absolute difference of the average
    temperature for the considered day and the reference temperature hdd_ref.
    The procedure is similar for cooling DD, with the absolute difference
    between the average day temperature and the cdd reference.
    Return the total.

    The formula considers that heating is necessary for those days with
    average temperature below the threshold (or above the other threshold
    in the case of cooling). Heating must be provided to bring the indoors
    temperature to hdd_ref, or cooling to bring the temperature down to
    cdd_ref.

    input data:
    - list with 8760 temperature values
    - threshold temperature for hdd addition yes/no (default value: 13C)
    - reference temperature for hdd calculation (default value: 18C)    
    - threshold temperature for cdd addition yes/no (default value: 26C)
    - reference temperature for cdd calculation (default value: 24C)    

    all values integer or float

    output:
    tuple with
    - heating degree days, integer
    - cooling degree days, integer

    """
    heat_ddays = 0
    cool_ddays = 0
    if hdd_threshold < hdd_ref and cdd_threshold > cdd_ref:
        for d in range(0, 365):
            day_temp = 0
            for h in range(0, 24):
                h_idx = d * 24 + h
                day_temp = day_temp + t_dry[h_idx]
            day_temp_avg = day_temp / 24
            if day_temp_avg <= hdd_threshold:
                heat_ddays = heat_ddays + (hdd_ref - day_temp_avg)
            if day_temp_avg >= cdd_threshold:
                cool_ddays = cool_ddays + (day_temp_avg - cdd_ref)
    return int(round(heat_ddays, 0)), int(round(cool_ddays, 0))
