Changeset 2544 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
May 18, 2019, 4:16:26 PM (6 years ago)
Author:
lfita
Message:

Adding:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2534 r2544  
    1616import os
    1717import generic_tools as gen
     18import numpy.ma as ma
    1819
    1920errormsg = 'ERROR -- error -- ERROR -- error'
     
    6768# plot_sphere: Function to plot an sphere and determine which standard lines will be
    6869#   also drawn
     70# [north/east/south/west_buoy1: Function to draw a [North/East/South/West] danger buoy using buoy1
    6971
    7072def deg_deci(angle):
     
    832834      N: number of points (50, default)
    833835    """
    834     import numpy.ma as ma
    835836    function = 'p_doubleArrow'
    836837
     
    885886      N: number of points (100, default)
    886887    """
    887     fname = 'p_angle_triange'
     888    fname = 'p_angle_triangle'
    888889
    889890    angle3 = 180. - angle1 - angle2
     
    10251026      lmains: length of main sail (as percentage of legnth, defaul 0.55)
    10261027    """
    1027     import numpy.ma as ma
    10281028    fname = 'zsailing_boat'
    10291029
     
    11561156      N: number of points (200, default)
    11571157    """
    1158     import numpy.ma as ma
    11591158    fname = 'zisland1'
    11601159
     
    12611260      N: number of points (300, default)
    12621261    """
    1263     import numpy.ma as ma
    12641262    fname = 'band_lighthouse'
    12651263
     
    14041402    return lighthouse, lighthousesecs, lighthousedic
    14051403
    1406 def north_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsings=0.2, N=300):
     1404def north_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300):
    14071405    """ Function to draw a North danger buoy using buoy1
    14081406      height: height of the prism (5., default)
     
    14101408      bradii: radii of the ball (1.75, default)
    14111409      bfrac: fraction of the ball above the prism (0.8, default)
    1412       hisngs: height of the sings [as reg. triangle] as percentage of the height
    1413         (0.2, default)
     1410      hisgns: height of the signs [as reg. triangle] as percentage of the height
     1411        (0.7, default)
    14141412      N: total number of points of the buoy (300, default)
    14151413    """
    14161414    fname = 'north_buoy1'
    14171415
    1418     Nbuoy = np.ones((N,2), dtype=np.float)*gen.fillValueF
     1416    buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF
    14191417
    14201418    # buoy
    14211419    N2 = int(N/2)
    1422     buoy1v = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsings=0.2, N=N2)
    1423     Nbuoy[0:N2] = buoy1v
     1420    buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2)
     1421    buoy[0:N2,:] = buoy1v
    14241422
    14251423    # signs
    1426     N3 = N - N2 - 1
    1427 
     1424    N3 = N - N2 - 2
     1425   
     1426    bottsigns = 2.*bradii+height
    14281427    lsign = height*hsigns
    1429     # First up
    1430     N32 = N3 / 2
    1431     N323 = N32 / 3
    1432 
    1433     # left up arm
    1434     ix = -lsign/2.
    1435     iy = height
    1436     dx = -lsign/(2.*(N323-1))
    1437     dy = lsign*np.sin(np.pi/3.)/(N323-1)
    1438     for ip in range(N323):
    1439         Nbuoy[N2+1:N2+N323+1] = [iy + dy*ip, ix + dx*ip]
    1440 
    1441     Nbuoy = ma.masked_equal(Nbuoy, gen.fillValueF)
    1442 
    1443     return Nbuoy, Nbuoysecs, Nbuoydic
     1428    # up
     1429    N32 = int(N3/2)
     1430    triu = p_angle_triangle(N=N32)
     1431    trib = triu*lsign + [0.,-lsign/2.]
     1432
     1433    buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.1*lsign,0.]
     1434
     1435    # up
     1436    N323 = N - N32 - N2 - 2
     1437    trid = p_angle_triangle(N=N323)
     1438    trib = trid*lsign + [0.,-lsign/2.]
     1439    buoy[N2+N32+2:N,:] = trib + [bottsigns+1.1*lsign,0.]
     1440
     1441    buoy = ma.masked_equal(buoy, gen.fillValueF)
     1442
     1443    buoysecs = ['buoy', 'sign1', 'sign2']
     1444    buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5],                                   \
     1445      'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5],                                  \
     1446      'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5]}
     1447
     1448    return buoy, buoysecs, buoydic
     1449
     1450def east_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300):
     1451    """ Function to draw a East danger buoy using buoy1
     1452      height: height of the prism (5., default)
     1453      width: width of the prism (10., default)
     1454      bradii: radii of the ball (1.75, default)
     1455      bfrac: fraction of the ball above the prism (0.8, default)
     1456      hisgns: height of the signs [as reg. triangle] as percentage of the height
     1457        (0.7, default)
     1458      N: total number of points of the buoy (300, default)
     1459    """
     1460    fname = 'east_buoy1'
     1461
     1462    buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF
     1463
     1464    # buoy
     1465    N2 = int(N/2)
     1466    buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2)
     1467    buoy[0:N2,:] = buoy1v
     1468
     1469    # signs
     1470    N3 = N - N2 - 2
     1471   
     1472    bottsigns = 2.*bradii+height
     1473    lsign = height*hsigns
     1474    # up
     1475    N32 = int(N3/2)
     1476    triu = p_angle_triangle(N=N32)
     1477    trib = triu*lsign + [0.,-lsign/2.]
     1478
     1479    buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.1*lsign,0.]
     1480
     1481    # down
     1482    N323 = N - N32 - N2 - 2
     1483
     1484    trid = p_angle_triangle(N=N323)
     1485    trid = mirror_polygon(trid, 'x')
     1486    trib = trid*lsign + [lsign,-lsign/2.]
     1487    buoy[N2+N32+2:N,:] = trib + [bottsigns+0.9*lsign,0.]
     1488
     1489    buoy = ma.masked_equal(buoy, gen.fillValueF)
     1490
     1491    buoysecs = ['buoy', 'sign1', 'sign2']
     1492    buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5],                                   \
     1493      'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5],                                  \
     1494      'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5]}
     1495
     1496    return buoy, buoysecs, buoydic
     1497
     1498def south_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300):
     1499    """ Function to draw a South danger buoy using buoy1
     1500      height: height of the prism (5., default)
     1501      width: width of the prism (10., default)
     1502      bradii: radii of the ball (1.75, default)
     1503      bfrac: fraction of the ball above the prism (0.8, default)
     1504      hisgns: height of the signs [as reg. triangle] as percentage of the height
     1505        (0.7, default)
     1506      N: total number of points of the buoy (300, default)
     1507    """
     1508    fname = 'east_buoy1'
     1509
     1510    buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF
     1511
     1512    # buoy
     1513    N2 = int(N/2)
     1514    buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2)
     1515    buoy[0:N2,:] = buoy1v
     1516
     1517    # signs
     1518    N3 = N - N2 - 2
     1519   
     1520    bottsigns = 2.*bradii+height
     1521    lsign = height*hsigns
     1522    # up
     1523    N32 = int(N3/2)
     1524    trid = p_angle_triangle(N=N32)
     1525    trid = mirror_polygon(trid, 'x')
     1526    trib = trid*lsign + [0.,-lsign/2.]
     1527
     1528    buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+2.9*lsign,0.]
     1529
     1530    # down
     1531    N323 = N - N32 - N2 - 2
     1532    trid = p_angle_triangle(N=N323)
     1533    trid = mirror_polygon(trid, 'x')
     1534    trib = trid*lsign + [lsign,-lsign/2.]
     1535    buoy[N2+N32+2:N,:] = trib + [bottsigns+0.9*lsign,0.]
     1536
     1537    buoy = ma.masked_equal(buoy, gen.fillValueF)
     1538
     1539    buoysecs = ['buoy', 'sign1', 'sign2']
     1540    buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5],                                   \
     1541      'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5],                                  \
     1542      'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5]}
     1543
     1544    return buoy, buoysecs, buoydic
     1545
     1546def west_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300):
     1547    """ Function to draw a West danger buoy using buoy1
     1548      height: height of the prism (5., default)
     1549      width: width of the prism (10., default)
     1550      bradii: radii of the ball (1.75, default)
     1551      bfrac: fraction of the ball above the prism (0.8, default)
     1552      hisgns: height of the signs [as reg. triangle] as percentage of the height
     1553        (0.7, default)
     1554      N: total number of points of the buoy (300, default)
     1555    """
     1556    fname = 'east_buoy1'
     1557
     1558    buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF
     1559
     1560    # buoy
     1561    N2 = int(N/2)
     1562    buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2)
     1563    buoy[0:N2,:] = buoy1v
     1564
     1565    # signs
     1566    N3 = N - N2 - 2
     1567   
     1568    bottsigns = 2.*bradii+height
     1569    lsign = height*hsigns
     1570
     1571    # down
     1572    N32 = int(N3/2)
     1573    trid = p_angle_triangle(N=N32)
     1574    trid = mirror_polygon(trid, 'x')
     1575    trib = trid*lsign + [lsign,-lsign/2.]
     1576    buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+1.9*lsign,0.]
     1577
     1578    # up
     1579    N323 = N - N32 - N2 - 2
     1580    triu = p_angle_triangle(N=N323)
     1581    trib = triu*lsign + [0.,-lsign/2.]
     1582
     1583    buoy[N2+N323+2:N,:] = trib + [bottsigns+1.*lsign,0.]
     1584
     1585    buoy = ma.masked_equal(buoy, gen.fillValueF)
     1586
     1587    buoysecs = ['buoy', 'sign1', 'sign2']
     1588    buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5],                                   \
     1589      'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5],                                  \
     1590      'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5]}
     1591
     1592    return buoy, buoysecs, buoydic
    14441593
    14451594####### ####### ##### #### ### ## #
Note: See TracChangeset for help on using the changeset viewer.