Changeset 2569 in lmdz_wrf
- Timestamp:
- May 29, 2019, 10:53:20 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/geometry_tools.py
r2568 r2569 47 47 ## Shapes/objects 48 48 # buoy1: Function to draw a buoy as superposition of prism and section of ball 49 # band_lighthouse: Function to plot a lighthouse with spiral bands 49 50 # circ_sec: Function union of point A and B by a section of a circle 50 51 # ellipse_polar: Function to determine an ellipse from its center and polar coordinates 52 # green_buoy1: Function to draw a green mark buoy using buoy1 51 53 # p_angle_triangle: Function to draw a triangle by an initial point and two 52 54 # consecutive angles and the first length of face. The third angle and 2 and 3rd … … 61 63 # p_spiral: Function to provide a polygon of an Archimedean spiral 62 64 # p_triangle: Function to provide the polygon of a triangle from its 3 vertices 63 # band_lighthouse: Function to plot a lighthouse with spiral bands 64 # green_buoy1: Function to draw a green mark buoy using buoy1 65 # prefchannelport[A/B]_buoy1: Function to draw a preferred channel port system 66 # [A/B] buoy using buoy1 67 # prefchannelstarboard[A/B]_buoy1: Function to draw a preferred channel starboard 68 # system [A/B] buoy using buoy1 65 69 # red_buoy1: Function to draw a red mark buoy using buoy1 66 70 # safewater_buoy1: Function to draw a safe water mark buoy using buoy1 … … 2186 2190 buoy = ma.masked_equal(buoy, gen.fillValueF) 2187 2191 2188 buoysecs = ['buoy', 'sign' , 'quarter1', 'quarter2', 'quarter3', 'quarter4']2192 buoysecs = ['buoy', 'sign'] 2189 2193 buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \ 2190 2194 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5]} … … 2223 2227 buoy = ma.masked_equal(buoy, gen.fillValueF) 2224 2228 2225 buoysecs = ['buoy', 'sign' , 'quarter1', 'quarter2', 'quarter3', 'quarter4']2229 buoysecs = ['buoy', 'sign'] 2226 2230 buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \ 2227 2231 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5]} 2232 2233 return buoy, buoysecs, buoydic 2234 2235 def prefchannelportA_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, \ 2236 N=300): 2237 """ Function to draw a preferred channel port system A buoy using buoy1 2238 height: height of the prism (5., default) 2239 width: width of the prism (10., default) 2240 bradii: radii of the ball (1.75, default) 2241 bfrac: fraction of the ball above the prism (0.8, default) 2242 hisgns: height of the signs [as reg. triangle] as percentage of the height 2243 (0.3, default) 2244 N: total number of points of the buoy (300, default) 2245 """ 2246 fname = 'prefchannelportA_buoy1' 2247 2248 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF 2249 2250 # buoy 2251 N2 = int(N/2) 2252 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ 2253 bfrac=0.8, N=N2) 2254 buoy[0:N2,:] = buoy1v 2255 2256 # signs 2257 N3 = N - N2 - 1 2258 lsign = height*hsigns*2. 2259 2260 Height = np.max(buoy1v[:,0]) 2261 triu = p_angle_triangle(N=N3) 2262 sign = triu*lsign 2263 buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.] 2264 2265 # painting it 2266 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom') 2267 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) 2268 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') 2269 2270 buoy = ma.masked_equal(buoy, gen.fillValueF) 2271 2272 buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3'] 2273 buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \ 2274 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5], 'third1': [third1,'-','g',1.5], \ 2275 'third2': [third2,'-','r',1.5], 'third3': [third3,'-','g',1.5]} 2276 2277 return buoy, buoysecs, buoydic 2278 2279 def prefchannelportB_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, \ 2280 N=300): 2281 """ Function to draw a preferred channel port system B buoy using buoy1 2282 height: height of the prism (5., default) 2283 width: width of the prism (10., default) 2284 bradii: radii of the ball (1.75, default) 2285 bfrac: fraction of the ball above the prism (0.8, default) 2286 hisgns: height of the signs [as reg. triangle] as percentage of the height 2287 (0.3, default) 2288 N: total number of points of the buoy (300, default) 2289 """ 2290 fname = 'prefchannelportB_buoy1' 2291 2292 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF 2293 2294 # buoy 2295 N2 = int(N/2) 2296 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ 2297 bfrac=0.8, N=N2) 2298 buoy[0:N2,:] = buoy1v 2299 2300 # signs 2301 N3 = N - N2 - 1 2302 lsign = height*hsigns*2. 2303 2304 Height = np.max(buoy1v[:,0]) 2305 triu = p_angle_triangle(N=N3) 2306 sign = triu*lsign 2307 buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.] 2308 2309 # painting it 2310 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom') 2311 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) 2312 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') 2313 2314 buoy = ma.masked_equal(buoy, gen.fillValueF) 2315 2316 buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3'] 2317 buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \ 2318 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'third1': [third1,'-','r',1.5], \ 2319 'third2': [third2,'-','g',1.5], 'third3': [third3,'-','r',1.5]} 2320 2321 return buoy, buoysecs, buoydic 2322 2323 def prefchannelstarboardA_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, \ 2324 hsigns=0.3, N=300): 2325 """ Function to draw a preferred channel starboard system A buoy using buoy1 2326 height: height of the prism (5., default) 2327 width: width of the prism (10., default) 2328 bradii: radii of the ball (1.75, default) 2329 bfrac: fraction of the ball above the prism (0.8, default) 2330 hisgns: height of the signs [as reg. triangle] as percentage of the height 2331 (0.3, default) 2332 N: total number of points of the buoy (300, default) 2333 """ 2334 fname = 'prefchannelstarboardA_buoy1' 2335 2336 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF 2337 2338 # buoy 2339 N2 = int(N/2) 2340 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ 2341 bfrac=0.8, N=N2) 2342 buoy[0:N2,:] = buoy1v 2343 2344 # signs 2345 N3 = N - N2 - 1 2346 lsign = height*hsigns*2. 2347 2348 Height = np.max(buoy1v[:,0]) 2349 sign = p_prism(lsign, lsign*2, N=N3) 2350 buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.] 2351 2352 # painting it 2353 # painting it 2354 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom') 2355 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) 2356 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') 2357 2358 buoy = ma.masked_equal(buoy, gen.fillValueF) 2359 2360 buoysecs = ['buoy', 'sign'] 2361 buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \ 2362 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'third1': [third1,'-','r',1.5], \ 2363 'third2': [third2,'-','g',1.5], 'third3': [third3,'-','r',1.5]} 2364 2365 return buoy, buoysecs, buoydic 2366 2367 def prefchannelstarboardB_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, \ 2368 hsigns=0.3, N=300): 2369 """ Function to draw a preferred channel starboard system B buoy using buoy1 2370 height: height of the prism (5., default) 2371 width: width of the prism (10., default) 2372 bradii: radii of the ball (1.75, default) 2373 bfrac: fraction of the ball above the prism (0.8, default) 2374 hisgns: height of the signs [as reg. triangle] as percentage of the height 2375 (0.3, default) 2376 N: total number of points of the buoy (300, default) 2377 """ 2378 fname = 'prefchannelstarboardB_buoy1' 2379 2380 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF 2381 2382 # buoy 2383 N2 = int(N/2) 2384 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ 2385 bfrac=0.8, N=N2) 2386 buoy[0:N2,:] = buoy1v 2387 2388 # signs 2389 N3 = N - N2 - 1 2390 lsign = height*hsigns*2. 2391 2392 Height = np.max(buoy1v[:,0]) 2393 sign = p_prism(lsign, lsign*2, N=N3) 2394 buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.] 2395 2396 # painting it 2397 # painting it 2398 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom') 2399 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) 2400 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') 2401 2402 buoy = ma.masked_equal(buoy, gen.fillValueF) 2403 2404 buoysecs = ['buoy', 'sign'] 2405 buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \ 2406 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5], 'third1': [third1,'-','g',1.5], \ 2407 'third2': [third2,'-','r',1.5], 'third3': [third3,'-','g',1.5]} 2228 2408 2229 2409 return buoy, buoysecs, buoydic
Note: See TracChangeset
for help on using the changeset viewer.