Changeset 2527 in lmdz_wrf
- Timestamp:
- May 11, 2019, 5:46:54 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/geometry_tools.py
r2514 r2527 53 53 # p_spiral: Function to provide a polygon of an Archimedean spiral 54 54 # p_triangle: Function to provide the polygon of a triangle from its 3 vertices 55 # band_lighthouse: Function to plot a lighthouse with spiral bands 55 56 # surface_sphere: Function to provide an sphere as matrix of x,y,z coordinates 56 57 # z_boat: Function to define an schematic boat from the z-plane … … 1196 1197 return buoy, buoysecs, buoydic 1197 1198 1199 def band_lighthouse(height=10., width=2., hlight=3., bands=3, N=300): 1200 """ Function to plot a lighthouse with spiral bands 1201 height: height of the tower (10., default) 1202 width: width of the tower (2., default) 1203 hlight: height of the light (3., default) 1204 bands: number of spiral bands (3, default) 1205 N: number of points (300, default) 1206 """ 1207 import numpy.ma as ma 1208 fname = 'band_lighthouse' 1209 1210 lighthouse = np.ones((N,2), dtype=np.float)*gen.fillValueF 1211 lighthousesecs = [] 1212 lighthousedic = {} 1213 1214 # base Tower 1215 Nsec = int(0.30*N/7) 1216 p1=np.array([0., width/2.]) 1217 p2=np.array([0., -width/2.]) 1218 iip = 0 1219 lighthouse[0:Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) 1220 iip = iip + Nsec 1221 1222 # left side 1223 ix=-width/2. 1224 iy=0. 1225 dx = 0. 1226 dy = height/(Nsec-1) 1227 for ip in range(Nsec): 1228 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] 1229 iip = iip + Nsec 1230 1231 # Top Tower 1232 p1=np.array([height, width/2.]) 1233 p2=np.array([height, -width/2.]) 1234 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) 1235 iip = iip + Nsec 1236 1237 # right side 1238 ix=width/2. 1239 iy=height 1240 dx = 0. 1241 dy = -height/(Nsec-1) 1242 for ip in range(Nsec): 1243 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] 1244 iip = iip + Nsec + 1 1245 1246 Ntower = iip-1 1247 lighthousesecs = ['tower'] 1248 lighthousedic['tower'] = [lighthouse[0:iip-1], '-', 'k', 1.5] 1249 1250 # Left light 1251 p1 = np.array([height, -width/2.]) 1252 p2 = np.array([height+hlight, 0.]) 1253 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*hlight, Nang=Nsec) 1254 iip = iip + Nsec 1255 1256 # Right light 1257 p1 = np.array([height+hlight, 0.]) 1258 p2 = np.array([height, width/2.]) 1259 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*hlight, Nang=Nsec) 1260 iip = iip + Nsec 1261 1262 # Base Light 1263 p1=np.array([height, width/2.]) 1264 p2=np.array([height, -width/2.]) 1265 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) 1266 iip = iip + Nsec + 1 1267 lighthousesecs = ['light'] 1268 lighthousedic['light'] = [lighthouse[Ntower+1:iip-1], '-', '#AAAA00', 1.5] 1269 1270 # Spiral bands 1271 hb = height/(2.*bands) 1272 Nsec2 = (N - Nsec*7 - 3)/bands 1273 for ib in range(bands-1): 1274 iband = iip 1275 Nsec = Nsec2/4 1276 bandS = 'band' + str(ib).zfill(2) 1277 # hband 1278 ix = -width/2. 1279 iy = hb*ib*2 1280 dx = 0. 1281 dy = hb/(Nsec-1) 1282 for ip in range(Nsec): 1283 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] 1284 iip = iip + Nsec 1285 # uband 1286 p1 = np.array([hb*(ib*2+1), -width/2.]) 1287 p2 = np.array([hb*(ib*2+2), width/2.]) 1288 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='right', Nang=Nsec) 1289 iip = iip + Nsec 1290 # dband 1291 ix = width/2. 1292 iy = hb*(ib*2+2) 1293 dx = 0. 1294 dy = -hb/(Nsec-1) 1295 for ip in range(Nsec): 1296 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] 1297 iip = iip + Nsec 1298 # dband 1299 p1 = np.array([hb*(ib*2+1), width/2.]) 1300 p2 = np.array([hb*ib*2, -width/2.]) 1301 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) 1302 iip = iip + Nsec + 1 1303 lighthousesecs = [bandS] 1304 lighthousedic[bandS] = [lighthouse[iband:iip-1], '-', '#160016', 2.] 1305 1306 ib = bands-1 1307 Nsec3 = (N - iip - 1) 1308 Nsec = int(Nsec3/4) 1309 bandS = 'band' + str(ib).zfill(2) 1310 # hband 1311 iband = iip 1312 ix = -width/2. 1313 iy = hb*ib*2 1314 dx = 0. 1315 dy = hb/(Nsec-1) 1316 for ip in range(Nsec): 1317 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] 1318 iip = iip + Nsec 1319 # uband 1320 p1 = np.array([hb*(ib*2+1), -width/2.]) 1321 p2 = np.array([hb*(ib*2+2), width/2.]) 1322 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='right', Nang=Nsec) 1323 iip = iip + Nsec 1324 # dband 1325 ix = width/2. 1326 iy = hb*(2+ib*2) 1327 dx = 0. 1328 dy = -hb/(Nsec-1) 1329 for ip in range(Nsec): 1330 lighthouse[iip+ip,:] = [iy+dy*ip, ix+dx*ip] 1331 iip = iip + Nsec 1332 # dband 1333 Nsec = N - iip 1334 p1 = np.array([hb*(1+ib*2), width/2.]) 1335 p2 = np.array([hb*ib*2, -width/2.]) 1336 lighthouse[iip:iip+Nsec,:] = circ_sec(p1, p2, 3*width, pos='left', Nang=Nsec) 1337 lighthousesecs = [bandS] 1338 lighthousedic[bandS] = [lighthouse[iband:iip-1], '-', '#160016', 2.] 1339 1340 lighthouse = ma.masked_equal(lighthouse, gen.fillValueF) 1341 1342 return lighthouse, lighthousesecs, lighthousedic 1343 1198 1344 ####### ####### ##### #### ### ## # 1199 1345 # Plotting
Note: See TracChangeset
for help on using the changeset viewer.