Changeset 2630 in lmdz_wrf


Ignore:
Timestamp:
Jun 23, 2019, 11:18:47 PM (5 years ago)
Author:
lfita
Message:

Creation of 'nautic.py' the module with all the natucial staff. Retrieving it from ' geometric_tools.py'

Location:
trunk/tools
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2629 r2630  
    11# Python tools to manage netCDF files.
    2 # L. Fita, CIMA. Mrch 2019
     2# L. Fita, CIMA. March 2019
    33# More information at: http://www.xn--llusfb-5va.cat/python/PyNCplot
    44#
     
    5151
    5252## Shapes/objects
    53 # buoy1: Function to draw a buoy as superposition of prism and section of ball
    54 # band_lighthouse: Function to plot a lighthouse with spiral bands
    5553# circ_sec: Function union of point A and B by a section of a circle
    5654# ellipse_polar: Function to determine an ellipse from its center and polar coordinates
    57 # green_buoy1: Function to draw a green mark buoy using buoy1
    58 # isolateddanger_buoy1: Function to draw an isolated danger buoy using buoy1
    5955# p_angle_triangle: Function to draw a triangle by an initial point and two
    6056#   consecutive angles and the first length of face. The third angle and 2 and 3rd
     
    7066# p_spiral: Function to provide a polygon of an Archimedean spiral
    7167# 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 system
    73 #   [A/B] buoy using buoy1
    74 # prefchannelstarboard[A/B]_buoy1: Function to draw a preferred channel starboard
    75 #   system [A/B] buoy using buoy1
    76 # red_buoy1: Function to draw a red mark buoy using buoy1
    77 # safewater_buoy1: Function to draw a safe water mark buoy using buoy1
    78 # special_buoy1: Function to draw an special mark buoy using buoy1
    7968# 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-plane
    81 # zsailing_boat: Function to define an schematic sailing boat from the z-plane with sails
    82 # zisland1: Function to draw an island from z-axis as the union of a series of points by
    83 #   circular segments
    8469
    8570## Plotting
     
    8772# plot_sphere: Function to plot an sphere and determine which standard lines will be
    8873#   also drawn
    89 # [north/east/south/west_buoy1: Function to draw a [North/East/South/West] danger buoy using buoy1
    9074
    9175def deg_deci(angle):
     
    23532337    return cross, crosssecs, crossdic
    23542338
    2355 # Combined objects
    2356 ##
    2357 
    2358 # FROM: http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html
    2359 def zboat(length=10., beam=1., lbeam=0.4, sternbp=0.5):
    2360     """ Function to define an schematic boat from the z-plane
    2361       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 section
    2375     fportside = circ_sec(maxportside, bow, length*2)
    2376     fstarboardside = circ_sec(bow, maxstarboardside, length*2)
    2377     # aft section
    2378     aportside = circ_sec(portside, maxportside, length*2)
    2379     astarboardside = circ_sec(maxstarboardside, starboardside, length*2)
    2380     # stern
    2381     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,:] = aportside
    2387     boat[dpts:2*dpts,:] = fportside
    2388     boat[2*dpts:3*dpts,:] = fstarboardside
    2389     boat[3*dpts:4*dpts,:] = astarboardside
    2390     boat[4*dpts:5*dpts,:] = stern
    2391 
    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 infmsg
    2396         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 stern
    2409     fcl = 0.15
    2410     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 sections
    2415     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 infmsg
    2430         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, dicboat
    2441 
    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 sails
    2445       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 sections
    2472     sailingboatsecs = ['aportside', 'fportside', 'fstarboardside', 'astarboardside', \
    2473       'stern', 'mast', 'hsail', 'msail', 'centerline']
    2474 
    2475     # forward section
    2476 
    2477     # aft section
    2478     # stern
    2479     # mast
    2480     mast = p_circle(wmast,N=dpts)
    2481     mast = mast + [length*lmast, 0.]
    2482     # head sails
    2483     lsail = lheads*length
    2484     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 - hsail
    2498 
    2499     # main sails
    2500     lsail = lmains*length
    2501     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] - msail
    2516 
    2517     sailingboat = np.zeros((dpts*8+4,2), dtype=np.float)
    2518 
    2519     sailingboat[0:dpts,:] = aportside
    2520     sailingboat[dpts:2*dpts,:] = fportside
    2521     sailingboat[2*dpts:3*dpts,:] = fstarboardside
    2522     sailingboat[3*dpts:4*dpts,:] = astarboardside
    2523     sailingboat[4*dpts:5*dpts,:] = stern
    2524     sailingboat[5*dpts,:] = [gen.fillValueF, gen.fillValueF]
    2525     sailingboat[5*dpts+1:6*dpts+1,:] = mast
    2526     sailingboat[6*dpts+1,:] = [gen.fillValueF, gen.fillValueF]
    2527     sailingboat[6*dpts+2:7*dpts+2,:] = hsail
    2528     sailingboat[7*dpts+2,:] = [gen.fillValueF, gen.fillValueF]
    2529     sailingboat[7*dpts+3:8*dpts+3,:] = msail
    2530     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 stern
    2535     fcl = 0.15
    2536     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 infmsg
    2557         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, dicsailingboat
    2572 
    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 by
    2576         circular segments
    2577       mainpts: main points of the island (clockwise ordered, to be joined by
    2578         circular segments of radii as the radfrac factor of the distance between
    2579         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 to
    2583         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.fillValueF
    2589 
    2590     # Coastline
    2591     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, islanddic
    2599 
    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 ball
    2602       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 = 0
    2614     iip = 0
    2615     # left lateral
    2616     ix = -width/2.
    2617     Np = N3
    2618     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 + Np
    2624     iip = NNp
    2625 
    2626     # left upper
    2627     ix = -width/2.
    2628     iy = height
    2629     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 + Np
    2634     iip = NNp
    2635 
    2636     # ball
    2637     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 + Np
    2642     iip = NNp
    2643 
    2644     # right upper
    2645     ix = bradii*bfrac
    2646     iy = height
    2647     Np = N3
    2648     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 + Np
    2653     iip = NNp
    2654 
    2655     # right lateral
    2656     ix = width/2.
    2657     iy = height
    2658     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 + Np
    2663     iip = NNp
    2664 
    2665     # Base
    2666     ix = width/2.
    2667     iy = 0.
    2668     Np = N - int(2*N/3) - 4*N3 - 1
    2669     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 + Np
    2674     iip = NNp
    2675 
    2676     buoy[N-1,:] = buoy[0,:]
    2677 
    2678     buoysecs = ['base']
    2679     buoydic = {'base': [buoy, '-', 'k', 1.5]}
    2680 
    2681     return buoy, buoysecs, buoydic
    2682 
    2683 def band_lighthouse(height=10., width=2., hlight=3., bands=3, N=300):
    2684     """ Function to plot a lighthouse with spiral bands
    2685       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.fillValueF
    2694     lighthousesecs = []
    2695     lighthousedic = {}
    2696 
    2697     # base Tower
    2698     Nsec = int(0.30*N/7)
    2699     p1=np.array([0., width/2.])
    2700     p2=np.array([0., -width/2.])
    2701     iip = 0
    2702     lighthouse[0:Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec)
    2703     iip = iip + Nsec
    2704 
    2705     # left side
    2706     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 + Nsec
    2713 
    2714     # Top Tower
    2715     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 + Nsec
    2719 
    2720     # right side
    2721     ix=width/2.
    2722     iy=height
    2723     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 + 1
    2728 
    2729     Ntower = iip-1
    2730     lighthousesecs.append('tower')
    2731     lighthousedic['tower'] = [lighthouse[0:iip-1], '-', 'k', 1.5]
    2732 
    2733     # Left light
    2734     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 + Nsec
    2738    
    2739     # Top Light
    2740     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 + 1
    2744 
    2745     # Right light
    2746     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 + Nsec
    2750 
    2751     # Base Light
    2752     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 + 1
    2756     lighthousesecs.append('light')
    2757     lighthousedic['light'] = [lighthouse[Ntower+1:iip-1], '-', '#EEEE00', 1.5]
    2758 
    2759     # Spiral bands
    2760     hb = height/(2.*bands)
    2761     Nsec2 = (N - Nsec*8 - 3)/bands
    2762     for ib in range(bands-1):
    2763         iband = iip
    2764         Nsec = Nsec2/4
    2765         bandS = 'band' + str(ib).zfill(2)
    2766         # hband
    2767         ix = -width/2.
    2768         iy = hb*ib*2
    2769         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 + Nsec
    2774         # uband
    2775         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 + Nsec
    2779         # dband
    2780         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 + Nsec
    2787         # dband
    2788         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 + 1
    2792         lighthousesecs.append(bandS)
    2793         lighthousedic[bandS] = [lighthouse[iband:iip-1], '-', '#6408AA', 2.]
    2794 
    2795     ib = bands-1
    2796     Nsec3 = (N - iip - 1)
    2797     Nsec = int(Nsec3/4)
    2798     bandS = 'band' + str(ib).zfill(2)
    2799     # hband
    2800     iband = iip
    2801     ix = -width/2.
    2802     iy = hb*ib*2
    2803     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 + Nsec
    2808     # uband
    2809     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 + Nsec
    2813     # dband
    2814     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 + Nsec
    2821     # dband
    2822     Nsec = N - iip
    2823     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, lighthousedic
    2832 
    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 buoy1
    2835       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 height
    2840         (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.fillValueF
    2846 
    2847     # buoy
    2848     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,:] = buoy1v
    2852 
    2853     # signs
    2854     N3 = N - N2 - 2
    2855    
    2856     bottsigns = 2.*bradii+height
    2857     lsign = height*hsigns
    2858     # up
    2859     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     # up
    2866     N323 = N - N32 - N2 - 2
    2867     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 it
    2872     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, buoydic
    2886 
    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 buoy1
    2889       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 height
    2894         (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.fillValueF
    2900 
    2901     # buoy
    2902     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,:] = buoy1v
    2905 
    2906     # signs
    2907     N3 = N - N2 - 2
    2908    
    2909     bottsigns = 2.*bradii+height
    2910     lsign = height*hsigns
    2911     # up
    2912     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     # down
    2919     N323 = N - N32 - N2 - 2
    2920 
    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 it
    2927     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, buoydic
    2943 
    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 buoy1
    2946       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 height
    2951         (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.fillValueF
    2957 
    2958     # buoy
    2959     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,:] = buoy1v
    2962 
    2963     # signs
    2964     N3 = N - N2 - 2
    2965    
    2966     bottsigns = 2.*bradii+height
    2967     lsign = height*hsigns
    2968     # up
    2969     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     # down
    2977     N323 = N - N32 - N2 - 2
    2978     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 it
    2984     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, buoydic
    2998 
    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 buoy1
    3001       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 height
    3006         (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.fillValueF
    3012 
    3013     # buoy
    3014     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,:] = buoy1v
    3017 
    3018     # signs
    3019     N3 = N - N2 - 2
    3020    
    3021     bottsigns = 2.*bradii+height
    3022     lsign = height*hsigns
    3023 
    3024     # down
    3025     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     # up
    3032     N323 = N - N32 - N2 - 2
    3033     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 it
    3039     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, buoydic
    3055 
    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 buoy1
    3058       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 height
    3063         (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.fillValueF
    3069 
    3070     # buoy
    3071     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,:] = buoy1v
    3075 
    3076     # signs
    3077     N3 = N - N2 - 1
    3078     lsign = height*hsigns
    3079    
    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 it
    3085     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, buoydic
    3100 
    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 buoy1
    3103       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 height
    3108         (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.fillValueF
    3114 
    3115     # buoy
    3116     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,:] = buoy1v
    3120 
    3121     # signs
    3122     N3 = N - N2 - 1
    3123     lsign = height*hsigns*2.
    3124    
    3125     Height = np.max(buoy1v[:,0])
    3126     triu = p_angle_triangle(N=N3)
    3127     sign = triu*lsign
    3128     buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.]
    3129 
    3130     # painting it
    3131     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, buoydic
    3138 
    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 buoy1
    3141       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 height
    3146         (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.fillValueF
    3152 
    3153     # buoy
    3154     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,:] = buoy1v
    3158 
    3159     # signs
    3160     N3 = N - N2 - 1
    3161     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 it
    3168     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, buoydic
    3175 
    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 buoy1
    3179       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 height
    3184         (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.fillValueF
    3190 
    3191     # buoy
    3192     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,:] = buoy1v
    3196 
    3197     # signs
    3198     N3 = N - N2 - 1
    3199     lsign = height*hsigns*2.
    3200    
    3201     Height = np.max(buoy1v[:,0])
    3202     triu = p_angle_triangle(N=N3)
    3203     sign = triu*lsign
    3204     buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.]
    3205 
    3206     # painting it
    3207     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, buoydic
    3219 
    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 buoy1
    3223       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 height
    3228         (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.fillValueF
    3234 
    3235     # buoy
    3236     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,:] = buoy1v
    3240 
    3241     # signs
    3242     N3 = N - N2 - 1
    3243     lsign = height*hsigns*2.
    3244    
    3245     Height = np.max(buoy1v[:,0])
    3246     triu = p_angle_triangle(N=N3)
    3247     sign = triu*lsign
    3248     buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.]
    3249 
    3250     # painting it
    3251     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, buoydic
    3263 
    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 buoy1
    3267       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 height
    3272         (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.fillValueF
    3278 
    3279     # buoy
    3280     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,:] = buoy1v
    3284 
    3285     # signs
    3286     N3 = N - N2 - 1
    3287     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 it
    3294     # painting it
    3295     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, buoydic
    3307 
    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 buoy1
    3311       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 height
    3316         (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.fillValueF
    3322 
    3323     # buoy
    3324     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,:] = buoy1v
    3328 
    3329     # signs
    3330     N3 = N - N2 - 1
    3331     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 it
    3338     # painting it
    3339     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, buoydic
    3351 
    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 buoy1
    3355       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 height
    3360         (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.fillValueF
    3366 
    3367     # buoy
    3368     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,:] = buoy1v
    3372 
    3373     # signs
    3374     N3 = N - N2 - 2
    3375    
    3376     bottsigns = 2.*bradii+height
    3377     lsign = height*hsigns
    3378     # up
    3379     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     # up
    3386     N323 = N - N32 - N2 - 2
    3387     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 it
    3392     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, buoydic
    3407 
    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 buoy1
    3410       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 height
    3415         (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.fillValueF
    3421 
    3422     # buoy
    3423     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,:] = buoy1v
    3427 
    3428     Height = np.max(buoy1v[:,0])
    3429 
    3430     # sign
    3431     N3 = N - N2 - 1
    3432    
    3433     bottsigns = 2.*bradii+height
    3434     lsign = height*hsigns
    3435     # up
    3436     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 it
    3441     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, buoydic
    3448 
    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 buoy1
    3451       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 height
    3456         (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.fillValueF
    3462 
    3463     # buoy
    3464     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,:] = buoy1v
    3468 
    3469     Height = np.max(buoy1v[:,0])
    3470 
    3471     # sign
    3472     N3 = N - N2 - 1
    3473    
    3474     bottsigns = 2.*bradii+height
    3475     lsign = height*hsigns
    3476     # up
    3477     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 it
    3481     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, buoydic
    3497 
    34982339####### ####### ##### #### ### ## #
    34992340# Plotting
Note: See TracChangeset for help on using the changeset viewer.