[2630] | 1 | ## Python sript to generate nautical content |
---|
| 2 | # L. Fita, CIMA. June 2019 |
---|
| 3 | # More information at: http://www.xn--llusfb-5va.cat/python/PyNCplot |
---|
| 4 | # |
---|
| 5 | # pyNCplot and its component geometry_tools.py comes with ABSOLUTELY NO WARRANTY. |
---|
| 6 | # This work is licendes under a Creative Commons |
---|
| 7 | # Attribution-ShareAlike 4.0 International License (http://creativecommons.org/licenses/by-sa/4.0) |
---|
| 8 | # |
---|
[2650] | 9 | import os |
---|
[2630] | 10 | import generic_tools as gen |
---|
[2632] | 11 | import geometry_tools as geo |
---|
[2633] | 12 | import numpy as np |
---|
[2630] | 13 | import numpy.ma as ma |
---|
| 14 | import module_ForSci as fsci |
---|
| 15 | |
---|
| 16 | errormsg = 'ERROR -- error -- ERROR -- error' |
---|
| 17 | infmsg = 'INFORMATION -- information -- INFORMATION -- information' |
---|
| 18 | |
---|
| 19 | ## Shapes/objects |
---|
[2646] | 20 | # boatnames: Function to provide the names of the sections of a boat |
---|
[2630] | 21 | # buoy1: Function to draw a buoy as superposition of prism and section of ball |
---|
| 22 | # band_lighthouse: Function to plot a lighthouse with spiral bands |
---|
[2636] | 23 | # EstuarioRioPlata: Function to plot an eschematic representation of the Estuario of Rio de la Plata |
---|
[2630] | 24 | # green_buoy1: Function to draw a green mark buoy using buoy1 |
---|
| 25 | # isolateddanger_buoy1: Function to draw an isolated danger buoy using buoy1 |
---|
| 26 | # prefchannelport[A/B]_buoy1: Function to draw a preferred channel port system |
---|
| 27 | # [A/B] buoy using buoy1 |
---|
| 28 | # prefchannelstarboard[A/B]_buoy1: Function to draw a preferred channel starboard |
---|
| 29 | # system [A/B] buoy using buoy1 |
---|
| 30 | # red_buoy1: Function to draw a red mark buoy using buoy1 |
---|
| 31 | # safewater_buoy1: Function to draw a safe water mark buoy using buoy1 |
---|
| 32 | # special_buoy1: Function to draw an special mark buoy using buoy1 |
---|
[2645] | 33 | # yboat: Function to define an schematic boat from the y-plane |
---|
[2630] | 34 | # z_boat: Function to define an schematic boat from the z-plane |
---|
| 35 | # zsailing_boat: Function to define an schematic sailing boat from the z-plane with sails |
---|
| 36 | # zisland1: Function to draw an island from z-axis as the union of a series of points by |
---|
| 37 | # circular segments |
---|
| 38 | # [north/east/south/west_buoy1: Function to draw a [North/East/South/West] danger buoy using buoy1 |
---|
| 39 | |
---|
[2636] | 40 | # Definitions [Name, lat, lon] |
---|
[2638] | 41 | NotablePoints = { \ |
---|
[2637] | 42 | 'ArroyoRosario': ['Arroyo Rosario', np.array([-34.4331, -57.3504])], \ |
---|
| 43 | 'BsAs': ['Buenos Aires', np.array([-34.6097, -58.4494])], \ |
---|
[2644] | 44 | 'BaSamborombom': ['Bah' + unichr(237) + 'a Samboromb' + unichr(243) + 'm', \ |
---|
| 45 | np.array([-36.0, -57.])], \ |
---|
[2637] | 46 | 'CaboPolonio': ['Cabo Polonio', np.array([-34.4083, -53.7782])], \ |
---|
| 47 | 'Colonia': ['Colonia del Sacramento', np.array([-34.4724, -57.8556])], \ |
---|
| 48 | 'MartinChico': ['Martin Chico', np.array([-34.1681, -58.2118])], \ |
---|
| 49 | 'Montevideo': ['Montevideo', np.array([-34.9216, -56.1574])], \ |
---|
| 50 | 'PuntaAtalaya': ['Punta Atalaya', np.array([-35.01868, -57.5181])], \ |
---|
| 51 | 'PuntaEste': ['Punta del Este', np.array([-34.9830, -54.9533])], \ |
---|
[2638] | 52 | 'PuntaIndio': ['Punta Indio', np.array([-35.4179, -57.0959])], \ |
---|
[2636] | 53 | 'PuntaMedanos': ['Punta Medanos', np.array([-36.8494, -56.6395])], \ |
---|
| 54 | 'PuntaRaza': ['Punta Raza', np.array([-36.2929, -56.7474])], \ |
---|
| 55 | 'RioSalado': ['Rio Salado', np.array([-35.7423, -57.3635])], \ |
---|
| 56 | 'Tigre': ['Tigre', np.array([-34.4486, -58.4989])], \ |
---|
[2637] | 57 | } |
---|
[2636] | 58 | |
---|
[2630] | 59 | # FROM: http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html |
---|
[2647] | 60 | def yboat(length=10., fcab=0.3, hcab=0.5, flength=0.7, freeboard=2., hskeg=2., \ |
---|
| 61 | fskeg=0.2, N=200): |
---|
[2645] | 62 | """ Function to define an schematic boat from the y-plane |
---|
| 63 | length: length of the boat (without stern, default, 10) |
---|
[2647] | 64 | fcab: length of the cabin as percentage of length (default, 0.3) |
---|
| 65 | hcab: height of the cabin (default, 0.5) |
---|
[2645] | 66 | flength: floating length of the boat as percentage of length (defatult, 0.7) |
---|
| 67 | freeboard: height above the water (default, 2) |
---|
| 68 | hskeg: height of the skeg (default, 2) |
---|
| 69 | fskeg: length of the skeg as percentage of length (default, 0.2) |
---|
| 70 | N: number of points to use (default, 200) |
---|
| 71 | """ |
---|
| 72 | fname = 'yboat' |
---|
| 73 | |
---|
| 74 | lflength = length*flength |
---|
| 75 | ilf3 = length*(1.-flength)/3 |
---|
[2647] | 76 | lcab = length*fcab |
---|
| 77 | ilcab3 = length*(1.-fcab)/4. |
---|
[2645] | 78 | |
---|
| 79 | bow = np.array([length, freeboard]) |
---|
| 80 | hbow = np.array([lflength + ilf3, 0.]) |
---|
[2647] | 81 | icab = np.array([ilcab3, freeboard]) |
---|
| 82 | ihcab = np.array([ilcab3, freeboard+hcab]) |
---|
| 83 | ecab = np.array([ilcab3+lcab, freeboard]) |
---|
[2645] | 84 | sternp = np.array([0., freeboard]) |
---|
| 85 | sternlp = np.array([0., freeboard*0.8]) |
---|
| 86 | |
---|
[2647] | 87 | print 'hbow', hbow, 'bow', bow, 'icab', icab, 'ihcab', ihcab, 'ecab', ecab, 'sternp', sternp, 'sternlp', sternlp |
---|
| 88 | |
---|
[2645] | 89 | boat = np.zeros((N,2), dtype=np.float) |
---|
| 90 | N1 = int(N*0.8) |
---|
| 91 | N2 = N - N1 - 1 |
---|
| 92 | |
---|
| 93 | # stern |
---|
| 94 | N14 = N1/4 |
---|
| 95 | stern = np.zeros((N14,2), dtype=np.float) |
---|
[2647] | 96 | ipt = sternlp |
---|
| 97 | ept = sternp |
---|
[2645] | 98 | dy = (ept[0] - ipt[0])/(N14-1) |
---|
| 99 | dz = (ept[1] - ipt[1])/(N14-1) |
---|
| 100 | for ip in range(N14): |
---|
| 101 | stern[ip,:] = ipt + [dy*ip, dz*ip] |
---|
| 102 | |
---|
| 103 | # deck |
---|
| 104 | deck = np.zeros((N14,2), dtype=np.float) |
---|
[2647] | 105 | N144 = int(N14/4.) |
---|
| 106 | |
---|
| 107 | ipt = sternp |
---|
| 108 | ept = icab |
---|
| 109 | dy = (ept[0] - ipt[0])/(N144-1) |
---|
| 110 | dz = (ept[1] - ipt[1])/(N144-1) |
---|
| 111 | for ip in range(N144): |
---|
[2645] | 112 | deck[ip,:] = ipt + [dy*ip, dz*ip] |
---|
[2647] | 113 | ipt = icab |
---|
| 114 | ept = ihcab |
---|
| 115 | dy = (ept[0] - ipt[0])/(N144-1) |
---|
| 116 | dz = (ept[1] - ipt[1])/(N144-1) |
---|
| 117 | for ip in range(N144): |
---|
| 118 | deck[N144:2*N144,:] = ipt + [dy*ip, dz*ip] |
---|
| 119 | deck[2*N144:3*N144,:] = geo.circ_sec(ihcab, ecab, 2*lcab, arc='short', \ |
---|
| 120 | pos='right', Nang=N144) |
---|
| 121 | N1442 = N14 - 3*N144 |
---|
| 122 | ipt = ecab |
---|
| 123 | ept = bow |
---|
| 124 | dy = (ept[0] - ipt[0])/(N144-1) |
---|
| 125 | dz = (ept[1] - ipt[1])/(N144-1) |
---|
| 126 | for ip in range(N144): |
---|
| 127 | deck[3*N144:N14,:] = ipt + [dy*ip, dz*ip] |
---|
[2645] | 128 | |
---|
| 129 | # sternl |
---|
| 130 | sternl = np.zeros((N14,2), dtype=np.float) |
---|
[2647] | 131 | ipt = bow |
---|
| 132 | ept = hbow |
---|
[2645] | 133 | dy = (ept[0] - ipt[0])/(N14-1) |
---|
| 134 | dz = (ept[1] - ipt[1])/(N14-1) |
---|
| 135 | for ip in range(N14): |
---|
| 136 | sternl[ip,:] = ipt + [dy*ip, dz*ip] |
---|
| 137 | |
---|
| 138 | # keel |
---|
| 139 | N12 = N1 - 3*N14 |
---|
[2647] | 140 | keel = geo.circ_sec(hbow, sternlp, length, arc='short', pos='right', Nang=N12) |
---|
[2645] | 141 | |
---|
| 142 | # skeg |
---|
| 143 | lskeg = length*fskeg |
---|
| 144 | ilk3 = length*(1.-fskeg)/3 |
---|
| 145 | iuskeg = np.array([1.5*ilk3, 0.]) |
---|
| 146 | euskeg = np.array([1.5*ilk3+lskeg, 0.]) |
---|
| 147 | edskeg = np.array([1.5*ilk3+lskeg*0.8, -hskeg]) |
---|
| 148 | idskeg = np.array([1.5*ilk3+lskeg*0.3, -hskeg]) |
---|
| 149 | |
---|
| 150 | skeg = np.zeros((N2,2), dtype=np.float) |
---|
| 151 | N24=N2/4 |
---|
| 152 | |
---|
| 153 | # upper skeg |
---|
| 154 | uskeg = np.zeros((N24,2), dtype=np.float) |
---|
| 155 | ipt = iuskeg |
---|
| 156 | ept = euskeg |
---|
| 157 | dy = (ept[0] - ipt[0])/(N24-1) |
---|
| 158 | dz = (ept[1] - ipt[1])/(N24-1) |
---|
| 159 | for ip in range(N24): |
---|
| 160 | uskeg[ip,:] = ipt + [dy*ip, dz*ip] |
---|
| 161 | |
---|
| 162 | # aft skeg |
---|
| 163 | askeg = np.zeros((N24,2), dtype=np.float) |
---|
| 164 | ipt = euskeg |
---|
| 165 | ept = edskeg |
---|
| 166 | dy = (ept[0] - ipt[0])/(N24-1) |
---|
| 167 | dz = (ept[1] - ipt[1])/(N24-1) |
---|
| 168 | for ip in range(N24): |
---|
| 169 | askeg[ip,:] = ipt + [dy*ip, dz*ip] |
---|
| 170 | |
---|
| 171 | # down skeg |
---|
| 172 | dskeg = np.zeros((N24,2), dtype=np.float) |
---|
| 173 | ipt = edskeg |
---|
| 174 | ept = idskeg |
---|
| 175 | dy = (ept[0] - ipt[0])/(N24-1) |
---|
| 176 | dz = (ept[1] - ipt[1])/(N24-1) |
---|
| 177 | for ip in range(N24): |
---|
| 178 | dskeg[ip,:] = ipt + [dy*ip, dz*ip] |
---|
| 179 | |
---|
| 180 | # stern skeg |
---|
| 181 | N22 = N2 - 3*N24 |
---|
| 182 | sskeg = np.zeros((N22,2), dtype=np.float) |
---|
| 183 | ipt = idskeg |
---|
| 184 | ept = iuskeg |
---|
| 185 | dy = (ept[0] - ipt[0])/(N22-1) |
---|
| 186 | dz = (ept[1] - ipt[1])/(N22-1) |
---|
| 187 | for ip in range(N22): |
---|
| 188 | sskeg[ip,:] = ipt + [dy*ip, dz*ip] |
---|
| 189 | |
---|
| 190 | boat[0:N14,:] = stern |
---|
| 191 | boat[N14:2*N14,:] = deck |
---|
| 192 | boat[2*N14:3*N14,:] = sternl |
---|
| 193 | boat[3*N14:4*N12,:] = keel |
---|
| 194 | boat[N1,:] = np.array([gen.fillValueF, gen.fillValueF]) |
---|
| 195 | boat[N1+1:N1+1+N24,:] = uskeg |
---|
| 196 | boat[N1+1+N24:N1+1+2*N24,:] = askeg |
---|
| 197 | boat[N1+1+2*N24:N1+1+3*N24,:] = dskeg |
---|
| 198 | boat[N1+1+3*N24:N,:] = sskeg |
---|
| 199 | |
---|
| 200 | # correct order of sections |
---|
| 201 | boatsecs = ['stern', 'deck', 'sternl', 'keel', 'uskeg', 'askeg', 'dskeg', 'sskeg'] |
---|
| 202 | |
---|
| 203 | # dictionary with sections [polygon_vertices, line_type, line_color, line_width] |
---|
| 204 | dicboat = {'stern': [stern, '-', '#8A5900', 2.], \ |
---|
| 205 | 'deck': [deck, '-', '#8A5900', 2.], \ |
---|
| 206 | 'sternl': [sternl, '-', '#8A5900', 2.], \ |
---|
| 207 | 'keel': [keel, '-', '#8A5900', 2.], \ |
---|
| 208 | 'uskeg': [uskeg, '-', '#000000', 1.5], 'askeg': [askeg, '-.', '#000000', 1.5], \ |
---|
| 209 | 'dskeg': [dskeg, '-', '#000000', 1.5], 'sskeg': [sskeg, '-.', '#000000', 1.5]} |
---|
| 210 | |
---|
| 211 | boat = ma.masked_equal(boat, gen.fillValueF) |
---|
| 212 | |
---|
| 213 | return boat, boatsecs, dicboat |
---|
| 214 | |
---|
[2630] | 215 | def zboat(length=10., beam=1., lbeam=0.4, sternbp=0.5): |
---|
| 216 | """ Function to define an schematic boat from the z-plane |
---|
| 217 | length: length of the boat (without stern, default 10) |
---|
| 218 | beam: beam of the boat (default 1) |
---|
| 219 | lbeam: length at beam (as percentage of length, default 0.4) |
---|
| 220 | sternbp: beam at stern (as percentage of beam, default 0.5) |
---|
| 221 | """ |
---|
| 222 | fname = 'zboat' |
---|
| 223 | |
---|
| 224 | bow = np.array([length, 0.]) |
---|
| 225 | maxportside = np.array([length*lbeam, -beam]) |
---|
| 226 | maxstarboardside = np.array([length*lbeam, beam]) |
---|
| 227 | portside = np.array([0., -beam*sternbp]) |
---|
| 228 | starboardside = np.array([0., beam*sternbp]) |
---|
| 229 | |
---|
| 230 | # forward section |
---|
| 231 | fportside = geo.circ_sec(maxportside, bow, length*2) |
---|
| 232 | fstarboardside = geo.circ_sec(bow, maxstarboardside, length*2) |
---|
| 233 | # aft section |
---|
| 234 | aportside = geo.circ_sec(portside, maxportside, length*2) |
---|
| 235 | astarboardside = geo.circ_sec(maxstarboardside, starboardside, length*2) |
---|
| 236 | # stern |
---|
| 237 | stern = geo.circ_sec(starboardside, portside, length*2) |
---|
| 238 | |
---|
| 239 | dpts = stern.shape[0] |
---|
| 240 | boat = np.zeros((dpts*5,2), dtype=np.float) |
---|
| 241 | |
---|
| 242 | boat[0:dpts,:] = aportside |
---|
| 243 | boat[dpts:2*dpts,:] = fportside |
---|
| 244 | boat[2*dpts:3*dpts,:] = fstarboardside |
---|
| 245 | boat[3*dpts:4*dpts,:] = astarboardside |
---|
| 246 | boat[4*dpts:5*dpts,:] = stern |
---|
| 247 | |
---|
| 248 | fname = 'boat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) + '_lb' + \ |
---|
| 249 | str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) + '.dat' |
---|
| 250 | if not os.path.isfile(fname): |
---|
| 251 | print infmsg |
---|
| 252 | print ' ' + fname + ": writting boat coordinates file '" + fname + "' !!" |
---|
| 253 | of = open(fname, 'w') |
---|
| 254 | of.write('# boat file with Length: ' + str(length) +' max_beam: '+str(beam)+ \ |
---|
| 255 | 'length_at_max_beam:' + str(lbeam) + '% beam at stern: ' + str(sternbp)+ \ |
---|
| 256 | ' %\n') |
---|
| 257 | for ip in range(dpts*5): |
---|
| 258 | of.write(str(boat[ip,0]) + ' ' + str(boat[ip,1]) + '\n') |
---|
| 259 | |
---|
| 260 | of.close() |
---|
| 261 | print fname + ": Successfull written '" + fname + "' !!" |
---|
| 262 | |
---|
| 263 | |
---|
| 264 | # Center line extending [fcl] percentage from length on aft and stern |
---|
| 265 | fcl = 0.15 |
---|
| 266 | centerline = np.zeros((dpts,2), dtype=np.float) |
---|
| 267 | dl = length*(1.+fcl*2.)/(dpts-1) |
---|
| 268 | centerline[:,0] = np.arange(-length*fcl, length*(1. + fcl)+dl, dl) |
---|
| 269 | |
---|
| 270 | # correct order of sections |
---|
| 271 | boatsecs = ['aportside', 'fportside', 'fstarboardside', 'astarboardside', \ |
---|
| 272 | 'stern', 'centerline'] |
---|
| 273 | |
---|
| 274 | # dictionary with sections [polygon_vertices, line_type, line_color, line_width] |
---|
| 275 | dicboat = {'fportside': [fportside, '-', '#8A5900', 2.], \ |
---|
| 276 | 'aportside': [aportside, '-', '#8A5900', 2.], \ |
---|
| 277 | 'stern': [stern, '-', '#8A5900', 2.], \ |
---|
| 278 | 'astarboardside': [astarboardside, '-', '#8A5900', 2.], \ |
---|
| 279 | 'fstarboardside': [fstarboardside, '-', '#8A5900', 2.], \ |
---|
| 280 | 'centerline': [centerline, '-.', '#AA6464', 1.5]} |
---|
| 281 | |
---|
| 282 | fname = 'sailboat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) + \ |
---|
| 283 | '_lb' + str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) +'.dat' |
---|
| 284 | if not os.path.isfile(fname): |
---|
| 285 | print infmsg |
---|
| 286 | print ' ' + fname + ": writting boat coordinates file '" + fname + "' !!" |
---|
| 287 | of = open(fname, 'w') |
---|
| 288 | of.write('# boat file with Length: ' + str(length) +' max_beam: '+str(beam)+ \ |
---|
| 289 | 'length_at_max_beam:' + str(lbeam) + '% beam at stern: ' +str(sternbp)+'\n') |
---|
| 290 | for ip in range(dpts*5): |
---|
| 291 | of.write(str(boat[ip,0]) + ' ' + str(boat[ip,1]) + '\n') |
---|
| 292 | |
---|
| 293 | of.close() |
---|
| 294 | print fname + ": Successfull written '" + fname + "' !!" |
---|
| 295 | |
---|
| 296 | return boat, boatsecs, dicboat |
---|
| 297 | |
---|
| 298 | def zsailing_boat(length=10., beam=1., lbeam=0.4, sternbp=0.5, lmast=0.6, wmast=0.1, \ |
---|
| 299 | hsd=5., msd=5., lheads=0.38, lmains=0.55): |
---|
| 300 | """ Function to define an schematic sailing boat from the z-plane with sails |
---|
| 301 | length: length of the boat (without stern, default 10) |
---|
| 302 | beam: beam of the boat (default 1) |
---|
| 303 | lbeam: length at beam (as percentage of length, default 0.4) |
---|
| 304 | sternbp: beam at stern (as percentage of beam, default 0.5) |
---|
| 305 | lmast: position of the mast (as percentage of length, default 0.6) |
---|
| 306 | wmast: width of the mast (default 0.1) |
---|
| 307 | hsd: head sail direction respect to center line (default 5., -999.99 for upwind) |
---|
| 308 | msd: main sail direction respect to center line (default 5., -999.99 for upwind) |
---|
| 309 | lheads: length of head sail (as percentage of legnth, defaul 0.38) |
---|
| 310 | lmains: length of main sail (as percentage of legnth, defaul 0.55) |
---|
| 311 | """ |
---|
| 312 | fname = 'zsailing_boat' |
---|
| 313 | |
---|
| 314 | bow = np.array([length, 0.]) |
---|
| 315 | maxportside = np.array([length*lbeam, -beam]) |
---|
| 316 | maxstarboardside = np.array([length*lbeam, beam]) |
---|
| 317 | portside = np.array([0., -beam*sternbp]) |
---|
| 318 | starboardside = np.array([0., beam*sternbp]) |
---|
| 319 | |
---|
| 320 | aportside = geo.circ_sec(portside, maxportside, length*2) |
---|
| 321 | fportside = geo.circ_sec(maxportside, bow, length*2) |
---|
| 322 | fstarboardside = geo.circ_sec(bow, maxstarboardside, length*2) |
---|
| 323 | astarboardside = geo.circ_sec(maxstarboardside, starboardside, length*2) |
---|
| 324 | stern = geo.circ_sec(starboardside, portside, length*2) |
---|
| 325 | dpts = fportside.shape[0] |
---|
| 326 | |
---|
| 327 | # correct order of sections |
---|
| 328 | sailingboatsecs = ['aportside', 'fportside', 'fstarboardside', 'astarboardside', \ |
---|
| 329 | 'stern', 'mast', 'hsail', 'msail', 'centerline'] |
---|
| 330 | |
---|
| 331 | # forward section |
---|
| 332 | |
---|
| 333 | # aft section |
---|
| 334 | # stern |
---|
| 335 | # mast |
---|
| 336 | mast = geo.p_circle(wmast,N=dpts) |
---|
| 337 | mast = mast + [length*lmast, 0.] |
---|
| 338 | # head sails |
---|
| 339 | lsail = lheads*length |
---|
| 340 | if hsd != -999.99: |
---|
| 341 | sailsa = np.pi/2. - np.pi*hsd/180. |
---|
| 342 | endsail = np.array([lsail*np.sin(sailsa), lsail*np.cos(sailsa)]) |
---|
| 343 | endsail[0] = length - endsail[0] |
---|
| 344 | if bow[1] > endsail[1]: |
---|
| 345 | hsail = geo.circ_sec(endsail, bow, lsail*2.15) |
---|
| 346 | else: |
---|
| 347 | hsail = geo.circ_sec(bow, endsail, lsail*2.15) |
---|
| 348 | else: |
---|
[2651] | 349 | hsail0, sailsec, saildic = geo.p_sinusiode(length=lsail, amp=0.2, lamb=0.75, N=dpts) |
---|
[2630] | 350 | hsail = np.zeros((dpts,2), dtype=np.float) |
---|
| 351 | hsail[:,0] = hsail0[:,1] |
---|
| 352 | hsail[:,1] = hsail0[:,0] |
---|
| 353 | hsail = bow - hsail |
---|
| 354 | |
---|
| 355 | # main sails |
---|
| 356 | lsail = lmains*length |
---|
| 357 | if msd != -999.99: |
---|
| 358 | sailsa = np.pi/2. - np.pi*msd/180. |
---|
| 359 | begsail = np.array([length*lmast, 0.]) |
---|
| 360 | endsail = np.array([lsail*np.sin(sailsa), lsail*np.cos(sailsa)]) |
---|
| 361 | endsail[0] = length*lmast - endsail[0] |
---|
| 362 | if endsail[1] > begsail[1]: |
---|
| 363 | msail = geo.circ_sec(begsail, endsail, lsail*2.15) |
---|
| 364 | else: |
---|
| 365 | msail = geo.circ_sec(endsail, begsail, lsail*2.15) |
---|
| 366 | else: |
---|
[2651] | 367 | msail0, sailsec, saildic = geo.p_sinusiode(length=lsail, amp=0.25, lamb=1., N=dpts) |
---|
[2630] | 368 | msail = np.zeros((dpts,2), dtype=np.float) |
---|
| 369 | msail[:,0] = msail0[:,1] |
---|
| 370 | msail[:,1] = msail0[:,0] |
---|
| 371 | msail = [length*lmast,0] - msail |
---|
| 372 | |
---|
| 373 | sailingboat = np.zeros((dpts*8+4,2), dtype=np.float) |
---|
| 374 | |
---|
| 375 | sailingboat[0:dpts,:] = aportside |
---|
| 376 | sailingboat[dpts:2*dpts,:] = fportside |
---|
| 377 | sailingboat[2*dpts:3*dpts,:] = fstarboardside |
---|
| 378 | sailingboat[3*dpts:4*dpts,:] = astarboardside |
---|
| 379 | sailingboat[4*dpts:5*dpts,:] = stern |
---|
| 380 | sailingboat[5*dpts,:] = [gen.fillValueF, gen.fillValueF] |
---|
| 381 | sailingboat[5*dpts+1:6*dpts+1,:] = mast |
---|
| 382 | sailingboat[6*dpts+1,:] = [gen.fillValueF, gen.fillValueF] |
---|
| 383 | sailingboat[6*dpts+2:7*dpts+2,:] = hsail |
---|
| 384 | sailingboat[7*dpts+2,:] = [gen.fillValueF, gen.fillValueF] |
---|
| 385 | sailingboat[7*dpts+3:8*dpts+3,:] = msail |
---|
| 386 | sailingboat[8*dpts+3,:] = [gen.fillValueF, gen.fillValueF] |
---|
| 387 | |
---|
| 388 | sailingboat = ma.masked_equal(sailingboat, gen.fillValueF) |
---|
| 389 | |
---|
| 390 | # Center line extending [fcl] percentage from length on aft and stern |
---|
| 391 | fcl = 0.15 |
---|
| 392 | centerline = np.zeros((dpts,2), dtype=np.float) |
---|
| 393 | dl = length*(1.+fcl*2.)/(dpts-1) |
---|
| 394 | centerline[:,0] = np.arange(-length*fcl, length*(1. + fcl)+dl, dl) |
---|
| 395 | |
---|
| 396 | # dictionary with sections [polygon_vertices, line_type, line_color, line_width] |
---|
| 397 | dicsailingboat = {'fportside': [fportside, '-', '#8A5900', 2.], \ |
---|
| 398 | 'aportside': [aportside, '-', '#8A5900', 2.], \ |
---|
| 399 | 'stern': [stern, '-', '#8A5900', 2.], \ |
---|
| 400 | 'astarboardside': [astarboardside, '-', '#8A5900', 2.], \ |
---|
| 401 | 'fstarboardside': [fstarboardside, '-', '#8A5900', 2.], \ |
---|
| 402 | 'mast': [mast, '-', '#8A5900', 2.], 'hsail': [hsail, '-', '#AAAAAA', 1.], \ |
---|
| 403 | 'msail': [msail, '-', '#AAAAAA', 1.], \ |
---|
| 404 | 'centerline': [centerline, '-.', '#AA6464', 1.5]} |
---|
| 405 | |
---|
| 406 | fname = 'sailboat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) + \ |
---|
| 407 | '_lb' + str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) + \ |
---|
| 408 | '_lm' + str(int(lmast*100.)) + '_wm' + str(int(wmast)) + \ |
---|
| 409 | '_hsd' + str(int(hsd)) + '_hs' + str(int(lheads*100.)) + \ |
---|
| 410 | '_ms' + str(int(lheads*100.)) + '_msd' + str(int(msd)) +'.dat' |
---|
| 411 | if not os.path.isfile(fname): |
---|
| 412 | print infmsg |
---|
| 413 | print ' ' + fname + ": writting boat coordinates file '" + fname + "' !!" |
---|
| 414 | of = open(fname, 'w') |
---|
| 415 | of.write('# boat file with Length: ' + str(length) +' max_beam: '+str(beam)+ \ |
---|
| 416 | 'length_at_max_beam:' + str(lbeam) + '% beam at stern: ' + str(sternbp)+ \ |
---|
| 417 | ' % mast position: '+ str(lmast) + ' % mast width: ' + str(wmast) + ' ' + \ |
---|
| 418 | ' head sail direction:' + str(hsd) + ' head sail length: ' + str(lheads) + \ |
---|
| 419 | ' %' + ' main sail length' + str(lmains) + ' main sail direction:' + \ |
---|
| 420 | str(msd) +'\n') |
---|
| 421 | for ip in range(dpts*5): |
---|
| 422 | of.write(str(sailingboat[ip,0]) + ' ' + str(sailingboat[ip,1]) + '\n') |
---|
| 423 | |
---|
| 424 | of.close() |
---|
| 425 | print fname + ": Successfull written '" + fname + "' !!" |
---|
| 426 | |
---|
| 427 | return sailingboat, sailingboatsecs, dicsailingboat |
---|
| 428 | |
---|
| 429 | def zisland1(mainpts= np.array([[-0.1,0.], [-1.,1.], [-0.8,1.2], [0.1,0.6], [1., 0.9],\ |
---|
| 430 | [2.8, -0.1], [0.1,-0.6]], dtype=np.float), radfrac=3., N=200): |
---|
| 431 | """ Function to draw an island from z-axis as the union of a series of points by |
---|
| 432 | circular segments |
---|
| 433 | mainpts: main points of the island (clockwise ordered, to be joined by |
---|
| 434 | circular segments of radii as the radfrac factor of the distance between |
---|
| 435 | consecutive points) |
---|
| 436 | * default= np.array([[-0.1,0.], [-1.,1.], [-0.8,1.2], [0.1,0.6], [1., 0.9], |
---|
| 437 | [2.8, -0.1], [0.1,-0.6]], dtype=np.float) |
---|
| 438 | radfrac: multiplicative factor of the distance between consecutive points to |
---|
| 439 | draw the circular segment (3., default) |
---|
| 440 | N: number of points (200, default) |
---|
| 441 | """ |
---|
| 442 | fname = 'zisland1' |
---|
| 443 | |
---|
| 444 | island1 = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 445 | |
---|
| 446 | # Coastline |
---|
| 447 | island1 = geo.join_circ_sec_rand(mainpts, arc='short', pos='left') |
---|
| 448 | |
---|
| 449 | islandsecs = ['coastline'] |
---|
| 450 | islanddic = {'coastline': [island1, '-', '#161616', 2.]} |
---|
| 451 | |
---|
| 452 | island1 = ma.masked_equal(island1, gen.fillValueF) |
---|
| 453 | |
---|
| 454 | return island1, islandsecs, islanddic |
---|
| 455 | |
---|
| 456 | def buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=300): |
---|
| 457 | """ Function to draw a buoy as superposition of prism and section of ball |
---|
| 458 | height: height of the prism (5., default) |
---|
| 459 | width: width of the prism (10., default) |
---|
| 460 | bradii: radii of the ball (1.75, default) |
---|
| 461 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 462 | N: total number of points of the buoy (300, default) |
---|
| 463 | """ |
---|
| 464 | fname = 'buoy1' |
---|
| 465 | |
---|
| 466 | buoy = np.zeros((N,2), dtype=np.float) |
---|
| 467 | |
---|
| 468 | N3 = int(N/3/5) |
---|
| 469 | NNp = 0 |
---|
| 470 | iip = 0 |
---|
| 471 | # left lateral |
---|
| 472 | ix = -width/2. |
---|
| 473 | Np = N3 |
---|
| 474 | iy = 0. |
---|
| 475 | dx = 0. |
---|
| 476 | dy = height/(Np) |
---|
| 477 | for ip in range(Np): |
---|
| 478 | buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip] |
---|
| 479 | NNp = NNp + Np |
---|
| 480 | iip = NNp |
---|
| 481 | |
---|
| 482 | # left upper |
---|
| 483 | ix = -width/2. |
---|
| 484 | iy = height |
---|
| 485 | dx = (width/2.-bradii*bfrac)/(Np) |
---|
| 486 | dy = 0. |
---|
| 487 | for ip in range(Np): |
---|
| 488 | buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip] |
---|
| 489 | NNp = NNp + Np |
---|
| 490 | iip = NNp |
---|
| 491 | |
---|
| 492 | # ball |
---|
| 493 | p1 = np.array([height, -bradii*bfrac]) |
---|
| 494 | p2 = np.array([height, bradii*bfrac]) |
---|
| 495 | Np = int(2*N/3) |
---|
| 496 | buoy[iip:iip+Np,:] = geo.circ_sec(p1, p2, 2.*bradii, 'long', 'left', Np) |
---|
| 497 | NNp = NNp + Np |
---|
| 498 | iip = NNp |
---|
| 499 | |
---|
| 500 | # right upper |
---|
| 501 | ix = bradii*bfrac |
---|
| 502 | iy = height |
---|
| 503 | Np = N3 |
---|
| 504 | dx = (width/2.-bradii*bfrac)/(Np) |
---|
| 505 | dy = 0. |
---|
| 506 | for ip in range(Np): |
---|
| 507 | buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip] |
---|
| 508 | NNp = NNp + Np |
---|
| 509 | iip = NNp |
---|
| 510 | |
---|
| 511 | # right lateral |
---|
| 512 | ix = width/2. |
---|
| 513 | iy = height |
---|
| 514 | dx = 0. |
---|
| 515 | dy = -height/(Np) |
---|
| 516 | for ip in range(Np): |
---|
| 517 | buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip] |
---|
| 518 | NNp = NNp + Np |
---|
| 519 | iip = NNp |
---|
| 520 | |
---|
| 521 | # Base |
---|
| 522 | ix = width/2. |
---|
| 523 | iy = 0. |
---|
| 524 | Np = N - int(2*N/3) - 4*N3 - 1 |
---|
| 525 | dx = -width/(Np) |
---|
| 526 | dy = 0. |
---|
| 527 | for ip in range(Np): |
---|
| 528 | buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip] |
---|
| 529 | NNp = NNp + Np |
---|
| 530 | iip = NNp |
---|
| 531 | |
---|
| 532 | buoy[N-1,:] = buoy[0,:] |
---|
| 533 | |
---|
| 534 | buoysecs = ['base'] |
---|
| 535 | buoydic = {'base': [buoy, '-', 'k', 1.5]} |
---|
| 536 | |
---|
| 537 | return buoy, buoysecs, buoydic |
---|
| 538 | |
---|
| 539 | def band_lighthouse(height=10., width=2., hlight=3., bands=3, N=300): |
---|
| 540 | """ Function to plot a lighthouse with spiral bands |
---|
| 541 | height: height of the tower (10., default) |
---|
| 542 | width: width of the tower (2., default) |
---|
| 543 | hlight: height of the light (3., default) |
---|
| 544 | bands: number of spiral bands (3, default) |
---|
| 545 | N: number of points (300, default) |
---|
| 546 | """ |
---|
| 547 | fname = 'band_lighthouse' |
---|
| 548 | |
---|
| 549 | lighthouse = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 550 | lighthousesecs = [] |
---|
| 551 | lighthousedic = {} |
---|
| 552 | |
---|
| 553 | # base Tower |
---|
| 554 | Nsec = int(0.30*N/7) |
---|
| 555 | p1=np.array([0., width/2.]) |
---|
| 556 | p2=np.array([0., -width/2.]) |
---|
| 557 | iip = 0 |
---|
| 558 | lighthouse[0:Nsec,:] = geo.circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) |
---|
| 559 | iip = iip + Nsec |
---|
| 560 | |
---|
| 561 | # left side |
---|
| 562 | ix=-width/2. |
---|
| 563 | iy=0. |
---|
| 564 | dx = 0. |
---|
| 565 | dy = height/(Nsec-1) |
---|
| 566 | for ip in range(Nsec): |
---|
| 567 | lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] |
---|
| 568 | iip = iip + Nsec |
---|
| 569 | |
---|
| 570 | # Top Tower |
---|
| 571 | p1=np.array([height, width/2.]) |
---|
| 572 | p2=np.array([height, -width/2.]) |
---|
| 573 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) |
---|
| 574 | iip = iip + Nsec |
---|
| 575 | |
---|
| 576 | # right side |
---|
| 577 | ix=width/2. |
---|
| 578 | iy=height |
---|
| 579 | dx = 0. |
---|
| 580 | dy = -height/(Nsec-1) |
---|
| 581 | for ip in range(Nsec): |
---|
| 582 | lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] |
---|
| 583 | iip = iip + Nsec + 1 |
---|
| 584 | |
---|
| 585 | Ntower = iip-1 |
---|
| 586 | lighthousesecs.append('tower') |
---|
| 587 | lighthousedic['tower'] = [lighthouse[0:iip-1], '-', 'k', 1.5] |
---|
| 588 | |
---|
| 589 | # Left light |
---|
| 590 | p1 = np.array([height, -width*0.8/2.]) |
---|
| 591 | p2 = np.array([height+hlight, -width*0.8/2.]) |
---|
| 592 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*hlight, Nang=Nsec) |
---|
| 593 | iip = iip + Nsec |
---|
| 594 | |
---|
| 595 | # Top Light |
---|
| 596 | p1=np.array([height+hlight, width*0.8/2.]) |
---|
| 597 | p2=np.array([height+hlight, -width*0.8/2.]) |
---|
| 598 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) |
---|
| 599 | iip = iip + Nsec + 1 |
---|
| 600 | |
---|
| 601 | # Right light |
---|
| 602 | p1 = np.array([height+hlight, width*0.8/2.]) |
---|
| 603 | p2 = np.array([height, width*0.8/2.]) |
---|
| 604 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*hlight, Nang=Nsec) |
---|
| 605 | iip = iip + Nsec |
---|
| 606 | |
---|
| 607 | # Base Light |
---|
| 608 | p1=np.array([height, width*0.8/2.]) |
---|
| 609 | p2=np.array([height, -width*0.8/2.]) |
---|
| 610 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) |
---|
| 611 | iip = iip + Nsec + 1 |
---|
| 612 | lighthousesecs.append('light') |
---|
| 613 | lighthousedic['light'] = [lighthouse[Ntower+1:iip-1], '-', '#EEEE00', 1.5] |
---|
| 614 | |
---|
| 615 | # Spiral bands |
---|
| 616 | hb = height/(2.*bands) |
---|
| 617 | Nsec2 = (N - Nsec*8 - 3)/bands |
---|
| 618 | for ib in range(bands-1): |
---|
| 619 | iband = iip |
---|
| 620 | Nsec = Nsec2/4 |
---|
| 621 | bandS = 'band' + str(ib).zfill(2) |
---|
| 622 | # hband |
---|
| 623 | ix = -width/2. |
---|
| 624 | iy = hb*ib*2 |
---|
| 625 | dx = 0. |
---|
| 626 | dy = hb/(Nsec-1) |
---|
| 627 | for ip in range(Nsec): |
---|
| 628 | lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] |
---|
| 629 | iip = iip + Nsec |
---|
| 630 | # uband |
---|
| 631 | p1 = np.array([hb*(ib*2+1), -width/2.]) |
---|
| 632 | p2 = np.array([hb*(ib*2+2), width/2.]) |
---|
| 633 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*width, pos='right', Nang=Nsec) |
---|
| 634 | iip = iip + Nsec |
---|
| 635 | # dband |
---|
| 636 | ix = width/2. |
---|
| 637 | iy = hb*(ib*2+2) |
---|
| 638 | dx = 0. |
---|
| 639 | dy = -hb/(Nsec-1) |
---|
| 640 | for ip in range(Nsec): |
---|
| 641 | lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] |
---|
| 642 | iip = iip + Nsec |
---|
| 643 | # dband |
---|
| 644 | p1 = np.array([hb*(ib*2+1), width/2.]) |
---|
| 645 | p2 = np.array([hb*ib*2, -width/2.]) |
---|
| 646 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) |
---|
| 647 | iip = iip + Nsec + 1 |
---|
| 648 | lighthousesecs.append(bandS) |
---|
| 649 | lighthousedic[bandS] = [lighthouse[iband:iip-1], '-', '#6408AA', 2.] |
---|
| 650 | |
---|
| 651 | ib = bands-1 |
---|
| 652 | Nsec3 = (N - iip - 1) |
---|
| 653 | Nsec = int(Nsec3/4) |
---|
| 654 | bandS = 'band' + str(ib).zfill(2) |
---|
| 655 | # hband |
---|
| 656 | iband = iip |
---|
| 657 | ix = -width/2. |
---|
| 658 | iy = hb*ib*2 |
---|
| 659 | dx = 0. |
---|
| 660 | dy = hb/(Nsec-1) |
---|
| 661 | for ip in range(Nsec): |
---|
| 662 | lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] |
---|
| 663 | iip = iip + Nsec |
---|
| 664 | # uband |
---|
| 665 | p1 = np.array([hb*(ib*2+1), -width/2.]) |
---|
| 666 | p2 = np.array([hb*(ib*2+2), width/2.]) |
---|
| 667 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*width, pos='right', Nang=Nsec) |
---|
| 668 | iip = iip + Nsec |
---|
| 669 | # dband |
---|
| 670 | ix = width/2. |
---|
| 671 | iy = hb*(2+ib*2) |
---|
| 672 | dx = 0. |
---|
| 673 | dy = -hb/(Nsec-1) |
---|
| 674 | for ip in range(Nsec): |
---|
| 675 | lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] |
---|
| 676 | iip = iip + Nsec |
---|
| 677 | # dband |
---|
| 678 | Nsec = N - iip |
---|
| 679 | p1 = np.array([hb*(1+ib*2), width/2.]) |
---|
| 680 | p2 = np.array([hb*ib*2, -width/2.]) |
---|
| 681 | lighthouse[iip:iip+Nsec,:] = geo.circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) |
---|
| 682 | lighthousesecs.append(bandS) |
---|
| 683 | lighthousedic[bandS] = [lighthouse[iband:iip-1], '-', '#6408AA', 2.] |
---|
| 684 | |
---|
| 685 | lighthouse = ma.masked_equal(lighthouse, gen.fillValueF) |
---|
| 686 | |
---|
| 687 | return lighthouse, lighthousesecs, lighthousedic |
---|
| 688 | |
---|
| 689 | def north_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300): |
---|
| 690 | """ Function to draw a North danger buoy using buoy1 |
---|
| 691 | height: height of the prism (5., default) |
---|
| 692 | width: width of the prism (10., default) |
---|
| 693 | bradii: radii of the ball (1.75, default) |
---|
| 694 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 695 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 696 | (0.7, default) |
---|
| 697 | N: total number of points of the buoy (300, default) |
---|
| 698 | """ |
---|
| 699 | fname = 'north_buoy1' |
---|
| 700 | |
---|
| 701 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 702 | |
---|
| 703 | # buoy |
---|
| 704 | N2 = int(N/2) |
---|
| 705 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 706 | bfrac=0.8, N=N2) |
---|
| 707 | buoy[0:N2,:] = buoy1v |
---|
| 708 | |
---|
| 709 | # signs |
---|
| 710 | N3 = N - N2 - 2 |
---|
| 711 | |
---|
| 712 | bottsigns = 2.*bradii+height |
---|
| 713 | lsign = height*hsigns |
---|
| 714 | # up |
---|
| 715 | N32 = int(N3/2) |
---|
| 716 | triu = geo.p_angle_triangle(N=N32) |
---|
| 717 | trib = triu*lsign + [0.,-lsign/2.] |
---|
| 718 | |
---|
| 719 | buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.1*lsign,0.] |
---|
| 720 | |
---|
| 721 | # up |
---|
| 722 | N323 = N - N32 - N2 - 2 |
---|
| 723 | trid = geo.p_angle_triangle(N=N323) |
---|
| 724 | trib = trid*lsign + [0.,-lsign/2.] |
---|
| 725 | buoy[N2+N32+2:N,:] = trib + [bottsigns+1.1*lsign,0.] |
---|
| 726 | |
---|
| 727 | # painting it |
---|
| 728 | Height = np.max(buoy1v[:,0]) |
---|
| 729 | |
---|
| 730 | Ncut, halfdown = geo.cut_ypolygon(buoy1v, yval=Height/2., keep='below') |
---|
| 731 | Ncut, halfup = geo.cut_ypolygon(buoy1v, yval=Height/2., keep='above') |
---|
| 732 | |
---|
| 733 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 734 | |
---|
| 735 | buoysecs = ['buoy', 'sign1', 'sign2', 'half1', 'half2'] |
---|
| 736 | buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \ |
---|
| 737 | 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \ |
---|
| 738 | 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], 'half1': [halfup, '-', 'k', 1.], \ |
---|
| 739 | 'half2': [halfdown, '-', '#FFFF00', 1.]} |
---|
| 740 | |
---|
| 741 | return buoy, buoysecs, buoydic |
---|
| 742 | |
---|
| 743 | def east_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300): |
---|
| 744 | """ Function to draw a East danger buoy using buoy1 |
---|
| 745 | height: height of the prism (5., default) |
---|
| 746 | width: width of the prism (10., default) |
---|
| 747 | bradii: radii of the ball (1.75, default) |
---|
| 748 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 749 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 750 | (0.7, default) |
---|
| 751 | N: total number of points of the buoy (300, default) |
---|
| 752 | """ |
---|
| 753 | fname = 'east_buoy1' |
---|
| 754 | |
---|
| 755 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 756 | |
---|
| 757 | # buoy |
---|
| 758 | N2 = int(N/2) |
---|
| 759 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2) |
---|
| 760 | buoy[0:N2,:] = buoy1v |
---|
| 761 | |
---|
| 762 | # signs |
---|
| 763 | N3 = N - N2 - 2 |
---|
| 764 | |
---|
| 765 | bottsigns = 2.*bradii+height |
---|
| 766 | lsign = height*hsigns |
---|
| 767 | # up |
---|
| 768 | N32 = int(N3/2) |
---|
| 769 | triu = geo.p_angle_triangle(N=N32) |
---|
| 770 | trib = triu*lsign + [0.,-lsign/2.] |
---|
| 771 | |
---|
| 772 | buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.1*lsign,0.] |
---|
| 773 | |
---|
| 774 | # down |
---|
| 775 | N323 = N - N32 - N2 - 2 |
---|
| 776 | |
---|
| 777 | trid = geo.p_angle_triangle(N=N323) |
---|
| 778 | trid = geo.mirror_polygon(trid, 'x') |
---|
| 779 | trib = trid*lsign + [lsign,-lsign/2.] |
---|
| 780 | buoy[N2+N32+2:N,:] = trib + [bottsigns+0.9*lsign,0.] |
---|
| 781 | |
---|
| 782 | # painting it |
---|
| 783 | Height = np.max(buoy1v[:,0]) |
---|
| 784 | |
---|
| 785 | Ncut, halfdown = geo.cut_ypolygon(buoy1v, yval=Height/3., keep='below') |
---|
| 786 | Ncut, halfbtw = geo.cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) |
---|
| 787 | Ncut, halfup = geo.cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') |
---|
| 788 | |
---|
| 789 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 790 | |
---|
| 791 | buoysecs = ['buoy', 'sign1', 'sign2', 'third1', 'third2', 'third3'] |
---|
| 792 | buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \ |
---|
| 793 | 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \ |
---|
| 794 | 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], \ |
---|
| 795 | 'third1': [halfup, '-', 'k', 1.], 'third2': [halfbtw, '-', '#FFFF00', 1.], \ |
---|
| 796 | 'third3': [halfdown, '-', 'k', 1.]} |
---|
| 797 | |
---|
| 798 | return buoy, buoysecs, buoydic |
---|
| 799 | |
---|
| 800 | def south_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300): |
---|
| 801 | """ Function to draw a South danger buoy using buoy1 |
---|
| 802 | height: height of the prism (5., default) |
---|
| 803 | width: width of the prism (10., default) |
---|
| 804 | bradii: radii of the ball (1.75, default) |
---|
| 805 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 806 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 807 | (0.7, default) |
---|
| 808 | N: total number of points of the buoy (300, default) |
---|
| 809 | """ |
---|
| 810 | fname = 'south_buoy1' |
---|
| 811 | |
---|
| 812 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 813 | |
---|
| 814 | # buoy |
---|
| 815 | N2 = int(N/2) |
---|
| 816 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2) |
---|
| 817 | buoy[0:N2,:] = buoy1v |
---|
| 818 | |
---|
| 819 | # signs |
---|
| 820 | N3 = N - N2 - 2 |
---|
| 821 | |
---|
| 822 | bottsigns = 2.*bradii+height |
---|
| 823 | lsign = height*hsigns |
---|
| 824 | # up |
---|
| 825 | N32 = int(N3/2) |
---|
| 826 | trid = geo.p_angle_triangle(N=N32) |
---|
| 827 | trid = geo.mirror_polygon(trid, 'x') |
---|
| 828 | trib = trid*lsign + [0.,-lsign/2.] |
---|
| 829 | |
---|
| 830 | buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.9*lsign,0.] |
---|
| 831 | |
---|
| 832 | # down |
---|
| 833 | N323 = N - N32 - N2 - 2 |
---|
| 834 | trid = geo.p_angle_triangle(N=N323) |
---|
| 835 | trid = geo.mirror_polygon(trid, 'x') |
---|
| 836 | trib = trid*lsign + [lsign,-lsign/2.] |
---|
| 837 | buoy[N2+N32+2:N,:] = trib + [bottsigns+0.9*lsign,0.] |
---|
| 838 | |
---|
| 839 | # painting it |
---|
| 840 | Height = np.max(buoy1v[:,0]) |
---|
| 841 | |
---|
| 842 | Ncut, halfdown = geo.cut_ypolygon(buoy1v, yval=Height/2., keep='below') |
---|
| 843 | Ncut, halfup = geo.cut_ypolygon(buoy1v, yval=Height/2., keep='above') |
---|
| 844 | |
---|
| 845 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 846 | |
---|
| 847 | buoysecs = ['buoy', 'sign1', 'sign2', 'half1', 'half2'] |
---|
| 848 | buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \ |
---|
| 849 | 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \ |
---|
| 850 | 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], 'half1': [halfup, '-', '#FFFF00', 1.], \ |
---|
| 851 | 'half2': [halfdown, '-', 'k', 1.]} |
---|
| 852 | |
---|
| 853 | return buoy, buoysecs, buoydic |
---|
| 854 | |
---|
| 855 | def west_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300): |
---|
| 856 | """ Function to draw a West danger buoy using buoy1 |
---|
| 857 | height: height of the prism (5., default) |
---|
| 858 | width: width of the prism (10., default) |
---|
| 859 | bradii: radii of the ball (1.75, default) |
---|
| 860 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 861 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 862 | (0.7, default) |
---|
| 863 | N: total number of points of the buoy (300, default) |
---|
| 864 | """ |
---|
| 865 | fname = 'east_buoy1' |
---|
| 866 | |
---|
| 867 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 868 | |
---|
| 869 | # buoy |
---|
| 870 | N2 = int(N/2) |
---|
| 871 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2) |
---|
| 872 | buoy[0:N2,:] = buoy1v |
---|
| 873 | |
---|
| 874 | # signs |
---|
| 875 | N3 = N - N2 - 2 |
---|
| 876 | |
---|
| 877 | bottsigns = 2.*bradii+height |
---|
| 878 | lsign = height*hsigns |
---|
| 879 | |
---|
| 880 | # down |
---|
| 881 | N32 = int(N3/2) |
---|
| 882 | trid = geo.p_angle_triangle(N=N32) |
---|
| 883 | trid = geo.mirror_polygon(trid, 'x') |
---|
| 884 | trib = trid*lsign + [lsign,-lsign/2.] |
---|
| 885 | buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+1.9*lsign,0.] |
---|
| 886 | |
---|
| 887 | # up |
---|
| 888 | N323 = N - N32 - N2 - 2 |
---|
| 889 | triu = geo.p_angle_triangle(N=N323) |
---|
| 890 | trib = triu*lsign + [0.,-lsign/2.] |
---|
| 891 | |
---|
| 892 | buoy[N2+N323+2:N,:] = trib + [bottsigns+1.*lsign,0.] |
---|
| 893 | |
---|
| 894 | # painting it |
---|
| 895 | Height = np.max(buoy1v[:,0]) |
---|
| 896 | |
---|
| 897 | Ncut, halfdown = geo.cut_ypolygon(buoy1v, yval=Height/3., keep='below') |
---|
| 898 | Ncut, halfbtw1 = geo.cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) |
---|
| 899 | Ncut, halfup = geo.cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') |
---|
| 900 | |
---|
| 901 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 902 | |
---|
| 903 | buoysecs = ['buoy', 'sign1', 'sign2', 'third1', 'third2', 'third3'] |
---|
| 904 | buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \ |
---|
| 905 | 'third1': [halfdown, '-', '#FFFF00', 1.], 'third2': [halfbtw1, '-', 'k', 1.], \ |
---|
| 906 | 'third3': [halfup, '-', '#FFFF00', 1.], \ |
---|
| 907 | 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \ |
---|
| 908 | 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5]} |
---|
| 909 | |
---|
| 910 | return buoy, buoysecs, buoydic |
---|
| 911 | |
---|
| 912 | def safewater_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, N=300): |
---|
| 913 | """ Function to draw a safe water mark buoy using buoy1 |
---|
| 914 | height: height of the prism (5., default) |
---|
| 915 | width: width of the prism (10., default) |
---|
| 916 | bradii: radii of the ball (1.75, default) |
---|
| 917 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 918 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 919 | (0.3, default) |
---|
| 920 | N: total number of points of the buoy (300, default) |
---|
| 921 | """ |
---|
| 922 | fname = 'safewater_buoy1' |
---|
| 923 | |
---|
| 924 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 925 | |
---|
| 926 | # buoy |
---|
| 927 | N2 = int(N/2) |
---|
| 928 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 929 | bfrac=0.8, N=N2) |
---|
| 930 | buoy[0:N2,:] = buoy1v |
---|
| 931 | |
---|
| 932 | # signs |
---|
| 933 | N3 = N - N2 - 1 |
---|
| 934 | lsign = height*hsigns |
---|
| 935 | |
---|
| 936 | Height = np.max(buoy1v[:,0]) |
---|
| 937 | sign = geo.p_circle(lsign, N3) |
---|
| 938 | buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.] |
---|
| 939 | |
---|
| 940 | # painting it |
---|
| 941 | ix = -width/2. |
---|
| 942 | Ncut, quarter1 = geo.cut_xpolygon(buoy1v, xval=ix+width/4., keep='left') |
---|
| 943 | Ncut, quarter2 = geo.cut_between_xpolygon(buoy1v, xval1=ix+width/4., xval2=ix+width/2.) |
---|
| 944 | Ncut, quarter3 = geo.cut_between_xpolygon(buoy1v, xval1=ix+width/2., xval2=ix+3.*width/4.) |
---|
| 945 | Ncut, quarter4 = geo.cut_xpolygon(buoy1v, xval=ix+3.*width/4., keep='right') |
---|
| 946 | |
---|
| 947 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 948 | |
---|
| 949 | buoysecs = ['buoy', 'sign', 'quarter1', 'quarter2', 'quarter3', 'quarter4'] |
---|
| 950 | buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \ |
---|
| 951 | 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'quarter1': [quarter1,'-','r',1.], \ |
---|
| 952 | 'quarter2': [quarter2,'-','#FFFFFF',1.], 'quarter3': [quarter3,'-','r',1.], \ |
---|
| 953 | 'quarter4': [quarter4,'-','#FFFFFF',1.]} |
---|
| 954 | |
---|
| 955 | return buoy, buoysecs, buoydic |
---|
| 956 | |
---|
| 957 | def red_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, N=300): |
---|
| 958 | """ Function to draw a red mark buoy using buoy1 |
---|
| 959 | height: height of the prism (5., default) |
---|
| 960 | width: width of the prism (10., default) |
---|
| 961 | bradii: radii of the ball (1.75, default) |
---|
| 962 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 963 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 964 | (0.3, default) |
---|
| 965 | N: total number of points of the buoy (300, default) |
---|
| 966 | """ |
---|
| 967 | fname = 'red_buoy1' |
---|
| 968 | |
---|
| 969 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 970 | |
---|
| 971 | # buoy |
---|
| 972 | N2 = int(N/2) |
---|
| 973 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 974 | bfrac=0.8, N=N2) |
---|
| 975 | buoy[0:N2,:] = buoy1v |
---|
| 976 | |
---|
| 977 | # signs |
---|
| 978 | N3 = N - N2 - 1 |
---|
| 979 | lsign = height*hsigns*2. |
---|
| 980 | |
---|
| 981 | Height = np.max(buoy1v[:,0]) |
---|
| 982 | triu = geo.p_angle_triangle(N=N3) |
---|
| 983 | sign = triu*lsign |
---|
| 984 | buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.] |
---|
| 985 | |
---|
| 986 | # painting it |
---|
| 987 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 988 | |
---|
| 989 | buoysecs = ['buoy', 'sign'] |
---|
| 990 | buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \ |
---|
| 991 | 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5]} |
---|
| 992 | |
---|
| 993 | return buoy, buoysecs, buoydic |
---|
| 994 | |
---|
| 995 | def green_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, N=300): |
---|
| 996 | """ Function to draw a green mark buoy using buoy1 |
---|
| 997 | height: height of the prism (5., default) |
---|
| 998 | width: width of the prism (10., default) |
---|
| 999 | bradii: radii of the ball (1.75, default) |
---|
| 1000 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 1001 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 1002 | (0.3, default) |
---|
| 1003 | N: total number of points of the buoy (300, default) |
---|
| 1004 | """ |
---|
| 1005 | fname = 'green_buoy1' |
---|
| 1006 | |
---|
| 1007 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 1008 | |
---|
| 1009 | # buoy |
---|
| 1010 | N2 = int(N/2) |
---|
| 1011 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 1012 | bfrac=0.8, N=N2) |
---|
| 1013 | buoy[0:N2,:] = buoy1v |
---|
| 1014 | |
---|
| 1015 | # signs |
---|
| 1016 | N3 = N - N2 - 1 |
---|
| 1017 | lsign = height*hsigns*2. |
---|
| 1018 | |
---|
| 1019 | Height = np.max(buoy1v[:,0]) |
---|
| 1020 | sign = geo.p_prism(lsign, lsign*2, N=N3) |
---|
| 1021 | buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.] |
---|
| 1022 | |
---|
| 1023 | # painting it |
---|
| 1024 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 1025 | |
---|
| 1026 | buoysecs = ['buoy', 'sign'] |
---|
| 1027 | buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \ |
---|
| 1028 | 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5]} |
---|
| 1029 | |
---|
| 1030 | return buoy, buoysecs, buoydic |
---|
| 1031 | |
---|
| 1032 | def prefchannelportA_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, \ |
---|
| 1033 | N=300): |
---|
| 1034 | """ Function to draw a preferred channel port system A buoy using buoy1 |
---|
| 1035 | height: height of the prism (5., default) |
---|
| 1036 | width: width of the prism (10., default) |
---|
| 1037 | bradii: radii of the ball (1.75, default) |
---|
| 1038 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 1039 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 1040 | (0.3, default) |
---|
| 1041 | N: total number of points of the buoy (300, default) |
---|
| 1042 | """ |
---|
| 1043 | fname = 'prefchannelportA_buoy1' |
---|
| 1044 | |
---|
| 1045 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 1046 | |
---|
| 1047 | # buoy |
---|
| 1048 | N2 = int(N/2) |
---|
| 1049 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 1050 | bfrac=0.8, N=N2) |
---|
| 1051 | buoy[0:N2,:] = buoy1v |
---|
| 1052 | |
---|
| 1053 | # signs |
---|
| 1054 | N3 = N - N2 - 1 |
---|
| 1055 | lsign = height*hsigns*2. |
---|
| 1056 | |
---|
| 1057 | Height = np.max(buoy1v[:,0]) |
---|
| 1058 | triu = geo.p_angle_triangle(N=N3) |
---|
| 1059 | sign = triu*lsign |
---|
| 1060 | buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.] |
---|
| 1061 | |
---|
| 1062 | # painting it |
---|
| 1063 | Ncut, third1 = geo.cut_ypolygon(buoy1v, yval=Height/3., keep='below') |
---|
| 1064 | Ncut, third2 = geo.cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) |
---|
| 1065 | Ncut, third3 = geo.cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') |
---|
| 1066 | |
---|
| 1067 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 1068 | |
---|
| 1069 | buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3'] |
---|
| 1070 | buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \ |
---|
| 1071 | 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5], 'third1': [third1,'-','g',1.5], \ |
---|
| 1072 | 'third2': [third2,'-','r',1.5], 'third3': [third3,'-','g',1.5]} |
---|
| 1073 | |
---|
| 1074 | return buoy, buoysecs, buoydic |
---|
| 1075 | |
---|
| 1076 | def prefchannelportB_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, \ |
---|
| 1077 | N=300): |
---|
| 1078 | """ Function to draw a preferred channel port system B buoy using buoy1 |
---|
| 1079 | height: height of the prism (5., default) |
---|
| 1080 | width: width of the prism (10., default) |
---|
| 1081 | bradii: radii of the ball (1.75, default) |
---|
| 1082 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 1083 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 1084 | (0.3, default) |
---|
| 1085 | N: total number of points of the buoy (300, default) |
---|
| 1086 | """ |
---|
| 1087 | fname = 'prefchannelportB_buoy1' |
---|
| 1088 | |
---|
| 1089 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 1090 | |
---|
| 1091 | # buoy |
---|
| 1092 | N2 = int(N/2) |
---|
| 1093 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 1094 | bfrac=0.8, N=N2) |
---|
| 1095 | buoy[0:N2,:] = buoy1v |
---|
| 1096 | |
---|
| 1097 | # signs |
---|
| 1098 | N3 = N - N2 - 1 |
---|
| 1099 | lsign = height*hsigns*2. |
---|
| 1100 | |
---|
| 1101 | Height = np.max(buoy1v[:,0]) |
---|
| 1102 | triu = geo.p_angle_triangle(N=N3) |
---|
| 1103 | sign = triu*lsign |
---|
| 1104 | buoy[N2+1:N2+2+N3,:] = sign + [Height+0.2*lsign,-lsign/2.] |
---|
| 1105 | |
---|
| 1106 | # painting it |
---|
| 1107 | Ncut, third1 = geo.cut_ypolygon(buoy1v, yval=Height/3., keep='below') |
---|
| 1108 | Ncut, third2 = geo.cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) |
---|
| 1109 | Ncut, third3 = geo.cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') |
---|
| 1110 | |
---|
| 1111 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 1112 | |
---|
| 1113 | buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3'] |
---|
| 1114 | buoydic = {'buoy': [buoy[0:N2,:],'-','r',1.5], \ |
---|
| 1115 | 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'third1': [third1,'-','r',1.5], \ |
---|
| 1116 | 'third2': [third2,'-','g',1.5], 'third3': [third3,'-','r',1.5]} |
---|
| 1117 | |
---|
| 1118 | return buoy, buoysecs, buoydic |
---|
| 1119 | |
---|
| 1120 | def prefchannelstarboardA_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, \ |
---|
| 1121 | hsigns=0.3, N=300): |
---|
| 1122 | """ Function to draw a preferred channel starboard system A buoy using buoy1 |
---|
| 1123 | height: height of the prism (5., default) |
---|
| 1124 | width: width of the prism (10., default) |
---|
| 1125 | bradii: radii of the ball (1.75, default) |
---|
| 1126 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 1127 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 1128 | (0.3, default) |
---|
| 1129 | N: total number of points of the buoy (300, default) |
---|
| 1130 | """ |
---|
| 1131 | fname = 'prefchannelstarboardA_buoy1' |
---|
| 1132 | |
---|
| 1133 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 1134 | |
---|
| 1135 | # buoy |
---|
| 1136 | N2 = int(N/2) |
---|
| 1137 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 1138 | bfrac=0.8, N=N2) |
---|
| 1139 | buoy[0:N2,:] = buoy1v |
---|
| 1140 | |
---|
| 1141 | # signs |
---|
| 1142 | N3 = N - N2 - 1 |
---|
| 1143 | lsign = height*hsigns*2. |
---|
| 1144 | |
---|
| 1145 | Height = np.max(buoy1v[:,0]) |
---|
| 1146 | sign = geo.p_prism(lsign, lsign*2, N=N3) |
---|
| 1147 | buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.] |
---|
| 1148 | |
---|
| 1149 | # painting it |
---|
| 1150 | # painting it |
---|
| 1151 | Ncut, third1 = geo.cut_ypolygon(buoy1v, yval=Height/3., keep='below') |
---|
| 1152 | Ncut, third2 = geo.cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) |
---|
| 1153 | Ncut, third3 = geo.cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') |
---|
| 1154 | |
---|
| 1155 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 1156 | |
---|
| 1157 | buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3'] |
---|
| 1158 | buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \ |
---|
| 1159 | 'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'third1': [third1,'-','r',1.5], \ |
---|
| 1160 | 'third2': [third2,'-','g',1.5], 'third3': [third3,'-','r',1.5]} |
---|
| 1161 | |
---|
| 1162 | return buoy, buoysecs, buoydic |
---|
| 1163 | |
---|
| 1164 | def prefchannelstarboardB_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, \ |
---|
| 1165 | hsigns=0.3, N=300): |
---|
| 1166 | """ Function to draw a preferred channel starboard system B buoy using buoy1 |
---|
| 1167 | height: height of the prism (5., default) |
---|
| 1168 | width: width of the prism (10., default) |
---|
| 1169 | bradii: radii of the ball (1.75, default) |
---|
| 1170 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 1171 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 1172 | (0.3, default) |
---|
| 1173 | N: total number of points of the buoy (300, default) |
---|
| 1174 | """ |
---|
| 1175 | fname = 'prefchannelstarboardB_buoy1' |
---|
| 1176 | |
---|
| 1177 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 1178 | |
---|
| 1179 | # buoy |
---|
| 1180 | N2 = int(N/2) |
---|
| 1181 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 1182 | bfrac=0.8, N=N2) |
---|
| 1183 | buoy[0:N2,:] = buoy1v |
---|
| 1184 | |
---|
| 1185 | # signs |
---|
| 1186 | N3 = N - N2 - 1 |
---|
| 1187 | lsign = height*hsigns*2. |
---|
| 1188 | |
---|
| 1189 | Height = np.max(buoy1v[:,0]) |
---|
| 1190 | sign = geo.p_prism(lsign, lsign*2, N=N3) |
---|
| 1191 | buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.] |
---|
| 1192 | |
---|
| 1193 | # painting it |
---|
| 1194 | # painting it |
---|
| 1195 | Ncut, third1 = geo.cut_ypolygon(buoy1v, yval=Height/3., keep='below') |
---|
| 1196 | Ncut, third2 = geo.cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) |
---|
| 1197 | Ncut, third3 = geo.cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') |
---|
| 1198 | |
---|
| 1199 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 1200 | |
---|
| 1201 | buoysecs = ['buoy', 'sign', 'third1', 'third2', 'third3'] |
---|
| 1202 | buoydic = {'buoy': [buoy[0:N2,:],'-','g',1.5], \ |
---|
| 1203 | 'sign': [buoy[N2+1:N2+N3+1,:],'-','g',1.5], 'third1': [third1,'-','g',1.5], \ |
---|
| 1204 | 'third2': [third2,'-','r',1.5], 'third3': [third3,'-','g',1.5]} |
---|
| 1205 | |
---|
| 1206 | return buoy, buoysecs, buoydic |
---|
| 1207 | |
---|
| 1208 | def isolateddanger_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5, \ |
---|
| 1209 | N=300): |
---|
| 1210 | """ Function to draw an isolated danger buoy using buoy1 |
---|
| 1211 | height: height of the prism (5., default) |
---|
| 1212 | width: width of the prism (10., default) |
---|
| 1213 | bradii: radii of the ball (1.75, default) |
---|
| 1214 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 1215 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 1216 | (0.5, default) |
---|
| 1217 | N: total number of points of the buoy (300, default) |
---|
| 1218 | """ |
---|
| 1219 | fname = 'isolateddanger_buoy1' |
---|
| 1220 | |
---|
| 1221 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 1222 | |
---|
| 1223 | # buoy |
---|
| 1224 | N2 = int(N/2) |
---|
| 1225 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 1226 | bfrac=0.8, N=N2) |
---|
| 1227 | buoy[0:N2,:] = buoy1v |
---|
| 1228 | |
---|
| 1229 | # signs |
---|
| 1230 | N3 = N - N2 - 2 |
---|
| 1231 | |
---|
| 1232 | bottsigns = 2.*bradii+height |
---|
| 1233 | lsign = height*hsigns |
---|
| 1234 | # up |
---|
| 1235 | N32 = int(N3/2) |
---|
| 1236 | circle = geo.p_circle(lsign/2., N=N32) |
---|
| 1237 | trib = circle + [0.,0.] |
---|
| 1238 | |
---|
| 1239 | buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+3.2*lsign,0.] |
---|
| 1240 | |
---|
| 1241 | # up |
---|
| 1242 | N323 = N - N32 - N2 - 2 |
---|
| 1243 | trid = geo.p_circle(lsign/2., N=N32) |
---|
| 1244 | trib = circle + [0.,0.] |
---|
| 1245 | buoy[N2+N32+2:N,:] = trib + [bottsigns+2.*lsign,0.] |
---|
| 1246 | |
---|
| 1247 | # painting it |
---|
| 1248 | Height = np.max(buoy1v[:,0]) |
---|
| 1249 | |
---|
| 1250 | Ncut, third1 = geo.cut_ypolygon(buoy1v, yval=Height/3., keep='below') |
---|
| 1251 | Ncut, third2 = geo.cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.) |
---|
| 1252 | Ncut, third3 = geo.cut_ypolygon(buoy1v, yval=Height*2./3., keep='above') |
---|
| 1253 | |
---|
| 1254 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 1255 | |
---|
| 1256 | buoysecs = ['buoy', 'sign1', 'sign2', 'third1', 'third2', 'third3'] |
---|
| 1257 | buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5], \ |
---|
| 1258 | 'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5], \ |
---|
| 1259 | 'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], 'third1': [third1, '-', 'k', 1.], \ |
---|
| 1260 | 'third2': [third2, '-', 'r', 1.], 'third3': [third3, '-', 'k', 1.]} |
---|
| 1261 | |
---|
| 1262 | return buoy, buoysecs, buoydic |
---|
| 1263 | |
---|
| 1264 | def special_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5, N=300): |
---|
| 1265 | """ Function to draw an special mark buoy using buoy1 |
---|
| 1266 | height: height of the prism (5., default) |
---|
| 1267 | width: width of the prism (10., default) |
---|
| 1268 | bradii: radii of the ball (1.75, default) |
---|
| 1269 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 1270 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 1271 | (0.5, default) |
---|
| 1272 | N: total number of points of the buoy (300, default) |
---|
| 1273 | """ |
---|
| 1274 | fname = 'special_buoy1' |
---|
| 1275 | |
---|
| 1276 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 1277 | |
---|
| 1278 | # buoy |
---|
| 1279 | N2 = int(N/2) |
---|
| 1280 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 1281 | bfrac=0.8, N=N2) |
---|
| 1282 | buoy[0:N2,:] = buoy1v |
---|
| 1283 | |
---|
| 1284 | Height = np.max(buoy1v[:,0]) |
---|
| 1285 | |
---|
| 1286 | # sign |
---|
| 1287 | N3 = N - N2 - 1 |
---|
| 1288 | |
---|
| 1289 | bottsigns = 2.*bradii+height |
---|
| 1290 | lsign = height*hsigns |
---|
| 1291 | # up |
---|
| 1292 | cross, crosssecs, crossdic = geo.p_cross_width(lsign, width=0.3*lsign, Narms=2, N=N3) |
---|
| 1293 | cross = geo.rotate_polygon_2D(cross, 40.05) |
---|
| 1294 | buoy[N2+1:N,:] = cross + [Height+1.1*lsign,0.] |
---|
| 1295 | |
---|
| 1296 | # painting it |
---|
| 1297 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 1298 | |
---|
| 1299 | buoysecs = ['buoy', 'sign'] |
---|
| 1300 | buoydic = {'buoy': [buoy[0:N2,:],'-','#FFFF00',1.5], \ |
---|
| 1301 | 'sign': [buoy[N2+1:N,:],'-','#FFFF00',1.5]} |
---|
| 1302 | |
---|
| 1303 | return buoy, buoysecs, buoydic |
---|
| 1304 | |
---|
| 1305 | def emergency_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5, N=300): |
---|
| 1306 | """ Function to draw an eergency mark buoy using buoy1 |
---|
| 1307 | height: height of the prism (5., default) |
---|
| 1308 | width: width of the prism (10., default) |
---|
| 1309 | bradii: radii of the ball (1.75, default) |
---|
| 1310 | bfrac: fraction of the ball above the prism (0.8, default) |
---|
| 1311 | hisgns: height of the signs [as reg. triangle] as percentage of the height |
---|
| 1312 | (0.5, default) |
---|
| 1313 | N: total number of points of the buoy (300, default) |
---|
| 1314 | """ |
---|
| 1315 | fname = 'emergency_buoy1' |
---|
| 1316 | |
---|
| 1317 | buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF |
---|
| 1318 | |
---|
| 1319 | # buoy |
---|
| 1320 | N2 = int(N/2) |
---|
| 1321 | buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ |
---|
| 1322 | bfrac=0.8, N=N2) |
---|
| 1323 | buoy[0:N2,:] = buoy1v |
---|
| 1324 | |
---|
| 1325 | Height = np.max(buoy1v[:,0]) |
---|
| 1326 | |
---|
| 1327 | # sign |
---|
| 1328 | N3 = N - N2 - 1 |
---|
| 1329 | |
---|
| 1330 | bottsigns = 2.*bradii+height |
---|
| 1331 | lsign = height*hsigns |
---|
| 1332 | # up |
---|
| 1333 | cross, crosssecs, crossdic = geo.p_cross_width(lsign, width=0.3*lsign, Narms=2, N=N3) |
---|
| 1334 | buoy[N2+1:N,:] = cross + [Height+1.1*lsign,0.] |
---|
| 1335 | |
---|
| 1336 | # painting it |
---|
| 1337 | ix = -width/2. |
---|
| 1338 | Ncut, fifth1 = geo.cut_xpolygon(buoy1v, xval=ix+width/5., keep='left') |
---|
| 1339 | Ncut, fifth2 = geo.cut_between_xpolygon(buoy1v,xval1=ix+width/5.,xval2=ix+width*2./5.) |
---|
| 1340 | Ncut, fifth3 = geo.cut_between_xpolygon(buoy1v,xval1=ix+width*2./5.,xval2=ix+width*3./5.) |
---|
| 1341 | Ncut, fifth4 = geo.cut_between_xpolygon(buoy1v,xval1=ix+width*3./5.,xval2=ix+width*4./5.) |
---|
| 1342 | Ncut, fifth5 = geo.cut_xpolygon(buoy1v, xval=ix+width*4./5., keep='right') |
---|
| 1343 | |
---|
| 1344 | buoy = ma.masked_equal(buoy, gen.fillValueF) |
---|
| 1345 | |
---|
| 1346 | buoysecs = ['buoy', 'sign', 'fifth1', 'fifth2', 'fifth3', 'fifth4', 'fifth5'] |
---|
| 1347 | buoydic = {'buoy': [buoy[0:N2,:],'-','#FFFF00',1.5], \ |
---|
| 1348 | 'sign': [buoy[N2+1:N,:],'-','#FFFF00',1.5],'fifth1':[fifth1,'-','#FFFF00',1.5],\ |
---|
| 1349 | 'fifth2': [fifth2,'-','#0000FF',1.5],'fifth3': [fifth3,'-','#FFFF00',1.5], \ |
---|
| 1350 | 'fifth4': [fifth4,'-','#0000FF',1.5],'fifth5': [fifth5,'-','#FFFF00',1.5]} |
---|
| 1351 | |
---|
| 1352 | return buoy, buoysecs, buoydic |
---|
| 1353 | |
---|
[2636] | 1354 | def EstuarioRioPlata(N=300): |
---|
| 1355 | """ Function to plot an eschematic representation of the Estuario of Rio de la Plata |
---|
| 1356 | N: total number of vertices to use |
---|
| 1357 | """ |
---|
| 1358 | fname = 'EstuarioRioPlata' |
---|
| 1359 | |
---|
| 1360 | secs0 = ['PuntaMedanos', 'PuntaRaza', 'RioSalado', 'PuntaIndio', 'PuntaAtalaya', \ |
---|
| 1361 | 'Tigre', 'MartinChico', 'Colonia', 'ArroyoRosario', 'Montevideo', 'PuntaEste', \ |
---|
| 1362 | 'CaboPolonio'] |
---|
| 1363 | secs = [] |
---|
| 1364 | dic = {} |
---|
| 1365 | rads = [5., 1.0, 5., 5., 5., 5., 5., 5., 5., 5., 5.] |
---|
| 1366 | lengths = ['short', 'short', 'short', 'short', 'short', 'short', 'short', \ |
---|
| 1367 | 'short', 'short', 'short', 'short'] |
---|
| 1368 | sides = ['right', 'left', 'left', 'right', 'left', 'left', 'left', 'left', \ |
---|
| 1369 | 'right', 'left', 'right'] |
---|
| 1370 | Nsecs = len(secs0) |
---|
| 1371 | Nn = N/Nsecs |
---|
| 1372 | estuario = np.zeros((N,2), dtype=np.float) |
---|
| 1373 | |
---|
| 1374 | iip = 0 |
---|
| 1375 | # Atlantic_PuntaRaza |
---|
| 1376 | prevn = 'PuntaMedanos' |
---|
[2637] | 1377 | pv = NotablePoints[prevn] |
---|
[2636] | 1378 | ip = pv[1] |
---|
| 1379 | for isec in range(1,Nsecs-1): |
---|
| 1380 | iisec = isec - 1 |
---|
| 1381 | aname = secs0[isec] |
---|
[2637] | 1382 | pv = NotablePoints[aname] |
---|
[2636] | 1383 | ep = pv[1] |
---|
| 1384 | dps = geo.dist_points(ip,ep) |
---|
| 1385 | estuario[iip:iip+Nn,:] = geo.circ_sec(ip,ep, dps*rads[iisec], lengths[iisec],\ |
---|
| 1386 | sides[iisec], Nn) |
---|
| 1387 | secs.append(prevn+'_'+aname) |
---|
| 1388 | dic[prevn+'_'+aname] = [estuario[iip:iip+Nn,:], ['-', 'k', 1.]] |
---|
| 1389 | ip = ep + 0. |
---|
| 1390 | prevn = aname + '' |
---|
| 1391 | iip = iip + Nn |
---|
| 1392 | |
---|
| 1393 | Nn2 = N - (Nsecs-2)*Nn |
---|
| 1394 | isec = Nsecs-1 |
---|
| 1395 | iisec = isec - 1 |
---|
| 1396 | aname = secs0[isec] |
---|
[2637] | 1397 | pv = NotablePoints[aname] |
---|
[2636] | 1398 | ep = pv[1] |
---|
| 1399 | dps = geo.dist_points(ip,ep) |
---|
| 1400 | isec = Nsecs - 1 |
---|
| 1401 | estuario[iip:N,:] = geo.circ_sec(ip, ep, dps*rads[iisec], lengths[iisec], \ |
---|
| 1402 | sides[iisec], Nn2) |
---|
| 1403 | secs.append(prevn+'_'+aname) |
---|
| 1404 | dic[prevn+'_'+aname] = [estuario[iip:N,:], ['-', 'k', 1.]] |
---|
| 1405 | |
---|
| 1406 | return estuario, secs, dic |
---|
| 1407 | |
---|
[2646] | 1408 | def boatnames(xn,xx,yn,yx,zn,zx,zlf): |
---|
| 1409 | """ Function to provide the names of the sections of a boat |
---|
| 1410 | xn: minimum length on x-axis (across beam) |
---|
| 1411 | xx: maximum length on x-axis (across beam) |
---|
| 1412 | yn: minimum length on y-axis (length) |
---|
| 1413 | yx: maximum length on y-axis (length) |
---|
| 1414 | zn: minimum length on z-axis (draught) |
---|
| 1415 | zx: maximum length on z-axis (draught) |
---|
[2647] | 1416 | zlf: water line |
---|
[2646] | 1417 | """ |
---|
| 1418 | fname = 'boatnames' |
---|
| 1419 | |
---|
| 1420 | dx = xx - xn |
---|
| 1421 | dy = yx - yn |
---|
| 1422 | dz = zx - zn |
---|
| 1423 | |
---|
| 1424 | x0 = xn + dx/2. |
---|
| 1425 | y0 = yn + dy/2. |
---|
| 1426 | z0 = zn + dz/2. |
---|
| 1427 | |
---|
| 1428 | # Values |
---|
| 1429 | boatvs = { |
---|
| 1430 | 'xn': xn, 'xx': xx, 'yn': yn, 'yx': yx, 'zn': zn, 'zx': zx, \ |
---|
| 1431 | 'dx': dx, 'dy': dy, 'dz': dz, 'zlf': zlf, \ |
---|
| 1432 | } |
---|
| 1433 | |
---|
| 1434 | # Names |
---|
| 1435 | boatns = { |
---|
| 1436 | 'bow': ['bow', 'proa', np.array([x0,yx,zx])], \ |
---|
| 1437 | 'stern': ['stern', 'popa', np.array([x0,yn,zx])], \ |
---|
[2650] | 1438 | 'starboard': ['starboard', 'estribor', np.array([xx,y0,zx])], \ |
---|
[2646] | 1439 | 'port': ['port', 'babor', np.array([xn,y0,zx])], \ |
---|
| 1440 | 'waterline': ['waterline', 'l'+unichr(237)+'nea de flotaci'+ unichr(243)+'n', \ |
---|
[2647] | 1441 | np.array([xn,y0,zlf])], \ |
---|
| 1442 | 'keel': ['keel', 'quillote', np.array([xn,y0,zn])], \ |
---|
[2648] | 1443 | 'centerline': ['center line', 'l'+unichr(237)+'nea de cruj'+unichr(237)+ \ |
---|
[2650] | 1444 | 'a (plano)', np.array([x0,y0,zn])], \ |
---|
| 1445 | 'bowside': ['bow', 'amura', np.array([xx,yx*0.83,zx])], \ |
---|
| 1446 | 'beamside': ['beam', 'trav' + unichr(233)+ 's', np.array([xx,yx*0.5,zx])], \ |
---|
| 1447 | 'quarter': ['quarter', 'aleta', np.array([xx,yx*0.15,zx])], \ |
---|
[2648] | 1448 | |
---|
[2646] | 1449 | } |
---|
| 1450 | |
---|
| 1451 | # Dimensions |
---|
| 1452 | boatls = { |
---|
[2647] | 1453 | 'length': ['length', 'eslora', np.array([[x0,yn,zx], [x0,yx,zx]])], \ |
---|
| 1454 | 'beam': ['beam', 'manga', np.array([[xn,y0,zx], [xx,y0,zx]])], \ |
---|
[2653] | 1455 | 'freeboard': ['freeboard (air \ndraught)', 'francobordo (obra \nviva)\n carena', \ |
---|
[2647] | 1456 | np.array([[xn,yn,zlf], [xn,yn,zx]])], \ |
---|
| 1457 | 'draught': ['draught', 'calado (obra \nmuerta)', \ |
---|
| 1458 | np.array([[xn,yx,zlf],[xn,yx,zn]])], \ |
---|
[2650] | 1459 | 'bowside': ['bow', 'amura', \ |
---|
| 1460 | np.array([[xx,yx*0.6,zx],[xn,yx*0.6,zx]])], \ |
---|
| 1461 | 'beamside': ['beam', 'trav'+unichr(233)+'s', \ |
---|
| 1462 | np.array([[xx,yx*0.3,zx], [xn,yx*0.3,zx]])], \ |
---|
| 1463 | 'quarter': ['quarter', 'aleta', np.array([[xx,0.,zx], [xn,0.,zx]])], \ |
---|
[2646] | 1464 | } |
---|
| 1465 | |
---|
| 1466 | return boatvs, boatns, boatls |
---|