Changeset 2577 in lmdz_wrf
- Timestamp:
- Jun 1, 2019, 8:29:34 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/geometry_tools.py
r2576 r2577 837 837 dy[ic] = polygon[eep,0] - polygon[ip,0] 838 838 dd = xval - polygon[ip,1] 839 print 'Lluis ip', ip, 'poly:', polygon[ip,:], 'xval:', xval, 'ip+1', polygon[eep,:] 840 print ' dx:', dx, 'dy:', dy, 'dd', dd 839 841 ipt[ic,:] = [polygon[ip,0]+dy[ic]*dd/dx[ic], xval] 840 842 … … 861 863 862 864 for ic in range(2): 865 print ic, 'Lluis ipt:', ipt[ic,:], 'ept:', ept[ic,:] 863 866 dx = (ept[ic,1] - ipt[ic,1])/(Nadd2-2) 864 867 dy = (ept[ic,0] - ipt[ic,0])/(Nadd2-2) 868 print ' dx:', dx, 'dy', dy 865 869 cutlines[ic,0,:] = ipt[ic,:] 866 870 for ip in range(1,Nadd2-1): … … 1848 1852 iy = 0. 1849 1853 dx = 0. 1850 dy = height/(Np -1)1854 dy = height/(Np) 1851 1855 for ip in range(Np): 1852 1856 buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip] … … 1857 1861 ix = -width/2. 1858 1862 iy = height 1859 dx = (width/2.-bradii*bfrac)/(Np -1)1863 dx = (width/2.-bradii*bfrac)/(Np) 1860 1864 dy = 0. 1861 1865 for ip in range(Np): … … 1876 1880 iy = height 1877 1881 Np = N3 1878 dx = (width/2.-bradii*bfrac)/(Np -1)1882 dx = (width/2.-bradii*bfrac)/(Np) 1879 1883 dy = 0. 1880 1884 for ip in range(Np): … … 1887 1891 iy = height 1888 1892 dx = 0. 1889 dy = -height/(Np -1)1893 dy = -height/(Np) 1890 1894 for ip in range(Np): 1891 1895 buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip] … … 1896 1900 ix = width/2. 1897 1901 iy = 0. 1898 Np = N - int(2*N/3) - 4*N3 1899 dx = -width/(Np -1)1902 Np = N - int(2*N/3) - 4*N3 - 1 1903 dx = -width/(Np) 1900 1904 dy = 0. 1901 1905 for ip in range(Np): … … 1903 1907 NNp = NNp + Np 1904 1908 iip = NNp 1909 1910 buoy[N-1,:] = buoy[0,:] 1905 1911 1906 1912 buoysecs = ['base'] … … 2675 2681 return buoy, buoysecs, buoydic 2676 2682 2683 def emergency_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5, N=300): 2684 """ Function to draw an eergency mark buoy using buoy1 2685 height: height of the prism (5., default) 2686 width: width of the prism (10., default) 2687 bradii: radii of the ball (1.75, default) 2688 bfrac: fraction of the ball above the prism (0.8, default) 2689 hisgns: height of the signs [as reg. triangle] as percentage of the height 2690 (0.5, default) 2691 N: total number of points of the buoy (300, default) 2692 """ 2693 fname = 'emergency_buoy1' 2694 2695 buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF 2696 2697 # buoy 2698 N2 = int(N/2) 2699 buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75, \ 2700 bfrac=0.8, N=N2) 2701 buoy[0:N2,:] = buoy1v 2702 2703 Height = np.max(buoy1v[:,0]) 2704 2705 # sign 2706 N3 = N - N2 - 1 2707 2708 bottsigns = 2.*bradii+height 2709 lsign = height*hsigns 2710 # up 2711 cross, crosssecs, crossdic = p_cross_width(lsign, width=0.2*lsign, Narms=2, N=N3) 2712 buoy[N2+1:N,:] = cross + [Height+1.1*lsign,0.] 2713 2714 # painting it 2715 Ncut, quart1 = cut_xpolygon(buoy1v, xval=width/4., keep='left') 2716 Ncut, quart2 = cut_between_xpolygon(buoy1v, xval1=width/4., xval2=width/2) 2717 Ncut, quart3 = cut_between_xpolygon(buoy1v, xval1=width/2., xval2=width*3./4.) 2718 Ncut, quart4 = cut_xpolygon(buoy1v, xval=width*3./4., keep='right') 2719 2720 buoy = ma.masked_equal(buoy, gen.fillValueF) 2721 2722 buoysecs = ['buoy', 'sign'] 2723 buoydic = {'buoy': [buoy[0:N2,:],'-','#FFFF00',1.5], \ 2724 'sign': [buoy[N2+1:N,:],'-','#FFFF00',1.5],'quart1':[quart1,'-','#0000FF',1.5],\ 2725 'quart2': [quart2,'-','#FFFF00',1.5],'quart3': [quart3,'-','#0000FF',1.5], \ 2726 'quart4': [quart4,'-','#FFFF00',1.5]} 2727 2728 return buoy, buoysecs, buoydic 2729 2677 2730 ####### ####### ##### #### ### ## # 2678 2731 # Plotting
Note: See TracChangeset
for help on using the changeset viewer.