######################################################## # 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 an advanced undulatus pattern ########################################################### var create_adv_undulatus = func (arg) { var markov_array = []; var rnd_array = []; var max_num_clouds = int(arg.xsize/arg.cloud_spacing)+1; var max_num_streaks = int(arg.ysize/arg.undulatus_spacing)+1; var path = "Models/Weather/blank.ac"; var counter = 0; append(markov_array,0.0); var rn = 0.0; arg.dir = arg.dir + 90.0; for (var i=1; i 0.7) { flag = 1; path = select_cloud_model(arg.type,"large") } else if (comp > 0.4) { flag = 1; path = select_cloud_model(arg.type,"small") } var lat = arg.blat + m_to_lat * (y * math.cos(arg.dir) - x * math.sin(arg.dir)); var lon = arg.blon + m_to_lon * (x * math.cos(arg.dir) + y * math.sin(arg.dir)); var alt = arg.balt + arg.alt_var * 2 * (rand() - 0.5); if (flag > 0) {create_cloud_vec(path, lat, lon, alt, 0.0); counter = counter +1;} } } print("Cloud count: ",counter); } ########################################################### # place a stick bundle pattern ########################################################### var sgn = func (x) { if (x<0.0) {return -1.0;} else {return 1.0;} } var create_stick_bundle = func (arg) { var path = "Models/Weather/blank.ac"; var base_size_scale = local_weather.cloud_size_scale; 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