Guest User

Untitled

a guest
Dec 14th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. # Conversion of the (median) location error ellipse for the best location
  2. # of any lightning stroke into the probability that the stroke was within
  3. # any radius of any object of interest. Implementation of the method pre-
  4. # sented in the NASA report [1].
  5. #
  6. # [1] Huddleston LL, Roeder WP, Merceret FJ. A Probabilistic, Facility-Centric
  7. # Approach to Lightning Strike Location. tech. rep., National Aeronautics
  8. # and Space Administration; Kennedy Space Center, FL 32899-0001: 2012.
  9. # NASA/TM-20 12-216308.
  10.  
  11. # library imports
  12. import numpy as np
  13. from scipy import integrate
  14.  
  15. # Great circle (orthodromic) distance between points on the Earth's surface
  16. def distance(lon_wt, lat_wt, lon_rad, lat_rad):
  17. """
  18. :param lon_wt: longitude of the wind turbine location
  19. :param lat_wt: latitude of the wind turbine location
  20. :param lon_rad: longitude of the lightning strike location
  21. :param lat_rad: latitude of the lightning strike location
  22. :return: orthodromic distance in meters
  23. """
  24. # Convert longitude and latitude information to radians
  25. lon_wt = lon_wt*np.pi/180.
  26. lat_wt = lat_wt*np.pi/180.
  27. lon_rad = lon_rad*np.pi/180.
  28. lat_rad = lat_rad*np.pi/180.
  29. # Compute a great circle distance between two points on the globe
  30. distance = 2.*np.arcsin(np.sqrt((np.sin((lat_wt-lat_rad)/2.))**2 +
  31. np.cos(lat_wt)*np.cos(lat_rad) *
  32. (np.sin((lon_wt-lon_rad)/2.))**2))
  33. # Convert distance to nautical miles
  34. distance_nm = ((180.*60.)/np.pi) * distance
  35. # convert distance to meters
  36. distance_m = distance_nm * 1852.
  37. return distance_m
  38.  
  39. def coordinate_rotation(target_lon, target_lat, strike_lon, strike_lat,
  40. alpha, distance, semi_major, semi_minor, proba):
  41. # convert degrees to radians
  42. target_lon = target_lon*(np.pi/180.)
  43. target_lat = target_lat*(np.pi/180.)
  44. strike_lon = strike_lon*(np.pi/180.)
  45. strike_lat = strike_lat*(np.pi/180.)
  46. alpha = alpha*(np.pi/180.)
  47. # coordinate rotation
  48. X = (target_lon - strike_lon)*np.cos(strike_lat)
  49. Z = target_lat - strike_lat
  50. theta = alpha - (np.pi/2. - np.arctan2(Z, X))
  51. Xc = distance*np.cos(theta)
  52. Zc = distance*np.sin(theta)
  53. k = np.sqrt(-2.*np.log(1. - proba))
  54. sigma_x = semi_major/k
  55. sigma_z = semi_minor/k
  56. return Xc, Zc, sigma_x, sigma_z
  57.  
  58. def kernel_function(x, mu_k, mu_h, sigma_k, sigma_h, w):
  59. z1 = (np.sqrt(w-x**2) - mu_k)/(np.sqrt(2.)*sigma_k)
  60. z2 = (np.sqrt(w-x**2) + mu_k)/(np.sqrt(2.)*sigma_k)
  61. erf_z1 = special.erf(z1)
  62. erf_z2 = special.erf(z2)
  63. exp_1 = np.exp(-(x - mu_h)**2/(2.*sigma_h**2))
  64. exp_2 = np.exp(-(x + mu_h)**2/(2.*sigma_h**2))
  65. function = (exp_1 + exp_2)*(erf_z1 + erf_z2)
  66. return function
  67.  
  68. # EXAMPLE:
  69. # lightning strike location
  70. strike_lat = 28.6069
  71. strike_lon = -80.6087
  72. # confidence ellipse (50%)
  73. semi_major = 0.6 # km
  74. semi_minor = 0.4 # km
  75. heading = 82. # heading from true north
  76. # point of interest (e.g. WT location)
  77. poi_lat = 28.60827
  78. poi_lon = -80.6041
  79. # radius around point of interest
  80. radius = 0.45*1.852 # nautical miles to km
  81.  
  82. # COMPUTATION:
  83. # orthodromic distance
  84. dist = distance(poi_lon, poi_lat, strike_lon, strike_lat)
  85. dist = dist*1e-3 # m => km
  86. # coordinate system rotation
  87. proba = 0.5 # confidence ellipse probability
  88. mu_k, mu_h, sigma_k, sigma_h = coordinate_rotation(poi_lon, poi_lat, strike_lon, strike_lat,
  89. heading, dist, semi_major, semi_minor, proba)
  90. w = radius**2
  91. arguments = (mu_k, mu_h, sigma_k, sigma_h, w)
  92. # numerical integration (quadrature)
  93. integral = integrate.quad(kernel_function, 0., np.sqrt(w), args=arguments)
  94. # probability of strike within a circle
  95. konstanta = 1./(2.*np.sqrt(2.*np.pi)*sigma_h)
  96. P = konstanta*integral[0]
  97. # probability that a strike is within the radius around the point of interest
  98. print(P)
Add Comment
Please, Sign In to add comment