def cal_anomaly_Y(df, df_ref):
    """
    Calculates yearly averaged temperature anomaly (departure) from the reference period.
    Parameters:
        - df: DataFrame from which anomaly is calculated
        - df_ref: DataFrame of the reference period
    Returns:
        - df_Y: yearly averaged anomaly
        - df_ref_Y: yearly averaged reference temperatures
    """
    # reference frame (just a number now)
    df_ref_Y = df_ref['value'].mean()

    # plotting frame:
    df_Y = df.resample('AS').mean() # this will fill incomplete years into complete ones and place the mean into the first day of the year

    # calculate anomaly:
    df_Y['value'] -= df_ref_Y
    
    return df_Y, df_ref_Y