Changeset 2491 in lmdz_wrf


Ignore:
Timestamp:
May 1, 2019, 4:50:03 PM (6 years ago)
Author:
lfita
Message:

Adding as return values on `zsailing_boat':

  • Adding `centerline'
  • list with name of sections of the object
  • dictionary with the name of sections and: vertices of polygons, line type, line color and line width
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2486 r2491  
    641641
    642642    # forward section
    643     fportsaid = circ_sec(bow,maxportside, length*2)
    644     fstarboardsaid = circ_sec(maxstarboardside, bow, length*2)
     643    fportside = circ_sec(bow,maxportside, length*2)
     644    fstarboardside = circ_sec(maxstarboardside, bow, length*2)
    645645    # aft section
    646     aportsaid = circ_sec(maxportside, portside, length*2)
    647     astarboardsaid = circ_sec(starboardside, maxstarboardside, length*2)
     646    aportside = circ_sec(maxportside, portside, length*2)
     647    astarboardside = circ_sec(starboardside, maxstarboardside, length*2)
    648648    # stern
    649649    stern = circ_sec(portside, starboardside, length*2)
     
    652652    boat = np.zeros((dpts*5,2), dtype=np.float)
    653653
    654     boat[0:dpts,:] = fportsaid
    655     boat[dpts:2*dpts,:] = aportsaid
     654    boat[0:dpts,:] = fportside
     655    boat[dpts:2*dpts,:] = aportside
    656656    boat[2*dpts:3*dpts,:] = stern
    657     boat[3*dpts:4*dpts,:] = astarboardsaid
    658     boat[4*dpts:5*dpts,:] = fstarboardsaid
     657    boat[3*dpts:4*dpts,:] = astarboardside
     658    boat[4*dpts:5*dpts,:] = fstarboardside
    659659
    660660    fname = 'boat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) + '_lb' +  \
     
    699699
    700700    # forward section
    701     fportsaid = circ_sec(bow,maxportside, length*2)
    702     fstarboardsaid = circ_sec(maxstarboardside, bow, length*2)
    703     dpts = fportsaid.shape[0]
     701    fportside = circ_sec(bow,maxportside, length*2)
     702    fstarboardside = circ_sec(maxstarboardside, bow, length*2)
     703    dpts = fportside.shape[0]
    704704
    705705    # aft section
    706     aportsaid = circ_sec(maxportside, portside, length*2)
    707     astarboardsaid = circ_sec(starboardside, maxstarboardside, length*2)
     706    aportside = circ_sec(maxportside, portside, length*2)
     707    astarboardside = circ_sec(starboardside, maxstarboardside, length*2)
    708708    # stern
    709709    stern = circ_sec(portside, starboardside, length*2)
     
    734734    sailingboat = np.zeros((dpts*8+4,2), dtype=np.float)
    735735
    736     sailingboat[0:dpts,:] = fportsaid
    737     sailingboat[dpts:2*dpts,:] = aportsaid
     736    sailingboat[0:dpts,:] = fportside
     737    sailingboat[dpts:2*dpts,:] = aportside
    738738    sailingboat[2*dpts:3*dpts,:] = stern
    739     sailingboat[3*dpts:4*dpts,:] = astarboardsaid
    740     sailingboat[4*dpts:5*dpts,:] = fstarboardsaid
     739    sailingboat[3*dpts:4*dpts,:] = astarboardside
     740    sailingboat[4*dpts:5*dpts,:] = fstarboardside
    741741    sailingboat[5*dpts,:] = [gen.fillValueF, gen.fillValueF]
    742742    sailingboat[5*dpts+1:6*dpts+1,:] = mast
     
    749749    sailingboat = ma.masked_equal(sailingboat, gen.fillValueF)
    750750
     751    # Center line extending [fcl] percentage from length on aft and stern
     752    fcl = 0.15
     753    centerline = np.zeros((dpts,2), dtype=np.float)
     754    dl = length*(1.+fcl*2.)/(dpts-1)
     755    centerline[:,0] = np.arange(-length*fcl, length*(1. + fcl)+dl, dl)
     756
     757    # correct order of sections
     758    sailingboatsecs = ['fportside', 'aportside', 'stern', 'astarboardside',          \
     759      'fstarboardside', 'mast', 'hsail', 'msail', 'centerline']
     760    # dictionary with sections [polygon_vertices, line_type, line_color, line_width]
     761    dicsailingboat = {'fportside': [fportside, '-', '#8A5900', 2.],                  \
     762      'aportside': [aportside, '-', '#8A5900', 2.],                                  \
     763      'stern': [stern, '-', '#8A5900', 2.],                                          \
     764      'astarboardside': [astarboardside, '-', '#8A5900', 2.],                        \
     765      'fstarboardside': [fstarboardside, '-', '#8A5900', 2.],                        \
     766      'mast': [mast, '-', '#8A5900', 2.], 'hsail': [hsail, '-', '#AAAAAA', 1.],      \
     767      'msail': [msail, '-', '#AAAAAA', 1.],                                          \
     768      'centerline': [centerline, '-.', '#AA6464', 1.5]}
     769   
    751770    fname = 'sailboat_L' + str(int(length*100.)) + '_B' + str(int(beam*100.)) +      \
    752771      '_lb' + str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) +                \
     
    770789        print fname + ": Successfull written '" + fname + "' !!"
    771790 
    772     return sailingboat
     791    return sailingboat, sailingboatsecs, dicsailingboat
    773792
    774793def write_join_poly(polys, flname='join_polygons.dat'):
Note: See TracChangeset for help on using the changeset viewer.