Exemplo n.º 1
0
def CSU_calculation(arr, fill_val=None, threshold=25):

    """
    Calculates the CSU indice: maximum number of consecutive summer days (i.e. days with daily maximum temperature > 25 degrees Celsius) [days].
    
    
    :param arr: daily maximum temperature (e.g. "tasmax") in Kelvin
    :type arr: numpy.ndarray (3D) or numpy.ma.MaskedArray (3D)
    :param fill_val: fill value 
    :type fill_val: float
    :param threshold: user defined temperature threshold in degrees Celsius (default: threshold=25)
    :type threshold: float
    
    :rtype: numpy.ndarray (2D)        (if "arr" is numpy.ndarray)
         or numpy.ma.MaskedArray (2D) (if "arr" is numpy.ma.MaskedArray)
         
    .. warning:: Units of "arr" must be Kelvin.
        
    .. warning:: Units of "threshold" must be in Celsius.
    """
    # .. warning:: If "arr" is a masked array, the parameter "fill_val" is ignored, because it has no sense in this case.

    T = threshold + 273.15  # Celsius -> Kelvin

    CSU = calc.get_max_nb_consecutive_days(arr, thresh=T, logical_operation="gt", coef=1.0, fill_val=fill_val)

    return CSU
Exemplo n.º 2
0
def CWD_calculation(arr, fill_val=None, threshold=1.0):

    """
    Calculates the CWD indice: maximum number of consecutive wet days (i.e. days with daily precipitation amount > = 1 mm) [days].
    
    :param arr: daily precipitation (liquid form) flux (e.g. "pr") in mm/day
    :type arr: numpy.ndarray (3D) or numpy.ma.MaskedArray (3D)
    :param fill_val: fill value 
    :type fill_val: float
    
    :rtype: numpy.ndarray (2D)        (if "arr" is numpy.ndarray)
         or numpy.ma.MaskedArray (2D) (if "arr" is numpy.ma.MaskedArray)
         
    .. warning:: Units of "arr" must be mm/day.
    
    .. warning:: If "arr" is a masked array, the parameter "fill_val" is ignored, because it has no sense in this case.
    """

    CWD = calc.get_max_nb_consecutive_days(arr, thresh=threshold, logical_operation="get", coef=1.0, fill_val=fill_val)

    return CWD
Exemplo n.º 3
0
def CFD_calculation(arr, fill_val=None, threshold=0):

    """
    Calculates the CFD indice: maximum number of consecutive frost days (i.e. days with daily minimum temperature < 0 degrees Celsius) [days].
    
    :param arr: daily min temperature (e.g. "tasmin") in Kelvin
    :type arr: numpy.ndarray (3D) or numpy.ma.MaskedArray (3D)
    :param fill_val: fill value 
    :type fill_val: float
    
    :rtype: numpy.ndarray (2D)        (if "arr" is numpy.ndarray)
         or numpy.ma.MaskedArray (2D) (if "arr" is numpy.ma.MaskedArray)
         
    .. warning:: Units of "arr" must be Kelvin.
    
    .. warning:: If "arr" is a masked array, the parameter "fill_val" is ignored, because it has no sense in this case.
    """

    T = threshold + 273.15  # Celsius -> Kelvin

    CFD = calc.get_max_nb_consecutive_days(arr, thresh=T, logical_operation="lt", coef=1.0, fill_val=fill_val)

    return CFD