def detectability_calculator(Theta_CDF,min_CDF,max_CDF,SNR_in):
    """
    Given the optimal-alignment SNR of a merger, this function returns the
    fraction of arbitrary orientations in which the merger would be expected to
    be observable (i.e. have a SNR above 8).
    
    Parameters
    ----------
    Theta_CDF: function
        The CDF of the projection function Theta, from cdf_generator().
    min_CDF: float
        The lower boundary of the range over which Theta_CDF is defined, from
        cdf_generator().
    max_CDF: float
        The upper boundary of the range over which Theta_CDF is defined, from
        cdf_generator().
    SNR_in: float
        The optimal-alignment SNR of the merger in question, can be obtained
        from snrcalculatorfuns.
        
    Returns
    -------
    det: float
        The detectability fraction of the merger.
    """
    
    #input type checking
    assert type(min_CDF) == float, 'min_CDF should be a float.'
    assert type(max_CDF) == float, 'max_CDF should be a float.'
    assert type(SNR_in) == float, 'SNR_in should be a float.'
    
    if SNR_in <= (8 / max_CDF):
        det = 0                             #always undetectable
        #set separately so Theta_CDF doesn't get input above 1
        #the max_CDF (just below 1) has to be included because the function
        #Theta_dist is not defined for the small range between max_CDF and 1
        #and this can occasionally cause problems if just 8 is used
    elif SNR_in >= (8 / min_CDF):
        det = 1                             #always detectable
        #similarly, Theta_CDF is not defined between 0 and min_CDF
    else:
        threshold = 8 / SNR_in
        #how much the SNR would need to be lowered to hit the threshold SNR=8
        undet = Theta_CDF(threshold)
        #the proportion of Theta values that would lower SNR below 8
        det = 1 - undet             #proportion that would keep SNR above 8
    
    #output type conversion
    det = float(det)
    
    return det