def significant_hail_parameter(mucape, mixing_ratio, lapse, temp_500, shear, flh):
    """
    Calculate the significant hail parameter, as given at
    https://www.spc.noaa.gov/exper/mesoanalysis/help/help_sigh.html
    
    Arguments:
    
        - mucape: Most unstable parcel CAPE [J kg-1].
        - mixing_ratio: Mixing ratio of the most unstable parcel [kg kg-1].
        - lapse: 700-500 hPa lapse rate [K/km].
        - temp_500: Temperature at 500 hPa [K].
        - shear: 0-6 km bulk wind shear [m s-1].
        - flh: Freezing level height [m].
        
    Returns:
    
        - Significant hail parameter.
    """

    # Convert from kg kg-1 to g kg-1
    mixing_ratio = mixing_ratio * 1e3

    # Use positive values of lapse rate.
    lapse = -lapse

    # Convert temperatures from K to C.
    temp_500 = temp_500 - 273.15

    # Apply thresholds on inputs to identify where SHIP is valid.
    shear = shear.where(shear >= 7).where(shear <= 27)
    mixing_ratio = mixing_ratio.where(mixing_ratio >= 11).where(mixing_ratio <= 13.6)
    temp_500 = temp_500.where(temp_500 <= -5.5, other=-5.5)

    # Calculate basic SHIP value.
    ship = mucape * mixing_ratio * lapse * -temp_500 * shear / 42000000 
    
    # Three conditions change the value of SHIP.
    ship = ship.where(mucape >= 1300, other=ship * (mucape/1300))
    ship = ship.where(lapse >= 5.8, other=ship * (lapse/5.8))
    ship = ship.where(flh >= 2400, other=ship * (flh/2400))
    
    # Metadata.
    ship.attrs['long_name'] = 'Significant hail parameter'
    ship.attrs['units'] = 'J kg-2 g K^2 km-1 m s-1'
    
    return ship