Пример #1
0
def lossref_compute(P,h0,h1,k=4/3.) :
    """
    compute loss and reflection rays on curved earth

    Parameters
    ----------

    P : float |list 

        if len(P) == 1 => P is a distance
        if len(P) == 4 => P is a list of [lon0,lat0,lon1,lat1]

        where :
        lat0 : float |string
            latitude first point (decimal |deg min sec Direction)
        lat1 : float |string
            latitude second point (decimal |deg min sec Direction)
        lon0 : float |string
            longitude first point (decimal |deg min sec Direction)
        lon1 : float |string
            longitude second point (decimal |deg min sec Direction)
    h0 : float:
        height of 1st point 
    h1 : float:
        height of 2nd point 
    k : electromagnetic earth factor


    Returns
    -------
    
    dloss : float
        length of direct path (meter)
    dref : float
        length of reflective path (meter)
    psy : float
        Reflection angle

    References
    ----------
    B. R. Mahafza, Radar systems analysis and design using MATLAB, Third edition. Boca Raton; London: CRC/Taylor & Francis, chapter 8, 2013.

    """


    if isinstance(P,float) or isinstance(P,int) :
        #P is a distance
        r=P
        mode = 'dist'
    elif isinstance(P,np.ndarray) or isinstance(P,list):
        if len(P) == 1:
            #P is a distance
            r=P
            mode = 'dist'
        elif len(P) == 4:
            #P is a lonlat
            lat0=P[0]
            lon0=P[1]
            lat1=P[2]
            lon1=P[2]
            mode = 'lonlat'
        else :
            raise AttributeError('P must be a list [lat0,lon0,lat1,lon0] or a distance')
    else :
        raise AttributeError('Invalid P format ( list |ndarray )')


    # if h0<h1:
    #     h1,h0 = h0,h1

    r0 = 6371.e3 # earth radius
    re = k*r0 # telecom earth radius


    if mode == 'lonlat':
        # r = distance curvilignenp.arcsin((h1/R1)-R1/(2.*re)) entre TXetRX / geodesic
        r = gu.distance_on_earth(lat0, lon0, lat1, lon1)
    else :
        r=P

    r=1.*r

    # import ipdb
    # ipdb.set_trace()
    p = 2/(np.sqrt(3))*np.sqrt(re*(h0+h1)+(r**2/4.)) #eq 8.45
    eps = np.arcsin(2*re*r*(h1-h0)/p**3) # eq 8.46



    #distance of reflection on curved earth
    r1 = r/2 - p*np.sin(eps/3) #eq 8.44

    r2 = r -r1

    phi1 = r1/re #8.47
    phi2 = r2/re # 8.48

    R1 = np.sqrt(h0**2+4*re*(re+h0)*(np.sin(phi1/2))**2) # 8.51
    R2 = np.sqrt(h1**2+4*re*(re+h1)*(np.sin(phi2/2))**2) #8.52

    Rd = np.sqrt((h1-h0)**2+4*(re+h1)*(re+h0)*np.sin((phi1+phi2)/2.)**2) # 8.53
    # tangente angle on earth
    psy = np.arcsin((h1/R1)-R1/(2.*re)) #eq 8.55
    deltaR = 4*R1*R2*np.sin(psy)**2/(R1+R2+Rd)

    dloss = Rd
    dref = R1+R2

    return psy,dloss,dref
Пример #2
0
def lossref_compute(P, h0, h1, k=4 / 3.):
    """
    compute loss and reflection rays on curved earth

    Parameters
    ----------

    P : float |list 

        if len(P) == 1 => P is a distance
        if len(P) == 4 => P is a list of [lon0,lat0,lon1,lat1]

        where :
        lat0 : float |string
            latitude first point (decimal |deg min sec Direction)
        lat1 : float |string
            latitude second point (decimal |deg min sec Direction)
        lon0 : float |string
            longitude first point (decimal |deg min sec Direction)
        lon1 : float |string
            longitude second point (decimal |deg min sec Direction)
    h0 : float:
        height of 1st point 
    h1 : float:
        height of 2nd point 
    k : electromagnetic earth factor


    Returns
    -------
    
    dloss : float
        length of direct path (meter)
    dref : float
        length of reflective path (meter)
    psy : float
        Reflection angle

    References
    ----------
    B. R. Mahafza, Radar systems analysis and design using MATLAB, Third edition. Boca Raton; London: CRC/Taylor & Francis, chapter 8, 2013.

    """

    if isinstance(P, float) or isinstance(P, int):
        #P is a distance
        r = P
        mode = 'dist'
    elif isinstance(P, np.ndarray) or isinstance(P, list):
        if len(P) == 1:
            #P is a distance
            r = P
            mode = 'dist'
        elif len(P) == 4:
            #P is a lonlat
            lat0 = P[0]
            lon0 = P[1]
            lat1 = P[2]
            lon1 = P[2]
            mode = 'lonlat'
        else:
            raise AttributeError(
                'P must be a list [lat0,lon0,lat1,lon0] or a distance')
    else:
        raise AttributeError('Invalid P format ( list |ndarray )')

    # if h0<h1:
    #     h1,h0 = h0,h1

    r0 = 6371.e3  # earth radius
    re = k * r0  # telecom earth radius

    if mode == 'lonlat':
        # r = distance curvilignenp.arcsin((h1/R1)-R1/(2.*re)) entre TXetRX / geodesic
        r = gu.distance_on_earth(lat0, lon0, lat1, lon1)
    else:
        r = P

    r = 1. * r

    # import ipdb
    # ipdb.set_trace()
    p = 2 / (np.sqrt(3)) * np.sqrt(re * (h0 + h1) + (r**2 / 4.))  #eq 8.45
    eps = np.arcsin(2 * re * r * (h1 - h0) / p**3)  # eq 8.46

    #distance of reflection on curved earth
    r1 = r / 2 - p * np.sin(eps / 3)  #eq 8.44

    r2 = r - r1

    phi1 = r1 / re  #8.47
    phi2 = r2 / re  # 8.48

    R1 = np.sqrt(h0**2 + 4 * re * (re + h0) * (np.sin(phi1 / 2))**2)  # 8.51
    R2 = np.sqrt(h1**2 + 4 * re * (re + h1) * (np.sin(phi2 / 2))**2)  #8.52

    Rd = np.sqrt((h1 - h0)**2 + 4 * (re + h1) * (re + h0) * np.sin(
        (phi1 + phi2) / 2.)**2)  # 8.53
    # tangente angle on earth
    psy = np.arcsin((h1 / R1) - R1 / (2. * re))  #eq 8.55
    deltaR = 4 * R1 * R2 * np.sin(psy)**2 / (R1 + R2 + Rd)

    dloss = Rd
    dref = R1 + R2

    return psy, dloss, dref