######################################################## # routines to set up, transform and manage advanced weather # Thorsten Renk, April 2012 ######################################################## # function purpose # # create_undulatus to create an undulating cloud pattern # create_cumulus_alleys to create an alley pattern of Cumulus clouds # create_layer to create a cloud layer with optional precipitation ########################################################### # place an undulatus pattern ########################################################### var create_undulatus = func (type, blat, blong, balt, alt_var, nx, xoffset, edgex, x_var, ny, yoffset, edgey, y_var, und_strength, direction, tri) { var flag = 0; var path = "Models/Weather/blank.ac"; local_weather.calc_geo(blat); var dir = direction * math.pi/180.0; var ymin = -0.5 * ny * yoffset; var xmin = -0.5 * nx * xoffset; var xinc = xoffset * (tri-1.0) /ny; var jlow = int(nx*edgex); var ilow = int(ny*edgey); var und = 0.0; var und_array = []; for (var i=0; i(nx-jlow-1))) and ((i(ny-ilow-1)))) # select a small or no cloud { if (rn > 2.0) {flag = 1;} else {path = select_cloud_model(type,"small");} } if ((j(nx-jlow-1)) or (i(ny-ilow-1))) { if (rn > 5.0) {flag = 1;} else {path = select_cloud_model(type,"small");} } else { # select a large cloud if (rn > 5.0) {flag = 1;} else {path = select_cloud_model(type,"large");} } if (flag==0){ if (thread_flag == 1) {create_cloud_vec(path, lat, long, alt, 0.0);} else {local_weather.create_cloud(path, lat, long, alt, 0.0);} } } } } ########################################################### # place a Cumulus alley pattern ########################################################### var create_cumulus_alleys = func (blat, blon, balt, alt_var, nx, xoffset, edgex, x_var, ny, yoffset, edgey, y_var, und_strength, direction, tri) { var flag = 0; var path = "Models/Weather/blank.ac"; local_weather.calc_geo(blat); var dir = direction * math.pi/180.0; var ymin = -0.5 * ny * yoffset; var xmin = -0.5 * nx * xoffset; var xinc = xoffset * (tri-1.0) /ny; var jlow = int(nx*edgex); var ilow = int(ny*edgey); var und = 0.0; var und_array = []; var spacing = 0.0; var spacing_array = []; for (var i=0; i(nx-jlow-1))) and ((i(ny-ilow-1)))) # select a small or no cloud { if (rn > 2.0) {flag = 1;} else {strength = 0.3 + rand() * 0.5;} } if ((j(nx-jlow-1)) or (i(ny-ilow-1))) { if (rn > 5.0) {flag = 1;} else {strength = 0.7 + rand() * 0.5;} } else { # select a large cloud if (rn > 5.0) {flag = 1;} else {strength = 1.1 + rand() * 0.6;} } if (flag==0){create_detailed_cumulus_cloud(lat, lon, alt, strength); } } } } ########################################################### # place a Cumulus alley pattern ########################################################### var create_developing_cumulus_alleys = func (blat, blon, balt, alt_var, nx, xoffset, edgex, x_var, ny, yoffset, edgey, y_var, und_strength, direction, tri) { var flag = 0; var path = "Models/Weather/blank.ac"; local_weather.calc_geo(blat); var dir = direction * math.pi/180.0; var ymin = -0.5 * ny * yoffset; var xmin = -0.5 * nx * xoffset; var xinc = xoffset * (tri-1.0) /ny; var jlow = int(nx*edgex); var ilow = int(ny*edgey); var und = 0.0; var und_array = []; var spacing = 0.0; var spacing_array = []; for (var i=0; i(nx-jlow-1))) and ((i(ny-ilow-1)))) # select a small or no cloud { if (rn > 2.0) {flag = 1;} else {strength = 0.1 + rand() * 0.5;} } if ((j(nx-jlow-1)) or (i(ny-ilow-1))) { if (rn > 5.0) {flag = 1;} else {strength = 0.4 + rand() * 0.5;} } else { # select a large cloud if (rn > 5.0) {flag = 1;} else {strength = 0.6 + rand() * 0.6;} } if (flag==0){create_detailed_cumulus_cloud(lat, lon, alt, strength); } } } } ########################################################### # place a cloud layer ########################################################### var create_layer = func (type, blat, blon, balt, bthick, rx, ry, phi, density, edge, rainflag, rain_density) { var i = 0; var area = math.pi * rx * ry; var circ = math.pi * (rx + ry); # that's just an approximation var n = int(area/80000000.0 * 100 * density); var m = int(circ/63000.0 * 40 * rain_density); var path = "Models/Weather/blank.ac"; #print("density: ",n); phi = phi * math.pi/180.0; if (contains(local_weather.cloud_vertical_size_map, type)) {var alt_offset = cloud_vertical_size_map[type]/2.0 * m_to_ft;} else {var alt_offset = 0.0;} while(i ((1.0 - edge) * (1.0- edge))) { if (rand() > 0.4) { path = select_cloud_model(type,"small"); if (thread_flag == 1) {create_cloud_vec(path, lat, lon, alt, 0.0);} else {compat_layer.create_cloud(path, lat, lon, alt, 0.0);} } } else { path = select_cloud_model(type,"large"); if (thread_flag == 1) {create_cloud_vec(path, lat, lon, alt, 0.0);} else {compat_layer.create_cloud(path, lat, lon, alt, 0.0);} } i = i + 1; } } i = 0; if (rainflag ==1){ if (local_weather.hardcoded_clouds_flag == 1) {balt = balt + local_weather.offset_map[type]; } while(i