WeatherField¶
-
class WeatherField¶
Bases:
TypedReferenceCountInheritance diagram
digraph inheritancee8cef33582 { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "ReferenceCount" [URL="acron.core.ReferenceCount.html#acron.core.ReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "ReferenceCount" [arrowsize=0.75,style=""]; "TypedObject" [URL="acron.core.TypedObject.html#acron.core.TypedObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "TypedObject" [arrowsize=0.75,style=""]; "TypedReferenceCount" [URL="acron.core.TypedReferenceCount.html#acron.core.TypedReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedObject" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; "ReferenceCount" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; "WeatherField" [URL="acron.atmosphere.WeatherField.html#acron.atmosphere.WeatherField",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top"]; "TypedReferenceCount" -> "WeatherField" [arrowsize=0.75,style=""]; }- WeatherField.__init__()¶
A field for the seed, packing maps of map_size^2 texels, starting on the “fair” preset.
- WeatherField.add_front()¶
A front crossing the tile: cold (a narrow line of strong uplift, cooler drier air behind) or warm (broad, gentle uplift ahead: stratiform cloud and rain; warmer moister air behind). It moves towards heading_deg (0 north, 90 east) at speed m/s relative to the air, from
distancemetres before the focus, with the given strength (0..2), for lifetime seconds (fading in and out). A front that leaves the tile comes round again (the tile repeats). Returns how many fronts there are.
- WeatherField.add_volume()¶
Voxel volumes.
A game’s own voxel cloud (in the air frame: it drifts with the wind).
density_at()and the sun’s column count it.
- WeatherField.air_to_world()¶
An air-frame point in the world: the image (the tile repeats) nearest the focus.
- WeatherField.clear_bolts()¶
- WeatherField.clear_fronts()¶
- WeatherField.clear_override()¶
Ends
set_override().
- WeatherField.clear_terrain()¶
- WeatherField.clear_volumes()¶
Removes the game’s volumes (the hero volumes stay; set_hero_count(0) ends those).
- WeatherField.cover_at()¶
The cloud cover (0..1) over the world point p, straight from the field.
- WeatherField.density_at()¶
The cloud density (0..1, before extinction) at a world point (metres), as the shader’s base density computes it from the last packed weather map and the base noise.
- WeatherField.fill_map()¶
Writes the weather map into tex (set up as map_size^2 RGBA8, repeating, linear, if it isn’t already): r cover, g type / 2 (0 stratus, 0.5 cumulus, 1 cumulonimbus), b base / 12 km, a top / 12 km. Texel (i, j) holds the air point ((i + 0.5), (j + 0.5)) x tile / map_size, so the shader samples it at air.xy / tile.
- WeatherField.fill_precipitation()¶
Writes the precipitation map into tex (like fill_map): r precipitation 0..1 at the ground (widened a texel round showers), g the share falling as snow, a 1.
- WeatherField.fill_sim_map()¶
The simulation’s fields into tex (set up as sim_size^2 RGBA32F, repeating, linear, like the weather map: texel (i, j) the air point ((i + 0.5), (j + 0.5)) x tile / sim_size): r relative humidity, g the temperature’s anomaly (K), b the uplift (m/s), a the stratiform and anvil cloud water. For debug views.
- WeatherField.get_base_noise_size()¶
- WeatherField.get_blend()¶
How far the last
set_preset()blend has got, 0..1.
- WeatherField.get_bolt()¶
A lightning bolt since the last clear_bolts(): (x, y, z world metres, strength 0..1). At most 64 are kept.
- WeatherField.get_cell()¶
Cell n: (x, y world metres, the image nearest the focus; its base and top metres above the sea).
- WeatherField.get_cell_id()¶
Cell n’s id (stable over its life; the hero volumes are keyed by it).
- WeatherField.get_cell_state()¶
Cell n’s state: (updraught m/s, how much of it exists 0..1, its anvil 0..1, its rain 0..1).
- static WeatherField.get_class_type()¶
- WeatherField.get_cloud_base()¶
Where cumulus bases sit (m): 1800 in dry air down to 650 in humid air.
- WeatherField.get_convection()¶
- WeatherField.get_extinction()¶
The clouds’ extinction per metre at density 1 (higher in storms).
- WeatherField.get_focus()¶
- WeatherField.get_fog()¶
- WeatherField.get_hero_count()¶
- WeatherField.get_hero_radius()¶
- WeatherField.get_hero_resolution()¶
- WeatherField.get_humidity()¶
The boundary layer’s relative humidity (0..1, a little more where it is supersaturated) under the world point.
- WeatherField.get_last_march_samples()¶
- WeatherField.get_layer_base()¶
- WeatherField.get_layer_offset()¶
The layers’ stretch compensation (metres), for the shader’s sxy = ap + lay * ((M - I) * ap + layer_offset), where ap = world.xy -
get_offset()and M stretches 0.6 alongget_wind_dir()and 1.3 across it. It is (0, 0) until the offset first wraps, so with it the formula is castaway’s mix(ap, M ap, lay); each wrap adds what keeps the layers from jumping. It is not wrapped (it grows by ~7 km a wrap).
- WeatherField.get_layer_top()¶
- WeatherField.get_light_dir()¶
- WeatherField.get_map_size()¶
- static WeatherField.get_max_height()¶
- WeatherField.get_moisture()¶
- WeatherField.get_noise_offset()¶
The base noise’s scroll (metres; the shader adds it to the sample point before dividing by the base tile): the noise rises 1.6 m/s, so the puffs boil.
- WeatherField.get_num_bolts()¶
- WeatherField.get_num_cells()¶
The convective cells (simulated, or the lattice’s).
How many convective cells there are now (the simulation’s, alive or fading; or the lattice’s live ones).
- WeatherField.get_num_fronts()¶
- WeatherField.get_num_volumes()¶
- WeatherField.get_offset()¶
The field’s drift (metres, wrapped into [0, tile)): air = world - offset.
- WeatherField.get_preset()¶
- WeatherField.get_seed()¶
- WeatherField.get_sim_size()¶
- WeatherField.get_sim_sources()¶
- WeatherField.get_sim_speed()¶
- static WeatherField.get_sim_step()¶
- WeatherField.get_sim_steps()¶
How many fixed steps the simulation has taken since it started over.
- WeatherField.get_snow()¶
- WeatherField.get_storm()¶
- WeatherField.get_stratus()¶
- WeatherField.get_temperature()¶
The air’s temperature (C) at the world point: the surface’s (the climate’s and the simulation’s anomaly) less the environment’s lapse rate with height.
- WeatherField.get_terrain_height()¶
The terrain’s height (m) at world (x, y) as
set_terrain()gave it.
- static WeatherField.get_tile()¶
- WeatherField.get_tile_m()¶
- WeatherField.get_time()¶
- WeatherField.get_uplift()¶
The vertical wind (m/s) at the world point: the boundary layer’s uplift (convergence, slopes, fronts) fading with height, and inside a cell’s updraught its speed.
- WeatherField.get_volume()¶
- WeatherField.get_volume_cell()¶
The id of the cell hero volume n was grown from (0 for a game’s).
- WeatherField.get_volume_weight()¶
How much volume n counts, 0..1 (a hero fades in as its cell leaves the map, and out again).
- WeatherField.get_water_source()¶
The water the climate has added (less taken) since the simulation started over:
get_water_total()minus it is what the processes conserve.
- WeatherField.get_water_total()¶
All the simulation’s water (water units: g/kg summed over its grid cells): vapour, cloud, rain, anvil ice, the ground’s, the cells’.
- WeatherField.get_wind()¶
The wind at the clouds, m/s in world space (x east, y north, z up); the field drifts with it.
- WeatherField.get_wind_dir()¶
The wind’s direction (unit, xy): layers are drawn out along it.
- static WeatherField.has_preset()¶
Whether a preset of this name exists: clear, fair, overcast, rain, storm, fog, snow, convective (scattered thunderstorms, nothing forced).
- WeatherField.is_hero_volume()¶
- WeatherField.is_simulated()¶
- WeatherField.march_density()¶
The integral of
density_at()(density x metres, before extinction) along the segment from world point p,lengthmetres along dir, sampled everystepmetres (at the steps’ middles). With skip the volumes’ signed distances skip the samples that lie provably outside every cloud (outside the layer’s slab and more than a voxel from every volume’s envelope): the march the renderer makes; without, every sample (brute force).get_last_march_samples()says how many were taken.
- WeatherField.optical_depth()¶
The optical depth of the cloud layer between the world point p and the light in the direction to_light: a 12-step march of
density_at()from p (or the layer’s base, whichever is higher) to the layer’s top, times the extinction. The light’s elevation is taken as at least asin(0.12) (~7 degrees); 0 above the layer or for a zero direction.
- WeatherField.precipitation_at()¶
The precipitation (0..1 at the ground: 0.1 drizzle, 0.4 a shower, 1 a downpour) under the world point p, straight from the field.
- WeatherField.remove_volume()¶
- WeatherField.sample()¶
The field over the world point (x, y): (cover 0..1, type 0..2, base m, top m).
- WeatherField.set_base_noise()¶
Shares the base noise volume the renderer samples (CloudNoise::make_base, any size, RGBA16 with its RAM image), so
density_at()reads the very same texels. Without one, a 64^3 base of the field’s seed is baked on first use (the same noise as a larger base of that seed, down-sampled).
- WeatherField.set_focus()¶
Where the forced looks of the clear, rain, snow and storm presets are exactly the preset’s (the player), world metres. Also where the storm level and the lightning are measured.
- WeatherField.set_hero_count()¶
How many of the deepest cells near the focus become hero volumes (voxelised cumulonimbus; 0, the default: none). Needs the simulation.
- WeatherField.set_hero_radius()¶
How far from the focus (m) a cell may be to become a hero volume.
- WeatherField.set_hero_resolution()¶
The hero volumes’ voxels (each 8..256; default 64^3).
- WeatherField.set_light_dir()¶
Towards the key light: the hero volumes’ self-shadow is swept for it (a few slices each
step()).
- WeatherField.set_override()¶
Forces parts of the field everywhere (the debug view, tests, a scripted sky): each value < 0 leaves that part alone. Heights are metres.
- WeatherField.set_preset()¶
Takes the weather towards a preset over
secondsofstep()time (0: at once). The blend starts from wherever the weather is now, so a new preset in the middle of a blend never jumps. Returns false for an unknown name.
- WeatherField.set_sim_size()¶
The simulation’s grid: n x n cells over the tile (8..256, default 64: 256 m). Starts it over.
- WeatherField.set_sim_sources()¶
Whether the climate feeds the boundary layer (vapour and warmth towards the preset’s targets: the sources and sinks). Off, the water is only moved about:
get_water_total()stays (the budget the tests check).
- WeatherField.set_sim_speed()¶
The simulation’s time scale: physics seconds per second of
step()(1: the real atmosphere’s pace, a storm towering in ~20 minutes; the default 6 tells a cell’s life in a few minutes, like the lattice’s).
- WeatherField.set_simulated()¶
The simulation.
The simulation.
Simulates the weather (the default) or, off, draws it from the lattice of scripted cells (castaway’s model, cheaper and fully procedural). On starts the simulation over in the current weather.
- WeatherField.set_terrain()¶
The ground’s heights for the uplift over slopes: a grey image (white
scalemetres) over the world rectangle (x0, y0, x1, y1; the image’s top row the north edge). Outside it the ground is flat.
- WeatherField.step()¶
Advances the weather by dt seconds: the cells’ lives, the blend towards the preset, the wind (it veers slowly about the seed’s prevailing direction) and the drift of the field with it. The packed maps are refreshed by the next
fill_map()/update_map(). A dt that is negative or not finite does nothing; one longer than an hour advances an hour (with a warning).
- WeatherField.sun_column()¶
The transmittance (0..1) of light from the direction to_light reaching the world point p through the cloud layer: exp(-optical_depth()), but thick cloud keeps a little diffuse light (multiple scattering): max(exp(-od), 0.35 exp(-0.2 od)).
- WeatherField.update_map()¶
Packs the field into the internal maps when it has changed since they were last packed.
fill_map()andfill_precipitation()do this themselves; call it when onlydensity_at()/sun_column()are used.
- WeatherField.volume_density()¶
The voxel volumes’ part of
density_at()at a world point.
- WeatherField.world_to_air()¶
A world point in the drifting frame: (x, y) -
get_offset(), z kept.