Changeset 2544 in lmdz_wrf for trunk/tools
- Timestamp:
- May 18, 2019, 4:16:26 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/geometry_tools.py
r2534 r2544 16 16 import os 17 17 import generic_tools as gen 18 import numpy.ma as ma 18 19 19 20 errormsg = 'ERROR -- error -- ERROR -- error' … … 67 68 # plot_sphere: Function to plot an sphere and determine which standard lines will be 68 69 # also drawn 70 # [north/east/south/west_buoy1: Function to draw a [North/East/South/West] danger buoy using buoy1 69 71 70 72 def deg_deci(angle): … … 832 834 N: number of points (50, default) 833 835 """ 834 import numpy.ma as ma835 836 function = 'p_doubleArrow' 836 837 … … 885 886 N: number of points (100, default) 886 887 """ 887 fname = 'p_angle_triang e'888 fname = 'p_angle_triangle' 888 889 889 890 angle3 = 180. - angle1 - angle2 … … 1025 1026 lmains: length of main sail (as percentage of legnth, defaul 0.55) 1026 1027 """ 1027 import numpy.ma as ma1028 1028 fname = 'zsailing_boat' 1029 1029 … … 1156 1156 N: number of points (200, default) 1157 1157 """ 1158 import numpy.ma as ma1159 1158 fname = 'zisland1' 1160 1159 … … 1261 1260 N: number of points (300, default) 1262 1261 """ 1263 import numpy.ma as ma1264 1262 fname = 'band_lighthouse' 1265 1263 … … 1404 1402 return lighthouse, lighthousesecs, lighthousedic 1405 1403 1406 def north_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsi ngs=0.2, N=300):1404 def north_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.7, N=300): 1407 1405 """ Function to draw a North danger buoy using buoy1 1408 1406 height: height of the prism (5., default) … … 1410 1408 bradii: radii of the ball (1.75, default) 1411 1409 bfrac: fraction of the ball above the prism (0.8, default) 1412 his ngs: height of the sings [as reg. triangle] as percentage of the height1413 (0. 2, default)1410 hisgns: height of the signs [as reg. triangle] as percentage of the height 1411 (0.7, default) 1414 1412 N: total number of points of the buoy (300, default) 1415 1413 """ 1416 1414 fname = 'north_buoy1' 1417 1415 1418 Nbuoy = np.ones((N,2), dtype=np.float)*gen.fillValueF1416 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF 1419 1417 1420 1418 # buoy 1421 1419 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] = buoy1v1420 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=N2) 1421 buoy[0:N2,:] = buoy1v 1424 1422 1425 1423 # signs 1426 N3 = N - N2 - 1 1427 1424 N3 = N - N2 - 2 1425 1426 bottsigns = 2.*bradii+height 1428 1427 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 1450 def 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 1498 def 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 1546 def 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 1444 1593 1445 1594 ####### ####### ##### #### ### ## #
Note: See TracChangeset
for help on using the changeset viewer.