Changeset 2513 in lmdz_wrf for trunk


Ignore:
Timestamp:
May 7, 2019, 5:42:58 AM (7 years ago)
Author:
lfita
Message:

Fixing `boats' with the new 'circ_sec'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2512 r2513  
    884884
    885885    # forward section
    886     fportside = circ_sec(bow,maxportside, length*2)
    887     fstarboardside = circ_sec(maxstarboardside, bow, length*2)
     886    fportside = circ_sec(maxportside, bow, length*2)
     887    fstarboardside = circ_sec(bow, maxstarboardside, length*2)
    888888    # aft section
    889     aportside = circ_sec(maxportside, portside, length*2)
    890     astarboardside = circ_sec(starboardside, maxstarboardside, length*2)
     889    aportside = circ_sec(portside, maxportside, length*2)
     890    astarboardside = circ_sec(maxstarboardside, starboardside, length*2)
    891891    # stern
    892     stern = circ_sec(portside, starboardside, length*2)
     892    stern = circ_sec(starboardside, portside, length*2)
    893893
    894894    dpts = stern.shape[0]
    895895    boat = np.zeros((dpts*5,2), dtype=np.float)
    896896
    897     boat[0:dpts,:] = fportside
    898     boat[dpts:2*dpts,:] = aportside
    899     boat[2*dpts:3*dpts,:] = stern
     897    boat[0:dpts,:] = aportside
     898    boat[dpts:2*dpts,:] = fportside
     899    boat[2*dpts:3*dpts,:] = fstarboardside
    900900    boat[3*dpts:4*dpts,:] = astarboardside
    901     boat[4*dpts:5*dpts,:] = fstarboardside
     901    boat[4*dpts:5*dpts,:] = stern
    902902
    903903    fname = 'boat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) + '_lb' +  \
     
    915915        of.close()
    916916        print fname + ": Successfull written '" + fname + "' !!"
    917  
    918     return boat
     917
     918
     919    # Center line extending [fcl] percentage from length on aft and stern
     920    fcl = 0.15
     921    centerline = np.zeros((dpts,2), dtype=np.float)
     922    dl = length*(1.+fcl*2.)/(dpts-1)
     923    centerline[:,0] = np.arange(-length*fcl, length*(1. + fcl)+dl, dl)
     924
     925    # correct order of sections
     926    boatsecs = ['aportside', 'fportside', 'fstarboardside', 'astarboardside',        \
     927      'stern', 'centerline']
     928
     929    # dictionary with sections [polygon_vertices, line_type, line_color, line_width]
     930    dicboat = {'fportside': [fportside, '-', '#8A5900', 2.],                         \
     931      'aportside': [aportside, '-', '#8A5900', 2.],                                  \
     932      'stern': [stern, '-', '#8A5900', 2.],                                          \
     933      'astarboardside': [astarboardside, '-', '#8A5900', 2.],                        \
     934      'fstarboardside': [fstarboardside, '-', '#8A5900', 2.],                        \
     935      'centerline': [centerline, '-.', '#AA6464', 1.5]}
     936   
     937    fname = 'sailboat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) +      \
     938      '_lb' + str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) +'.dat'
     939    if not os.path.isfile(fname):
     940        print infmsg
     941        print '  ' + fname + ": writting boat coordinates file '" + fname + "' !!"
     942        of = open(fname, 'w')
     943        of.write('# boat file with Length: ' + str(length) +' max_beam: '+str(beam)+ \
     944          'length_at_max_beam:' + str(lbeam) + '% beam at stern: ' +str(sternbp)+'\n')
     945        for ip in range(dpts*5):
     946            of.write(str(boat[ip,0]) + ' ' + str(boat[ip,1]) + '\n')
     947       
     948        of.close()
     949        print fname + ": Successfull written '" + fname + "' !!"
     950 
     951    return boat, boatsecs, dicboat
    919952
    920953def zsailing_boat(length=10., beam=1., lbeam=0.4, sternbp=0.5, lmast=0.6, wmast=0.1, \
     
    941974    starboardside = np.array([0., beam*sternbp])
    942975
     976    aportside = circ_sec(portside, maxportside, length*2)
     977    fportside = circ_sec(maxportside, bow, length*2)
     978    fstarboardside = circ_sec(bow, maxstarboardside, length*2)
     979    astarboardside = circ_sec(maxstarboardside, starboardside, length*2)
     980    stern = circ_sec(starboardside, portside, length*2)
     981    dpts = fportside.shape[0]
     982
     983    # correct order of sections
     984    sailingboatsecs = ['aportside', 'fportside', 'fstarboardside', 'astarboardside', \
     985      'stern', 'mast', 'hsail', 'msail', 'centerline']
     986
    943987    # forward section
    944     fportside = circ_sec(bow,maxportside, length*2)
    945     fstarboardside = circ_sec(maxstarboardside, bow, length*2)
    946     dpts = fportside.shape[0]
    947988
    948989    # aft section
    949     aportside = circ_sec(maxportside, portside, length*2)
    950     astarboardside = circ_sec(starboardside, maxstarboardside, length*2)
    951990    # stern
    952     stern = circ_sec(portside, starboardside, length*2)
    953991    # mast
    954992    mast = p_circle(wmast,N=dpts)
     
    960998        endsail = np.array([lsail*np.sin(sailsa), lsail*np.cos(sailsa)])
    961999        endsail[0] = length - endsail[0]
    962         if bow[1] < endsail[1]:
     1000        if bow[1] > endsail[1]:
    9631001            hsail = circ_sec(endsail, bow, lsail*2.15)
    9641002        else:
     
    9781016        endsail = np.array([lsail*np.sin(sailsa), lsail*np.cos(sailsa)])
    9791017        endsail[0] = length*lmast - endsail[0]
    980         if endsail[1] < begsail[1]:
     1018        if endsail[1] > begsail[1]:
    9811019            msail = circ_sec(begsail, endsail, lsail*2.15)
    9821020        else:
     
    9911029    sailingboat = np.zeros((dpts*8+4,2), dtype=np.float)
    9921030
    993     sailingboat[0:dpts,:] = fportside
    994     sailingboat[dpts:2*dpts,:] = aportside
    995     sailingboat[2*dpts:3*dpts,:] = stern
     1031    sailingboat[0:dpts,:] = aportside
     1032    sailingboat[dpts:2*dpts,:] = fportside
     1033    sailingboat[2*dpts:3*dpts,:] = fstarboardside
    9961034    sailingboat[3*dpts:4*dpts,:] = astarboardside
    997     sailingboat[4*dpts:5*dpts,:] = fstarboardside
     1035    sailingboat[4*dpts:5*dpts,:] = stern
    9981036    sailingboat[5*dpts,:] = [gen.fillValueF, gen.fillValueF]
    9991037    sailingboat[5*dpts+1:6*dpts+1,:] = mast
     
    10121050    centerline[:,0] = np.arange(-length*fcl, length*(1. + fcl)+dl, dl)
    10131051
    1014     # correct order of sections
    1015     sailingboatsecs = ['fportside', 'aportside', 'stern', 'astarboardside',          \
    1016       'fstarboardside', 'mast', 'hsail', 'msail', 'centerline']
    10171052    # dictionary with sections [polygon_vertices, line_type, line_color, line_width]
    10181053    dicsailingboat = {'fportside': [fportside, '-', '#8A5900', 2.],                  \
Note: See TracChangeset for help on using the changeset viewer.