Changeset 2645 in lmdz_wrf


Ignore:
Timestamp:
Jun 29, 2019, 9:00:17 PM (5 years ago)
Author:
lfita
Message:

Adding:

  • `yboat': Function to define an schematic boat from the y-plane
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nautical.py

    r2644 r2645  
    2929# safewater_buoy1: Function to draw a safe water mark buoy using buoy1
    3030# special_buoy1: Function to draw an special mark buoy using buoy1
     31# yboat: Function to define an schematic boat from the y-plane
    3132# z_boat: Function to define an schematic boat from the z-plane
    3233# zsailing_boat: Function to define an schematic sailing boat from the z-plane with sails
     
    5556
    5657# FROM: http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html
     58def yboat(length=10., flength=0.7, freeboard=2., hskeg=2.,fskeg=0.2,  N=200):
     59    """ Function to define an schematic boat from the y-plane
     60      length: length of the boat (without stern, default, 10)
     61      flength: floating length of the boat as percentage of length (defatult, 0.7)
     62      freeboard: height above the water (default, 2)
     63      hskeg: height of the skeg (default, 2)
     64      fskeg: length of the skeg as percentage of length (default, 0.2)
     65      N: number of points to use (default, 200)
     66    """
     67    fname = 'yboat'
     68
     69    lflength = length*flength
     70    ilf3 = length*(1.-flength)/3
     71
     72    bow = np.array([length, freeboard])
     73    hbow = np.array([lflength + ilf3, 0.])
     74    sternp = np.array([0., freeboard])
     75    sternlp = np.array([0., freeboard*0.8])
     76
     77    boat = np.zeros((N,2), dtype=np.float)
     78    N1 = int(N*0.8)
     79    N2 = N - N1 - 1
     80
     81    # stern
     82    N14 = N1/4
     83    stern = np.zeros((N14,2), dtype=np.float)
     84    ipt = hbow
     85    ept = bow
     86    dy = (ept[0] - ipt[0])/(N14-1)
     87    dz = (ept[1] - ipt[1])/(N14-1)
     88    for ip in range(N14):
     89        stern[ip,:] = ipt + [dy*ip, dz*ip]
     90
     91    # deck
     92    deck = np.zeros((N14,2), dtype=np.float)
     93    ipt = bow
     94    ept = sternp
     95    dy = (ept[0] - ipt[0])/(N14-1)
     96    dz = (ept[1] - ipt[1])/(N14-1)
     97    for ip in range(N14):
     98        deck[ip,:] = ipt + [dy*ip, dz*ip]
     99
     100    # sternl
     101    sternl = np.zeros((N14,2), dtype=np.float)
     102    ipt = sternp
     103    ept = sternlp
     104    dy = (ept[0] - ipt[0])/(N14-1)
     105    dz = (ept[1] - ipt[1])/(N14-1)
     106    for ip in range(N14):
     107        sternl[ip,:] = ipt + [dy*ip, dz*ip]
     108
     109    # keel
     110    N12 = N1 - 3*N14
     111    keel = geo.circ_sec(sternlp, hbow, length, arc='short', pos='left', Nang=N12)
     112
     113    # skeg
     114    lskeg = length*fskeg
     115    ilk3 = length*(1.-fskeg)/3
     116    iuskeg = np.array([1.5*ilk3, 0.])
     117    euskeg = np.array([1.5*ilk3+lskeg, 0.])
     118    edskeg = np.array([1.5*ilk3+lskeg*0.8, -hskeg])
     119    idskeg = np.array([1.5*ilk3+lskeg*0.3, -hskeg])
     120
     121    skeg = np.zeros((N2,2), dtype=np.float)
     122    N24=N2/4
     123
     124    # upper skeg
     125    uskeg = np.zeros((N24,2), dtype=np.float)
     126    ipt = iuskeg
     127    ept = euskeg
     128    dy = (ept[0] - ipt[0])/(N24-1)
     129    dz = (ept[1] - ipt[1])/(N24-1)
     130    for ip in range(N24):
     131        uskeg[ip,:] = ipt + [dy*ip, dz*ip]
     132
     133    # aft skeg
     134    askeg = np.zeros((N24,2), dtype=np.float)
     135    ipt = euskeg
     136    ept = edskeg
     137    dy = (ept[0] - ipt[0])/(N24-1)
     138    dz = (ept[1] - ipt[1])/(N24-1)
     139    for ip in range(N24):
     140        askeg[ip,:] = ipt + [dy*ip, dz*ip]
     141
     142    # down skeg
     143    dskeg = np.zeros((N24,2), dtype=np.float)
     144    ipt = edskeg
     145    ept = idskeg
     146    dy = (ept[0] - ipt[0])/(N24-1)
     147    dz = (ept[1] - ipt[1])/(N24-1)
     148    for ip in range(N24):
     149        dskeg[ip,:] = ipt + [dy*ip, dz*ip]
     150
     151    # stern skeg
     152    N22 = N2 - 3*N24
     153    sskeg = np.zeros((N22,2), dtype=np.float)
     154    ipt = idskeg
     155    ept = iuskeg
     156    dy = (ept[0] - ipt[0])/(N22-1)
     157    dz = (ept[1] - ipt[1])/(N22-1)
     158    for ip in range(N22):
     159        sskeg[ip,:] = ipt + [dy*ip, dz*ip]
     160
     161    boat[0:N14,:] = stern
     162    boat[N14:2*N14,:] = deck
     163    boat[2*N14:3*N14,:] = sternl
     164    boat[3*N14:4*N12,:] = keel
     165    boat[N1,:] = np.array([gen.fillValueF, gen.fillValueF])
     166    boat[N1+1:N1+1+N24,:] = uskeg
     167    boat[N1+1+N24:N1+1+2*N24,:] = askeg
     168    boat[N1+1+2*N24:N1+1+3*N24,:] = dskeg
     169    boat[N1+1+3*N24:N,:] = sskeg
     170
     171    # correct order of sections
     172    boatsecs = ['stern', 'deck', 'sternl', 'keel', 'uskeg', 'askeg', 'dskeg', 'sskeg']
     173
     174    # dictionary with sections [polygon_vertices, line_type, line_color, line_width]
     175    dicboat = {'stern': [stern, '-', '#8A5900', 2.],                         \
     176      'deck': [deck, '-', '#8A5900', 2.],                                  \
     177      'sternl': [sternl, '-', '#8A5900', 2.],                                          \
     178      'keel': [keel, '-', '#8A5900', 2.],                        \
     179      'uskeg': [uskeg, '-', '#000000', 1.5], 'askeg': [askeg, '-.', '#000000', 1.5], \
     180      'dskeg': [dskeg, '-', '#000000', 1.5], 'sskeg': [sskeg, '-.', '#000000', 1.5]}
     181
     182    boat = ma.masked_equal(boat, gen.fillValueF)
     183     
     184    return boat, boatsecs, dicboat
     185
    57186def zboat(length=10., beam=1., lbeam=0.4, sternbp=0.5):
    58187    """ Function to define an schematic boat from the z-plane
Note: See TracChangeset for help on using the changeset viewer.