Changeset 2630 in lmdz_wrf
- Timestamp:
- Jun 23, 2019, 11:18:47 PM (5 years ago)
- Location:
- trunk/tools
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/geometry_tools.py
r2629 r2630 1 1 # Python tools to manage netCDF files. 2 # L. Fita, CIMA. M rch 20192 # L. Fita, CIMA. March 2019 3 3 # More information at: http://www.xn--llusfb-5va.cat/python/PyNCplot 4 4 # … … 51 51 52 52 ## Shapes/objects 53 # buoy1: Function to draw a buoy as superposition of prism and section of ball54 # band_lighthouse: Function to plot a lighthouse with spiral bands55 53 # circ_sec: Function union of point A and B by a section of a circle 56 54 # ellipse_polar: Function to determine an ellipse from its center and polar coordinates 57 # green_buoy1: Function to draw a green mark buoy using buoy158 # isolateddanger_buoy1: Function to draw an isolated danger buoy using buoy159 55 # p_angle_triangle: Function to draw a triangle by an initial point and two 60 56 # consecutive angles and the first length of face. The third angle and 2 and 3rd … … 70 66 # p_spiral: Function to provide a polygon of an Archimedean spiral 71 67 # p_triangle: Function to provide the polygon of a triangle from its 3 vertices 72 # prefchannelport[A/B]_buoy1: Function to draw a preferred channel port system73 # [A/B] buoy using buoy174 # prefchannelstarboard[A/B]_buoy1: Function to draw a preferred channel starboard75 # system [A/B] buoy using buoy176 # red_buoy1: Function to draw a red mark buoy using buoy177 # safewater_buoy1: Function to draw a safe water mark buoy using buoy178 # special_buoy1: Function to draw an special mark buoy using buoy179 68 # surface_sphere: Function to provide an sphere as matrix of x,y,z coordinates 80 # z_boat: Function to define an schematic boat from the z-plane81 # zsailing_boat: Function to define an schematic sailing boat from the z-plane with sails82 # zisland1: Function to draw an island from z-axis as the union of a series of points by83 # circular segments84 69 85 70 ## Plotting … … 87 72 # plot_sphere: Function to plot an sphere and determine which standard lines will be 88 73 # also drawn 89 # [north/east/south/west_buoy1: Function to draw a [North/East/South/West] danger buoy using buoy190 74 91 75 def deg_deci(angle): … … 2353 2337 return cross, crosssecs, crossdic 2354 2338 2355 # Combined objects2356 ##2357 2358 # FROM: http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html2359 def zboat(length=10., beam=1., lbeam=0.4, sternbp=0.5):2360 """ Function to define an schematic boat from the z-plane2361 length: length of the boat (without stern, default 10)2362 beam: beam of the boat (default 1)2363 lbeam: length at beam (as percentage of length, default 0.4)2364 sternbp: beam at stern (as percentage of beam, default 0.5)2365 """2366 fname = 'zboat'2367 2368 bow = np.array([length, 0.])2369 maxportside = np.array([length*lbeam, -beam])2370 maxstarboardside = np.array([length*lbeam, beam])2371 portside = np.array([0., -beam*sternbp])2372 starboardside = np.array([0., beam*sternbp])2373 2374 # forward section2375 fportside = circ_sec(maxportside, bow, length*2)2376 fstarboardside = circ_sec(bow, maxstarboardside, length*2)2377 # aft section2378 aportside = circ_sec(portside, maxportside, length*2)2379 astarboardside = circ_sec(maxstarboardside, starboardside, length*2)2380 # stern2381 stern = circ_sec(starboardside, portside, length*2)2382 2383 dpts = stern.shape[0]2384 boat = np.zeros((dpts*5,2), dtype=np.float)2385 2386 boat[0:dpts,:] = aportside2387 boat[dpts:2*dpts,:] = fportside2388 boat[2*dpts:3*dpts,:] = fstarboardside2389 boat[3*dpts:4*dpts,:] = astarboardside2390 boat[4*dpts:5*dpts,:] = stern2391 2392 fname = 'boat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) + '_lb' + \2393 str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) + '.dat'2394 if not os.path.isfile(fname):2395 print infmsg2396 print ' ' + fname + ": writting boat coordinates file '" + fname + "' !!"2397 of = open(fname, 'w')2398 of.write('# boat file with Length: ' + str(length) +' max_beam: '+str(beam)+ \2399 'length_at_max_beam:' + str(lbeam) + '% beam at stern: ' + str(sternbp)+ \2400 ' %\n')2401 for ip in range(dpts*5):2402 of.write(str(boat[ip,0]) + ' ' + str(boat[ip,1]) + '\n')2403 2404 of.close()2405 print fname + ": Successfull written '" + fname + "' !!"2406 2407 2408 # Center line extending [fcl] percentage from length on aft and stern2409 fcl = 0.152410 centerline = np.zeros((dpts,2), dtype=np.float)2411 dl = length*(1.+fcl*2.)/(dpts-1)2412 centerline[:,0] = np.arange(-length*fcl, length*(1. + fcl)+dl, dl)2413 2414 # correct order of sections2415 boatsecs = ['aportside', 'fportside', 'fstarboardside', 'astarboardside', \2416 'stern', 'centerline']2417 2418 # dictionary with sections [polygon_vertices, line_type, line_color, line_width]2419 dicboat = {'fportside': [fportside, '-', '#8A5900', 2.], \2420 'aportside': [aportside, '-', '#8A5900', 2.], \2421 'stern': [stern, '-', '#8A5900', 2.], \2422 'astarboardside': [astarboardside, '-', '#8A5900', 2.], \2423 'fstarboardside': [fstarboardside, '-', '#8A5900', 2.], \2424 'centerline': [centerline, '-.', '#AA6464', 1.5]}2425 2426 fname = 'sailboat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) + \2427 '_lb' + str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) +'.dat'2428 if not os.path.isfile(fname):2429 print infmsg2430 print ' ' + fname + ": writting boat coordinates file '" + fname + "' !!"2431 of = open(fname, 'w')2432 of.write('# boat file with Length: ' + str(length) +' max_beam: '+str(beam)+ \2433 'length_at_max_beam:' + str(lbeam) + '% beam at stern: ' +str(sternbp)+'\n')2434 for ip in range(dpts*5):2435 of.write(str(boat[ip,0]) + ' ' + str(boat[ip,1]) + '\n')2436 2437 of.close()2438 print fname + ": Successfull written '" + fname + "' !!"2439 2440 return boat, boatsecs, dicboat2441 2442 def zsailing_boat(length=10., beam=1., lbeam=0.4, sternbp=0.5, lmast=0.6, wmast=0.1, \2443 hsd=5., msd=5., lheads=0.38, lmains=0.55):2444 """ Function to define an schematic sailing boat from the z-plane with sails2445 length: length of the boat (without stern, default 10)2446 beam: beam of the boat (default 1)2447 lbeam: length at beam (as percentage of length, default 0.4)2448 sternbp: beam at stern (as percentage of beam, default 0.5)2449 lmast: position of the mast (as percentage of length, default 0.6)2450 wmast: width of the mast (default 0.1)2451 hsd: head sail direction respect to center line (default 5., -999.99 for upwind)2452 msd: main sail direction respect to center line (default 5., -999.99 for upwind)2453 lheads: length of head sail (as percentage of legnth, defaul 0.38)2454 lmains: length of main sail (as percentage of legnth, defaul 0.55)2455 """2456 fname = 'zsailing_boat'2457 2458 bow = np.array([length, 0.])2459 maxportside = np.array([length*lbeam, -beam])2460 maxstarboardside = np.array([length*lbeam, beam])2461 portside = np.array([0., -beam*sternbp])2462 starboardside = np.array([0., beam*sternbp])2463 2464 aportside = circ_sec(portside, maxportside, length*2)2465 fportside = circ_sec(maxportside, bow, length*2)2466 fstarboardside = circ_sec(bow, maxstarboardside, length*2)2467 astarboardside = circ_sec(maxstarboardside, starboardside, length*2)2468 stern = circ_sec(starboardside, portside, length*2)2469 dpts = fportside.shape[0]2470 2471 # correct order of sections2472 sailingboatsecs = ['aportside', 'fportside', 'fstarboardside', 'astarboardside', \2473 'stern', 'mast', 'hsail', 'msail', 'centerline']2474 2475 # forward section2476 2477 # aft section2478 # stern2479 # mast2480 mast = p_circle(wmast,N=dpts)2481 mast = mast + [length*lmast, 0.]2482 # head sails2483 lsail = lheads*length2484 if hsd != -999.99:2485 sailsa = np.pi/2. - np.pi*hsd/180.2486 endsail = np.array([lsail*np.sin(sailsa), lsail*np.cos(sailsa)])2487 endsail[0] = length - endsail[0]2488 if bow[1] > endsail[1]:2489 hsail = circ_sec(endsail, bow, lsail*2.15)2490 else:2491 hsail = circ_sec(bow, endsail, lsail*2.15)2492 else:2493 hsail0 = p_sinusiode(length=lsail, amp=0.2, lamb=0.75, N=dpts)2494 hsail = np.zeros((dpts,2), dtype=np.float)2495 hsail[:,0] = hsail0[:,1]2496 hsail[:,1] = hsail0[:,0]2497 hsail = bow - hsail2498 2499 # main sails2500 lsail = lmains*length2501 if msd != -999.99:2502 sailsa = np.pi/2. - np.pi*msd/180.2503 begsail = np.array([length*lmast, 0.])2504 endsail = np.array([lsail*np.sin(sailsa), lsail*np.cos(sailsa)])2505 endsail[0] = length*lmast - endsail[0]2506 if endsail[1] > begsail[1]:2507 msail = circ_sec(begsail, endsail, lsail*2.15)2508 else:2509 msail = circ_sec(endsail, begsail, lsail*2.15)2510 else:2511 msail0 = p_sinusiode(length=lsail, amp=0.25, lamb=1., N=dpts)2512 msail = np.zeros((dpts,2), dtype=np.float)2513 msail[:,0] = msail0[:,1]2514 msail[:,1] = msail0[:,0]2515 msail = [length*lmast,0] - msail2516 2517 sailingboat = np.zeros((dpts*8+4,2), dtype=np.float)2518 2519 sailingboat[0:dpts,:] = aportside2520 sailingboat[dpts:2*dpts,:] = fportside2521 sailingboat[2*dpts:3*dpts,:] = fstarboardside2522 sailingboat[3*dpts:4*dpts,:] = astarboardside2523 sailingboat[4*dpts:5*dpts,:] = stern2524 sailingboat[5*dpts,:] = [gen.fillValueF, gen.fillValueF]2525 sailingboat[5*dpts+1:6*dpts+1,:] = mast2526 sailingboat[6*dpts+1,:] = [gen.fillValueF, gen.fillValueF]2527 sailingboat[6*dpts+2:7*dpts+2,:] = hsail2528 sailingboat[7*dpts+2,:] = [gen.fillValueF, gen.fillValueF]2529 sailingboat[7*dpts+3:8*dpts+3,:] = msail2530 sailingboat[8*dpts+3,:] = [gen.fillValueF, gen.fillValueF]2531 2532 sailingboat = ma.masked_equal(sailingboat, gen.fillValueF)2533 2534 # Center line extending [fcl] percentage from length on aft and stern2535 fcl = 0.152536 centerline = np.zeros((dpts,2), dtype=np.float)2537 dl = length*(1.+fcl*2.)/(dpts-1)2538 centerline[:,0] = np.arange(-length*fcl, length*(1. + fcl)+dl, dl)2539 2540 # dictionary with sections [polygon_vertices, line_type, line_color, line_width]2541 dicsailingboat = {'fportside': [fportside, '-', '#8A5900', 2.], \2542 'aportside': [aportside, '-', '#8A5900', 2.], \2543 'stern': [stern, '-', '#8A5900', 2.], \2544 'astarboardside': [astarboardside, '-', '#8A5900', 2.], \2545 'fstarboardside': [fstarboardside, '-', '#8A5900', 2.], \2546 'mast': [mast, '-', '#8A5900', 2.], 'hsail': [hsail, '-', '#AAAAAA', 1.], \2547 'msail': [msail, '-', '#AAAAAA', 1.], \2548 'centerline': [centerline, '-.', '#AA6464', 1.5]}2549 2550 fname = 'sailboat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) + \2551 '_lb' + str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) + \2552 '_lm' + str(int(lmast*100.)) + '_wm' + str(int(wmast)) + \2553 '_hsd' + str(int(hsd)) + '_hs' + str(int(lheads*100.)) + \2554 '_ms' + str(int(lheads*100.)) + '_msd' + str(int(msd)) +'.dat'2555 if not os.path.isfile(fname):2556 print infmsg2557 print ' ' + fname + ": writting boat coordinates file '" + fname + "' !!"2558 of = open(fname, 'w')2559 of.write('# boat file with Length: ' + str(length) +' max_beam: '+str(beam)+ \2560 'length_at_max_beam:' + str(lbeam) + '% beam at stern: ' + str(sternbp)+ \2561 ' % mast position: '+ str(lmast) + ' % mast width: ' + str(wmast) + ' ' + \2562 ' head sail direction:' + str(hsd) + ' head sail length: ' + str(lheads) + \2563 ' %' + ' main sail length' + str(lmains) + ' main sail direction:' + \2564 str(msd) +'\n')2565 for ip in range(dpts*5):2566 of.write(str(sailingboat[ip,0]) + ' ' + str(sailingboat[ip,1]) + '\n')2567 2568 of.close()2569 print fname + ": Successfull written '" + fname + "' !!"2570 2571 return sailingboat, sailingboatsecs, dicsailingboat2572 2573 def zisland1(mainpts= np.array([[-0.1,0.], [-1.,1.], [-0.8,1.2], [0.1,0.6], [1., 0.9],\2574 [2.8, -0.1], [0.1,-0.6]], dtype=np.float), radfrac=3., N=200):2575 """ Function to draw an island from z-axis as the union of a series of points by2576 circular segments2577 mainpts: main points of the island (clockwise ordered, to be joined by2578 circular segments of radii as the radfrac factor of the distance between2579 consecutive points)2580 * default= np.array([[-0.1,0.], [-1.,1.], [-0.8,1.2], [0.1,0.6], [1., 0.9],2581 [2.8, -0.1], [0.1,-0.6]], dtype=np.float)2582 radfrac: multiplicative factor of the distance between consecutive points to2583 draw the circular segment (3., default)2584 N: number of points (200, default)2585 """2586 fname = 'zisland1'2587 2588 island1 = np.ones((N,2), dtype=np.float)*gen.fillValueF2589 2590 # Coastline2591 island1 = join_circ_sec_rand(mainpts, arc='short', pos='left')2592 2593 islandsecs = ['coastline']2594 islanddic = {'coastline': [island1, '-', '#161616', 2.]}2595 2596 island1 = ma.masked_equal(island1, gen.fillValueF)2597 2598 return island1, islandsecs, islanddic2599 2600 def buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=300):2601 """ Function to draw a buoy as superposition of prism and section of ball2602 height: height of the prism (5., default)2603 width: width of the prism (10., default)2604 bradii: radii of the ball (1.75, default)2605 bfrac: fraction of the ball above the prism (0.8, default)2606 N: total number of points of the buoy (300, default)2607 """2608 fname = 'buoy1'2609 2610 buoy = np.zeros((N,2), dtype=np.float)2611 2612 N3 = int(N/3/5)2613 NNp = 02614 iip = 02615 # left lateral2616 ix = -width/2.2617 Np = N32618 iy = 0.2619 dx = 0.2620 dy = height/(Np)2621 for ip in range(Np):2622 buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]2623 NNp = NNp + Np2624 iip = NNp2625 2626 # left upper2627 ix = -width/2.2628 iy = height2629 dx = (width/2.-bradii*bfrac)/(Np)2630 dy = 0.2631 for ip in range(Np):2632 buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]2633 NNp = NNp + Np2634 iip = NNp2635 2636 # ball2637 p1 = np.array([height, -bradii*bfrac])2638 p2 = np.array([height, bradii*bfrac])2639 Np = int(2*N/3)2640 buoy[iip:iip+Np,:] = circ_sec(p1, p2, 2.*bradii, 'long', 'left', Np)2641 NNp = NNp + Np2642 iip = NNp2643 2644 # right upper2645 ix = bradii*bfrac2646 iy = height2647 Np = N32648 dx = (width/2.-bradii*bfrac)/(Np)2649 dy = 0.2650 for ip in range(Np):2651 buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]2652 NNp = NNp + Np2653 iip = NNp2654 2655 # right lateral2656 ix = width/2.2657 iy = height2658 dx = 0.2659 dy = -height/(Np)2660 for ip in range(Np):2661 buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]2662 NNp = NNp + Np2663 iip = NNp2664 2665 # Base2666 ix = width/2.2667 iy = 0.2668 Np = N - int(2*N/3) - 4*N3 - 12669 dx = -width/(Np)2670 dy = 0.2671 for ip in range(Np):2672 buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]2673 NNp = NNp + Np2674 iip = NNp2675 2676 buoy[N-1,:] = buoy[0,:]2677 2678 buoysecs = ['base']2679 buoydic = {'base': [buoy, '-', 'k', 1.5]}2680 2681 return buoy, buoysecs, buoydic2682 2683 def band_lighthouse(height=10., width=2., hlight=3., bands=3, N=300):2684 """ Function to plot a lighthouse with spiral bands2685 height: height of the tower (10., default)2686 width: width of the tower (2., default)2687 hlight: height of the light (3., default)2688 bands: number of spiral bands (3, default)2689 N: number of points (300, default)2690 """2691 fname = 'band_lighthouse'2692 2693 lighthouse = np.ones((N,2), dtype=np.float)*gen.fillValueF2694 lighthousesecs = []2695 lighthousedic = {}2696 2697 # base Tower2698 Nsec = int(0.30*N/7)2699 p1=np.array([0., width/2.])2700 p2=np.array([0., -width/2.])2701 iip = 02702 lighthouse[0:Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec)2703 iip = iip + Nsec2704 2705 # left side2706 ix=-width/2.2707 iy=0.2708 dx = 0.2709 dy = height/(Nsec-1)2710 for ip in range(Nsec):2711 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip]2712 iip = iip + Nsec2713 2714 # Top Tower2715 p1=np.array([height, width/2.])2716 p2=np.array([height, -width/2.])2717 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec)2718 iip = iip + Nsec2719 2720 # right side2721 ix=width/2.2722 iy=height2723 dx = 0.2724 dy = -height/(Nsec-1)2725 for ip in range(Nsec):2726 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip]2727 iip = iip + Nsec + 12728 2729 Ntower = iip-12730 lighthousesecs.append('tower')2731 lighthousedic['tower'] = [lighthouse[0:iip-1], '-', 'k', 1.5]2732 2733 # Left light2734 p1 = np.array([height, -width*0.8/2.])2735 p2 = np.array([height+hlight, -width*0.8/2.])2736 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*hlight, Nang=Nsec)2737 iip = iip + Nsec2738 2739 # Top Light2740 p1=np.array([height+hlight, width*0.8/2.])2741 p2=np.array([height+hlight, -width*0.8/2.])2742 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec)2743 iip = iip + Nsec + 12744 2745 # Right light2746 p1 = np.array([height+hlight, width*0.8/2.])2747 p2 = np.array([height, width*0.8/2.])2748 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*hlight, Nang=Nsec)2749 iip = iip + Nsec2750 2751 # Base Light2752 p1=np.array([height, width*0.8/2.])2753 p2=np.array([height, -width*0.8/2.])2754 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec)2755 iip = iip + Nsec + 12756 lighthousesecs.append('light')2757 lighthousedic['light'] = [lighthouse[Ntower+1:iip-1], '-', '#EEEE00', 1.5]2758 2759 # Spiral bands2760 hb = height/(2.*bands)2761 Nsec2 = (N - Nsec*8 - 3)/bands2762 for ib in range(bands-1):2763 iband = iip2764 Nsec = Nsec2/42765 bandS = 'band' + str(ib).zfill(2)2766 # hband2767 ix = -width/2.2768 iy = hb*ib*22769 dx = 0.2770 dy = hb/(Nsec-1)2771 for ip in range(Nsec):2772 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip]2773 iip = iip + Nsec2774 # uband2775 p1 = np.array([hb*(ib*2+1), -width/2.])2776 p2 = np.array([hb*(ib*2+2), width/2.])2777 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='right', Nang=Nsec)2778 iip = iip + Nsec2779 # dband2780 ix = width/2.2781 iy = hb*(ib*2+2)2782 dx = 0.2783 dy = -hb/(Nsec-1)2784 for ip in range(Nsec):2785 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip]2786 iip = iip + Nsec2787 # dband2788 p1 = np.array([hb*(ib*2+1), width/2.])2789 p2 = np.array([hb*ib*2, -width/2.])2790 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec)2791 iip = iip + Nsec + 12792 lighthousesecs.append(bandS)2793 lighthousedic[bandS] = [lighthouse[iband:iip-1], '-', '#6408AA', 2.]2794 2795 ib = bands-12796 Nsec3 = (N - iip - 1)2797 Nsec = int(Nsec3/4)2798 bandS = 'band' + str(ib).zfill(2)2799 # hband2800 iband = iip2801 ix = -width/2.2802 iy = hb*ib*22803 dx = 0.2804 dy = hb/(Nsec-1)2805 for ip in range(Nsec):2806 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip]2807 iip = iip + Nsec2808 # uband2809 p1 = np.array([hb*(ib*2+1), -width/2.])2810 p2 = np.array([hb*(ib*2+2), width/2.])2811 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='right', Nang=Nsec)2812 iip = iip + Nsec2813 # dband2814 ix = width/2.2815 iy = hb*(2+ib*2)2816 dx = 0.2817 dy = -hb/(Nsec-1)2818 for ip in range(Nsec):2819 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip]2820 iip = iip + Nsec2821 # dband2822 Nsec = N - iip2823 p1 = np.array([hb*(1+ib*2), width/2.])2824 p2 = np.array([hb*ib*2, -width/2.])2825 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec)2826 lighthousesecs.append(bandS)2827 lighthousedic[bandS] = [lighthouse[iband:iip-1], '-', '#6408AA', 2.]2828 2829 lighthouse = ma.masked_equal(lighthouse, gen.fillValueF)2830 2831 return lighthouse, lighthousesecs, lighthousedic2832 2833 def north_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300):2834 """ Function to draw a North danger buoy using buoy12835 height: height of the prism (5., default)2836 width: width of the prism (10., default)2837 bradii: radii of the ball (1.75, default)2838 bfrac: fraction of the ball above the prism (0.8, default)2839 hisgns: height of the signs [as reg. triangle] as percentage of the height2840 (0.7, default)2841 N: total number of points of the buoy (300, default)2842 """2843 fname = 'north_buoy1'2844 2845 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF2846 2847 # buoy2848 N2 = int(N/2)2849 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \2850 bfrac=0.8, N=N2)2851 buoy[0:N2,:] = buoy1v2852 2853 # signs2854 N3 = N - N2 - 22855 2856 bottsigns = 2.*bradii+height2857 lsign = height*hsigns2858 # up2859 N32 = int(N3/2)2860 triu = p_angle_triangle(N=N32)2861 trib = triu*lsign + [0.,-lsign/2.]2862 2863 buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.1*lsign,0.]2864 2865 # up2866 N323 = N - N32 - N2 - 22867 trid = p_angle_triangle(N=N323)2868 trib = trid*lsign + [0.,-lsign/2.]2869 buoy[N2+N32+2:N,:] = trib + [bottsigns+1.1*lsign,0.]2870 2871 # painting it2872 Height = np.max(buoy1v[:,0])2873 2874 Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/2., keep='below')2875 Ncut, halfup = cut_ypolygon(buoy1v, yval=Height/2., keep='above')2876 2877 buoy = ma.masked_equal(buoy, gen.fillValueF)2878 2879 buoysecs = ['buoy', 'sign1', 'sign2', 'half1', 'half2']2880 buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \2881 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \2882 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], 'half1': [halfup, '-', 'k', 1.], \2883 'half2': [halfdown, '-', '#FFFF00', 1.]}2884 2885 return buoy, buoysecs, buoydic2886 2887 def east_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300):2888 """ Function to draw a East danger buoy using buoy12889 height: height of the prism (5., default)2890 width: width of the prism (10., default)2891 bradii: radii of the ball (1.75, default)2892 bfrac: fraction of the ball above the prism (0.8, default)2893 hisgns: height of the signs [as reg. triangle] as percentage of the height2894 (0.7, default)2895 N: total number of points of the buoy (300, default)2896 """2897 fname = 'east_buoy1'2898 2899 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF2900 2901 # buoy2902 N2 = int(N/2)2903 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2)2904 buoy[0:N2,:] = buoy1v2905 2906 # signs2907 N3 = N - N2 - 22908 2909 bottsigns = 2.*bradii+height2910 lsign = height*hsigns2911 # up2912 N32 = int(N3/2)2913 triu = p_angle_triangle(N=N32)2914 trib = triu*lsign + [0.,-lsign/2.]2915 2916 buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.1*lsign,0.]2917 2918 # down2919 N323 = N - N32 - N2 - 22920 2921 trid = p_angle_triangle(N=N323)2922 trid = mirror_polygon(trid, 'x')2923 trib = trid*lsign + [lsign,-lsign/2.]2924 buoy[N2+N32+2:N,:] = trib + [bottsigns+0.9*lsign,0.]2925 2926 # painting it2927 Height = np.max(buoy1v[:,0])2928 2929 Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/3., keep='below')2930 Ncut, halfbtw = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)2931 Ncut, halfup = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')2932 2933 buoy = ma.masked_equal(buoy, gen.fillValueF)2934 2935 buoysecs = ['buoy', 'sign1', 'sign2', 'third1', 'third2', 'third3']2936 buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \2937 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \2938 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], \2939 'third1': [halfup, '-', 'k', 1.], 'third2': [halfbtw, '-', '#FFFF00', 1.], \2940 'third3': [halfdown, '-', 'k', 1.]}2941 2942 return buoy, buoysecs, buoydic2943 2944 def south_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300):2945 """ Function to draw a South danger buoy using buoy12946 height: height of the prism (5., default)2947 width: width of the prism (10., default)2948 bradii: radii of the ball (1.75, default)2949 bfrac: fraction of the ball above the prism (0.8, default)2950 hisgns: height of the signs [as reg. triangle] as percentage of the height2951 (0.7, default)2952 N: total number of points of the buoy (300, default)2953 """2954 fname = 'south_buoy1'2955 2956 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF2957 2958 # buoy2959 N2 = int(N/2)2960 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2)2961 buoy[0:N2,:] = buoy1v2962 2963 # signs2964 N3 = N - N2 - 22965 2966 bottsigns = 2.*bradii+height2967 lsign = height*hsigns2968 # up2969 N32 = int(N3/2)2970 trid = p_angle_triangle(N=N32)2971 trid = mirror_polygon(trid, 'x')2972 trib = trid*lsign + [0.,-lsign/2.]2973 2974 buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.9*lsign,0.]2975 2976 # down2977 N323 = N - N32 - N2 - 22978 trid = p_angle_triangle(N=N323)2979 trid = mirror_polygon(trid, 'x')2980 trib = trid*lsign + [lsign,-lsign/2.]2981 buoy[N2+N32+2:N,:] = trib + [bottsigns+0.9*lsign,0.]2982 2983 # painting it2984 Height = np.max(buoy1v[:,0])2985 2986 Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/2., keep='below')2987 Ncut, halfup = cut_ypolygon(buoy1v, yval=Height/2., keep='above')2988 2989 buoy = ma.masked_equal(buoy, gen.fillValueF)2990 2991 buoysecs = ['buoy', 'sign1', 'sign2', 'half1', 'half2']2992 buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \2993 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \2994 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], 'half1': [halfup, '-', '#FFFF00', 1.], \2995 'half2': [halfdown, '-', 'k', 1.]}2996 2997 return buoy, buoysecs, buoydic2998 2999 def west_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300):3000 """ Function to draw a West danger buoy using buoy13001 height: height of the prism (5., default)3002 width: width of the prism (10., default)3003 bradii: radii of the ball (1.75, default)3004 bfrac: fraction of the ball above the prism (0.8, default)3005 hisgns: height of the signs [as reg. triangle] as percentage of the height3006 (0.7, default)3007 N: total number of points of the buoy (300, default)3008 """3009 fname = 'east_buoy1'3010 3011 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3012 3013 # buoy3014 N2 = int(N/2)3015 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2)3016 buoy[0:N2,:] = buoy1v3017 3018 # signs3019 N3 = N - N2 - 23020 3021 bottsigns = 2.*bradii+height3022 lsign = height*hsigns3023 3024 # down3025 N32 = int(N3/2)3026 trid = p_angle_triangle(N=N32)3027 trid = mirror_polygon(trid, 'x')3028 trib = trid*lsign + [lsign,-lsign/2.]3029 buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+1.9*lsign,0.]3030 3031 # up3032 N323 = N - N32 - N2 - 23033 triu = p_angle_triangle(N=N323)3034 trib = triu*lsign + [0.,-lsign/2.]3035 3036 buoy[N2+N323+2:N,:] = trib + [bottsigns+1.*lsign,0.]3037 3038 # painting it3039 Height = np.max(buoy1v[:,0])3040 3041 Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/3., keep='below')3042 Ncut, halfbtw1 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)3043 Ncut, halfup = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')3044 3045 buoy = ma.masked_equal(buoy, gen.fillValueF)3046 3047 buoysecs = ['buoy', 'sign1', 'sign2', 'third1', 'third2', 'third3']3048 buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \3049 'third1': [halfdown, '-', '#FFFF00', 1.], 'third2': [halfbtw1, '-', 'k', 1.], \3050 'third3': [halfup, '-', '#FFFF00', 1.], \3051 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \3052 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5]}3053 3054 return buoy, buoysecs, buoydic3055 3056 def safewater_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, N=300):3057 """ Function to draw a safe water mark buoy using buoy13058 height: height of the prism (5., default)3059 width: width of the prism (10., default)3060 bradii: radii of the ball (1.75, default)3061 bfrac: fraction of the ball above the prism (0.8, default)3062 hisgns: height of the signs [as reg. triangle] as percentage of the height3063 (0.3, default)3064 N: total number of points of the buoy (300, default)3065 """3066 fname = 'safewater_buoy1'3067 3068 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3069 3070 # buoy3071 N2 = int(N/2)3072 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3073 bfrac=0.8, N=N2)3074 buoy[0:N2,:] = buoy1v3075 3076 # signs3077 N3 = N - N2 - 13078 lsign = height*hsigns3079 3080 Height = np.max(buoy1v[:,0])3081 sign = p_circle(lsign, N3)3082 buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.]3083 3084 # painting it3085 ix = -width/2.3086 Ncut, quarter1 = cut_xpolygon(buoy1v, xval=ix+width/4., keep='left')3087 Ncut, quarter2 = cut_between_xpolygon(buoy1v, xval1=ix+width/4., xval2=ix+width/2.)3088 Ncut, quarter3 = cut_between_xpolygon(buoy1v, xval1=ix+width/2., xval2=ix+3.*width/4.)3089 Ncut, quarter4 = cut_xpolygon(buoy1v, xval=ix+3.*width/4., keep='right')3090 3091 buoy = ma.masked_equal(buoy, gen.fillValueF)3092 3093 buoysecs = ['buoy', 'sign', 'quarter1', 'quarter2', 'quarter3', 'quarter4']3094 buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \3095 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'quarter1': [quarter1,'-','r',1.], \3096 'quarter2': [quarter2,'-','#FFFFFF',1.], 'quarter3': [quarter3,'-','r',1.], \3097 'quarter4': [quarter4,'-','#FFFFFF',1.]}3098 3099 return buoy, buoysecs, buoydic3100 3101 def red_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, N=300):3102 """ Function to draw a red mark buoy using buoy13103 height: height of the prism (5., default)3104 width: width of the prism (10., default)3105 bradii: radii of the ball (1.75, default)3106 bfrac: fraction of the ball above the prism (0.8, default)3107 hisgns: height of the signs [as reg. triangle] as percentage of the height3108 (0.3, default)3109 N: total number of points of the buoy (300, default)3110 """3111 fname = 'red_buoy1'3112 3113 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3114 3115 # buoy3116 N2 = int(N/2)3117 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3118 bfrac=0.8, N=N2)3119 buoy[0:N2,:] = buoy1v3120 3121 # signs3122 N3 = N - N2 - 13123 lsign = height*hsigns*2.3124 3125 Height = np.max(buoy1v[:,0])3126 triu = p_angle_triangle(N=N3)3127 sign = triu*lsign3128 buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.]3129 3130 # painting it3131 buoy = ma.masked_equal(buoy, gen.fillValueF)3132 3133 buoysecs = ['buoy', 'sign']3134 buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \3135 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5]}3136 3137 return buoy, buoysecs, buoydic3138 3139 def green_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, N=300):3140 """ Function to draw a green mark buoy using buoy13141 height: height of the prism (5., default)3142 width: width of the prism (10., default)3143 bradii: radii of the ball (1.75, default)3144 bfrac: fraction of the ball above the prism (0.8, default)3145 hisgns: height of the signs [as reg. triangle] as percentage of the height3146 (0.3, default)3147 N: total number of points of the buoy (300, default)3148 """3149 fname = 'green_buoy1'3150 3151 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3152 3153 # buoy3154 N2 = int(N/2)3155 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3156 bfrac=0.8, N=N2)3157 buoy[0:N2,:] = buoy1v3158 3159 # signs3160 N3 = N - N2 - 13161 lsign = height*hsigns*2.3162 3163 Height = np.max(buoy1v[:,0])3164 sign = p_prism(lsign, lsign*2, N=N3)3165 buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.]3166 3167 # painting it3168 buoy = ma.masked_equal(buoy, gen.fillValueF)3169 3170 buoysecs = ['buoy', 'sign']3171 buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \3172 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5]}3173 3174 return buoy, buoysecs, buoydic3175 3176 def prefchannelportA_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, \3177 N=300):3178 """ Function to draw a preferred channel port system A buoy using buoy13179 height: height of the prism (5., default)3180 width: width of the prism (10., default)3181 bradii: radii of the ball (1.75, default)3182 bfrac: fraction of the ball above the prism (0.8, default)3183 hisgns: height of the signs [as reg. triangle] as percentage of the height3184 (0.3, default)3185 N: total number of points of the buoy (300, default)3186 """3187 fname = 'prefchannelportA_buoy1'3188 3189 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3190 3191 # buoy3192 N2 = int(N/2)3193 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3194 bfrac=0.8, N=N2)3195 buoy[0:N2,:] = buoy1v3196 3197 # signs3198 N3 = N - N2 - 13199 lsign = height*hsigns*2.3200 3201 Height = np.max(buoy1v[:,0])3202 triu = p_angle_triangle(N=N3)3203 sign = triu*lsign3204 buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.]3205 3206 # painting it3207 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')3208 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)3209 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')3210 3211 buoy = ma.masked_equal(buoy, gen.fillValueF)3212 3213 buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3']3214 buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \3215 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5], 'third1': [third1,'-','g',1.5], \3216 'third2': [third2,'-','r',1.5], 'third3': [third3,'-','g',1.5]}3217 3218 return buoy, buoysecs, buoydic3219 3220 def prefchannelportB_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, \3221 N=300):3222 """ Function to draw a preferred channel port system B buoy using buoy13223 height: height of the prism (5., default)3224 width: width of the prism (10., default)3225 bradii: radii of the ball (1.75, default)3226 bfrac: fraction of the ball above the prism (0.8, default)3227 hisgns: height of the signs [as reg. triangle] as percentage of the height3228 (0.3, default)3229 N: total number of points of the buoy (300, default)3230 """3231 fname = 'prefchannelportB_buoy1'3232 3233 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3234 3235 # buoy3236 N2 = int(N/2)3237 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3238 bfrac=0.8, N=N2)3239 buoy[0:N2,:] = buoy1v3240 3241 # signs3242 N3 = N - N2 - 13243 lsign = height*hsigns*2.3244 3245 Height = np.max(buoy1v[:,0])3246 triu = p_angle_triangle(N=N3)3247 sign = triu*lsign3248 buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.]3249 3250 # painting it3251 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')3252 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)3253 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')3254 3255 buoy = ma.masked_equal(buoy, gen.fillValueF)3256 3257 buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3']3258 buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \3259 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'third1': [third1,'-','r',1.5], \3260 'third2': [third2,'-','g',1.5], 'third3': [third3,'-','r',1.5]}3261 3262 return buoy, buoysecs, buoydic3263 3264 def prefchannelstarboardA_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, \3265 hsigns=0.3, N=300):3266 """ Function to draw a preferred channel starboard system A buoy using buoy13267 height: height of the prism (5., default)3268 width: width of the prism (10., default)3269 bradii: radii of the ball (1.75, default)3270 bfrac: fraction of the ball above the prism (0.8, default)3271 hisgns: height of the signs [as reg. triangle] as percentage of the height3272 (0.3, default)3273 N: total number of points of the buoy (300, default)3274 """3275 fname = 'prefchannelstarboardA_buoy1'3276 3277 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3278 3279 # buoy3280 N2 = int(N/2)3281 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3282 bfrac=0.8, N=N2)3283 buoy[0:N2,:] = buoy1v3284 3285 # signs3286 N3 = N - N2 - 13287 lsign = height*hsigns*2.3288 3289 Height = np.max(buoy1v[:,0])3290 sign = p_prism(lsign, lsign*2, N=N3)3291 buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.]3292 3293 # painting it3294 # painting it3295 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')3296 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)3297 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')3298 3299 buoy = ma.masked_equal(buoy, gen.fillValueF)3300 3301 buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3']3302 buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \3303 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'third1': [third1,'-','r',1.5], \3304 'third2': [third2,'-','g',1.5], 'third3': [third3,'-','r',1.5]}3305 3306 return buoy, buoysecs, buoydic3307 3308 def prefchannelstarboardB_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, \3309 hsigns=0.3, N=300):3310 """ Function to draw a preferred channel starboard system B buoy using buoy13311 height: height of the prism (5., default)3312 width: width of the prism (10., default)3313 bradii: radii of the ball (1.75, default)3314 bfrac: fraction of the ball above the prism (0.8, default)3315 hisgns: height of the signs [as reg. triangle] as percentage of the height3316 (0.3, default)3317 N: total number of points of the buoy (300, default)3318 """3319 fname = 'prefchannelstarboardB_buoy1'3320 3321 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3322 3323 # buoy3324 N2 = int(N/2)3325 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3326 bfrac=0.8, N=N2)3327 buoy[0:N2,:] = buoy1v3328 3329 # signs3330 N3 = N - N2 - 13331 lsign = height*hsigns*2.3332 3333 Height = np.max(buoy1v[:,0])3334 sign = p_prism(lsign, lsign*2, N=N3)3335 buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.]3336 3337 # painting it3338 # painting it3339 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')3340 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)3341 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')3342 3343 buoy = ma.masked_equal(buoy, gen.fillValueF)3344 3345 buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3']3346 buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \3347 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5], 'third1': [third1,'-','g',1.5], \3348 'third2': [third2,'-','r',1.5], 'third3': [third3,'-','g',1.5]}3349 3350 return buoy, buoysecs, buoydic3351 3352 def isolateddanger_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5, \3353 N=300):3354 """ Function to draw an isolated danger buoy using buoy13355 height: height of the prism (5., default)3356 width: width of the prism (10., default)3357 bradii: radii of the ball (1.75, default)3358 bfrac: fraction of the ball above the prism (0.8, default)3359 hisgns: height of the signs [as reg. triangle] as percentage of the height3360 (0.5, default)3361 N: total number of points of the buoy (300, default)3362 """3363 fname = 'isolateddanger_buoy1'3364 3365 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3366 3367 # buoy3368 N2 = int(N/2)3369 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3370 bfrac=0.8, N=N2)3371 buoy[0:N2,:] = buoy1v3372 3373 # signs3374 N3 = N - N2 - 23375 3376 bottsigns = 2.*bradii+height3377 lsign = height*hsigns3378 # up3379 N32 = int(N3/2)3380 circle = p_circle(lsign/2., N=N32)3381 trib = circle + [0.,0.]3382 3383 buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+3.2*lsign,0.]3384 3385 # up3386 N323 = N - N32 - N2 - 23387 trid = p_circle(lsign/2., N=N32)3388 trib = circle + [0.,0.]3389 buoy[N2+N32+2:N,:] = trib + [bottsigns+2.*lsign,0.]3390 3391 # painting it3392 Height = np.max(buoy1v[:,0])3393 3394 Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')3395 Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)3396 Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')3397 3398 buoy = ma.masked_equal(buoy, gen.fillValueF)3399 3400 buoysecs = ['buoy', 'sign1', 'sign2', 'third1', 'third2', 'third3']3401 buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \3402 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \3403 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], 'third1': [third1, '-', 'k', 1.], \3404 'third2': [third2, '-', 'r', 1.], 'third3': [third3, '-', 'k', 1.]}3405 3406 return buoy, buoysecs, buoydic3407 3408 def special_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5, N=300):3409 """ Function to draw an special mark buoy using buoy13410 height: height of the prism (5., default)3411 width: width of the prism (10., default)3412 bradii: radii of the ball (1.75, default)3413 bfrac: fraction of the ball above the prism (0.8, default)3414 hisgns: height of the signs [as reg. triangle] as percentage of the height3415 (0.5, default)3416 N: total number of points of the buoy (300, default)3417 """3418 fname = 'special_buoy1'3419 3420 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3421 3422 # buoy3423 N2 = int(N/2)3424 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3425 bfrac=0.8, N=N2)3426 buoy[0:N2,:] = buoy1v3427 3428 Height = np.max(buoy1v[:,0])3429 3430 # sign3431 N3 = N - N2 - 13432 3433 bottsigns = 2.*bradii+height3434 lsign = height*hsigns3435 # up3436 cross, crosssecs, crossdic = p_cross_width(lsign, width=0.3*lsign, Narms=2, N=N3)3437 cross = rotate_polygon_2D(cross, 40.05)3438 buoy[N2+1:N,:] = cross + [Height+1.1*lsign,0.]3439 3440 # painting it3441 buoy = ma.masked_equal(buoy, gen.fillValueF)3442 3443 buoysecs = ['buoy', 'sign']3444 buoydic = {'buoy': [buoy[0:N2,:],'-','#FFFF00',1.5], \3445 'sign': [buoy[N2+1:N,:],'-','#FFFF00',1.5]}3446 3447 return buoy, buoysecs, buoydic3448 3449 def emergency_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5, N=300):3450 """ Function to draw an eergency mark buoy using buoy13451 height: height of the prism (5., default)3452 width: width of the prism (10., default)3453 bradii: radii of the ball (1.75, default)3454 bfrac: fraction of the ball above the prism (0.8, default)3455 hisgns: height of the signs [as reg. triangle] as percentage of the height3456 (0.5, default)3457 N: total number of points of the buoy (300, default)3458 """3459 fname = 'emergency_buoy1'3460 3461 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF3462 3463 # buoy3464 N2 = int(N/2)3465 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \3466 bfrac=0.8, N=N2)3467 buoy[0:N2,:] = buoy1v3468 3469 Height = np.max(buoy1v[:,0])3470 3471 # sign3472 N3 = N - N2 - 13473 3474 bottsigns = 2.*bradii+height3475 lsign = height*hsigns3476 # up3477 cross, crosssecs, crossdic = p_cross_width(lsign, width=0.3*lsign, Narms=2, N=N3)3478 buoy[N2+1:N,:] = cross + [Height+1.1*lsign,0.]3479 3480 # painting it3481 ix = -width/2.3482 Ncut, fifth1 = cut_xpolygon(buoy1v, xval=ix+width/5., keep='left')3483 Ncut, fifth2 = cut_between_xpolygon(buoy1v,xval1=ix+width/5.,xval2=ix+width*2./5.)3484 Ncut, fifth3 = cut_between_xpolygon(buoy1v,xval1=ix+width*2./5.,xval2=ix+width*3./5.)3485 Ncut, fifth4 = cut_between_xpolygon(buoy1v,xval1=ix+width*3./5.,xval2=ix+width*4./5.)3486 Ncut, fifth5 = cut_xpolygon(buoy1v, xval=ix+width*4./5., keep='right')3487 3488 buoy = ma.masked_equal(buoy, gen.fillValueF)3489 3490 buoysecs = ['buoy', 'sign', 'fifth1', 'fifth2', 'fifth3', 'fifth4', 'fifth5']3491 buoydic = {'buoy': [buoy[0:N2,:],'-','#FFFF00',1.5], \3492 'sign': [buoy[N2+1:N,:],'-','#FFFF00',1.5],'fifth1':[fifth1,'-','#FFFF00',1.5],\3493 'fifth2': [fifth2,'-','#0000FF',1.5],'fifth3': [fifth3,'-','#FFFF00',1.5], \3494 'fifth4': [fifth4,'-','#0000FF',1.5],'fifth5': [fifth5,'-','#FFFF00',1.5]}3495 3496 return buoy, buoysecs, buoydic3497 3498 2339 ####### ####### ##### #### ### ## # 3499 2340 # Plotting
Note: See TracChangeset
for help on using the changeset viewer.