A fallout simulator on the map: nuclear mode, targets, live winds aloft (#1007)
* A fallout model, checked against six Nevada tests
The local fallout of a surface burst lands where layered winds carry particles of every size
from the stabilized cloud. Cloud and particle sizes come from DNAF-1, WSEG-10 and DELFIC;
the air is the 1976 standard atmosphere. The six shots' wind profiles, measured contour
areas and plume bearings are in nts-shots.json with their sources, alongside HPAC's
predictions of the same contours.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A prototype fallout panel on the map
Right-click "Simulate Fallout Here" draws the dose rate at H+1 of one surface burst, in one
wind or in the winds aloft of one of the six Nevada tests. Nothing is saved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout lands where it meets the ground
A particle stops falling at the first level where it is at or below the ground under it, not
at a plane at the height of ground zero: early on a ridge in its way, later in a valley. The
map panel reads the ground from the terrain files the user has downloaded; the Nevada tests
are checked against a small elevation grid of Mapterhorn terrain, as WROLPi publishes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout falls from the cloud's cap, skirt and stem
The cloud of a surface burst holds 77.5% of its activity in the cap, 15% in a skirt below it
and 7.5% in the stem (Philippe et al.); the stem starts as narrow as the early fireball at the
ground and widens up to the cap (DNAF-1). More of the fallout lands near ground zero: a 1 Mt
burst now draws a 1000 R/hr contour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Close-in fallout measured after three Nevada surface bursts
Jangle Sugar, Small Boy and Johnie Boy, from DNAF-1's Table 3: the area, hotline length and
azimuth of each contour from 35 to 1000 R/hr, as observed and as DNAF-1, DELFIC and WSEG-10
predicted them, with each shot's winds. The deposition grid can look closely at part of the
fallout, and measures hotlines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout rises with the cloud, and heavy particles drop out low
All of the activity starts in the early fireball and rises with the cloud, whose base and top
climb with the square root of time (SIMFIC). Each particle rises with the air less its own
settling speed, so a heavy one leaves the cloud low and early and lands near ground zero, and a
light one rides to the top. A burst above the ground puts down less, by its scaled height.
Against the close-in fallout of Jangle Sugar and Small Boy this is within 2.4x in area and 1.7x
in hotline length (it was 100x short); across the six Nevada tests, 4.2x a priori (it was 8.9x).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel offers the weapons in service today
Weapons deployed or stockpiled by each country, each with its yield quoted from the 2025-2026
Nuclear Notebook or SIPRI Yearbook, and the improvised devices FEMA plans for; no retired or
historical weapons, and none whose yield no source gives. Variable-yield weapons have one entry
for each published setting. Fission shares are not public; they are assumed as Glasstone and
Dolan plan for, and the user may change them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's dropdowns open above it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A variable-yield weapon is named once, with each setting's yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel uses the forecast winds aloft
WROLPi fetches, on request, Open-Meteo's hourly forecast of the wind at nineteen pressure levels
(about 100 m to 24 km) and the rain, for the whole degree around the burst: the place is rounded
before it is sent. The forecast is kept, so the panel can use it offline. The panel picks the
hour nearest now, gives the forecast's age, and warns of rain, which brings fallout down in places
the map does not show.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A nuclear mode on the map: targets, and fallout
A radiation button under the print button turns nuclear mode on and off. In it, targets (likely
detonation sites) are shown alongside the pins, a pin added is saved as a target, and fallout can
be simulated at a target or anywhere on the map. A pin's kind is kept in map_pins.yaml; a pin
without one is a plain pin, as every pin was.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets keep their weapon, and nuclear mode shows the fallout of all of them
A target keeps the weapon chosen for it (or a yield of the user's own) and its fission share in
map_pins.yaml. Nuclear mode opens on the fallout of every saved target at once, in the forecast
winds aloft fetched most recently; a burst tried out from the map can be saved as a target.
A whole-degree latitude or longitude, which a browser sends as an integer, is a valid pin, and a
pin's label and color may be left out of an update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* An improvised device is named once, with each yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout of many targets is calculated in seconds, and shown as it goes
A particle size's settling speed is read from a table by altitude rather than solved again for
every fall of every burst (a burst: 40 ms to 6 ms). The view yields to the page only every 40 ms,
through a message channel, which a browser does not hold back in a hidden tab as it does timers;
it says how far it has got, and draws the fallout on flat ground while the terrain is read.
A target in the list shows its weapon, and is given a weapon picker when asked; one picker sets
every target's weapon.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout grid covers where fallout shows, not past the poles
The faintest particles of a burst are carried thousands of km in two days; with many targets the
grid stretched past 90 degrees and the map refused the image ("Invalid LngLat latitude"). The grid
now covers the spots which can reach the faintest band drawn, the image's corners stay within
Web Mercator's 85 degrees, and so does the area whose terrain is read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout across a continent is drawn where it lands
The map stretches an image evenly in Web Mercator between its corners, but the fallout grid's rows
are evenly apart in latitude; over tens of degrees (targets across a country) they part ways, and
the southern part of the image was drawn far from its targets. Each image row now takes the grid
row at its own latitude. A burst far from the first target keeps its plume as wide, east to west,
as at its own latitude.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Terrain across the antimeridian, and ground with no number, do not break the fallout
Targets in Alaska and Hawaii carry fallout west of 180 degrees, where the terrain's tile arithmetic
read past the tile's pixels; one sample with no number made every target's lowest ground NaN and
every spot fall off the map, and the grid's size Infinity. Longitudes wrap, a sample with no number
is left out (of the lowest ground, and of the elevation between samples), and a spot not on the map
is left out of the grid rather than breaking it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Every target's weapon is set in one change
Setting it target by target, eight at once, lost most of the changes: each request wrote the whole
pin list, undoing the others (QA: 47 of 156 changed). PUT /api/map/pins/targets/weapon gives
every target the weapon in one change of the config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The every-target weapon picker starts empty and always applies
It showed the first target's weapon, so choosing that weapon for all of them did nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout is carried by the winds where it is, region by region
A field of forecasts on a grid over the targets replaces the one forecast for
all of them. Each particle rises and falls through the wind at its place,
height and hour, read between the surrounding grid points, hours and heights.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The winds aloft are fetched as a Job, ninety places a minute
The free forecast service allows 600 calls a minute and a place costs six, so
a field of up to 540 points is fetched in paced batches by a Job, which the
fallout panel follows, instead of inside one request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A small burst's hot fallout is kept on a grid over many, and the panel says what it shows
- Each burst's narrow close-in fallout is also put on a fine grid, so the
lethal zone of a small target is not averaged away in the cells kilometers
wide of a grid over targets far apart.
- The legend says the dose rate is as at one hour, with all the fallout down,
and what R/hr is; the error quoted is the unscaled model's.
- The TNA's yield is 150 kt: its source gives only an upper bound below 300.
- Weapons show their fission share beside their yield.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout can be watched landing, hour by hour
A timeline under the legend plays, or steps through, the 48 hours after the
bursts: each hour shows only the fallout which has landed by then, at its
dose rate then (t^-1.2 from H+1), on the same cells as the whole of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The map can show the total dose of someone outdoors, hour by hour
A "Show" picker switches from the dose rate to the total dose (R) someone
outdoors gets from when the fallout arrives: t^-1.2 added up from each spot's
arrival to the hour on the timeline, or over the first two weeks. Its bands
say what each dose does to a person.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against the Army's fallout manuals
- FM 3-3-1's worked decay and dose problems are tests.
- FM 3-11.3's cloud and Zone I nomograms, read from their images, are a
fixture; the model's cloud top is within 10% of them from 1 kt to 10 Mt,
and its Zone I within 0.7-1.7 times from 10 kt to 1 Mt, the yields of
modern weapons, which the test shots do not reach.
- The legend says real fallout may decay faster or slower than usual.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against two megaton bursts in the Pacific
Redwing Zuni (3.5 Mt), whose winds were measured above its cloud: the hot
fallout goes where it went and about as far. Castle Bravo (15 Mt), whose
winds were measured only below its cloud: its fallout arrives when it did,
and its hot fallout reaching a third as far is kept in view as a known gap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Winds are read from the right points at every spacing, and cover the landing
- A field's points were filed by rounding (lat + 90) / spacing but looked up
by flooring it: at 4 and 8 degrees, which do not divide 90, every point read
half its neighbor's wind. Both now count whole spacings from the equator.
- The forecast starts at midnight UTC, so two days could end before the
fallout of a burst this hour was down; three are fetched (the same call
weight), and the panel says when the last hour's winds are held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bravo's known gap is not its unmeasured upper winds
Reanalysis winds above the 1954 sounding turn the plume to within 10 degrees
of the measured one but do not lengthen its hot contours; the fixture's caveat
and the test's explanation said otherwise, and now say what was found.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Rain takes fallout out of the air where it falls
A falling particle in rain loses a share of its activity every step: fast
inside the rain cloud ("rainout"), slower below it, by how hard it rains
("washout"), at Glasstone and Dolan's rates (Tables 9.74a and b), and none
above it. What is taken out comes down where the particle was. The forecast
now asks for relative humidity at 14 levels, and each hour's rain cloud is
taken as HYSPLIT takes it: from the lowest level 80% humid to the first above
it less than 60%.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* With no forecast, the fallout of 30 past days of the month
- wrolpi/scripts/build_fallout_climatology.py builds, from NOAA's reanalysis,
the winds aloft of 30 days of each month (one from each year 1991-2020) over
the whole world: a gzip file a month, about 4 MB, for the release download
location.
- WROLPi fetches the months it lacks once, while there is the Internet, each
checked against a sha256 pinned in modules/map/climatology.py (none pinned
until the files are published), and serves them to the panel.
- The panel's "Past days of a month" wind runs the bursts in each day and shows
on what share of the days each place had the chosen dose rate; it is chosen
for us when there is no forecast, or it has run out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology's months are published, and their sha256 pinned
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology worker waits for the Internet and the drive on startup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Counting the past days says flat ground at once, not the forecast's terrain
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout reuses each yield's paths, about 10 times faster
On flat ground in a day's held winds, how each parcel rises with the cloud
and falls does not depend on the wind, so it is worked out once per yield
and kept for every burst and day. The rising cloud is carried by the winds
over ground zero (it drifts about 10 km); the fall still reads the winds
where the particle is. A field of one hour is read without its hours, and
the nearest point to a cell past the field is kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rising cloud reads the winds over ground zero from arrays, by level
Each parcel's rise is kept as the levels of the column it passes through
(steps in the same level as one) and their seconds, so a burst reads the
column once and sums.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel shows a progress bar while it calculates
At the top of the panel, filled as far as the bursts are done, or moving
without a count until there is one. A calculation stopped by removing the
last target no longer leaves the panel busy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout runs in Web Workers, with a Cancel button
The days are spread over workers, one for each core but one (left for the
page), at most 6, and at most 2 where the browser says it has 2 GB or less.
A worker is given the next day as it finishes one, and sends back only the
cells reached. Where workers cannot be made, or fail, the days are
calculated on the page as before.
The days are counted on cells as wide as the coarsest day's grid, so the
count does not depend on which day finishes first.
Cancel, beside the progress bar, stops a calculation (and its workers) at
once; Calculate starts it again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's bursts are spread over Web Workers too
The workers now take any task: a past day, or a burst. The page and the
workers build each burst's winds and terrain with the same functions
(work.js), so the fallout is the same either way; the flat pass and the
terrain pass each run on their own workers, and Cancel stops them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The bursts' grid is made in parts by the Web Workers
The grid is a sum over the bursts' spots, sharpened by the most any burst
raises a cell, so it is made in a fixed number of parts (a burst's spots
in one) on one frame, and joined on the page. The page makes the same
parts when there are no workers, so the grid is the same either way.
The forecast's warnings (bursts outside the winds, rain) are no longer
worked out again on every progress update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's hours are labeled once an hour, not on every progress update
Writing each hour's label (toLocaleString) took most of the page's time
while the workers calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Faster forecast fallout: the nearest point outside the field, progress, and what workers are sent
- Outside the forecast's field, the nearest point is looked for only
among the points which can be nearest somewhere in the grid cell (kept
for each cell); the same point as looking through them all. Longitudes
are wrapped however far round the world a particle is carried.
- The progress is shown at most ten times a second.
- The workers are sent the forecast's arrays, not the forecast as fetched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel in steps: the targets, then the fallout hour by hour or in total
Nuclear mode opens on the targets; nothing is calculated until the user goes on.
The winds and terrain wait under Options, with what is used said beside it.
The timeline runs from the first hour to two weeks, saying how much the fallout
has weakened since H+1; the view of all the fallout as if landed at H+1 is gone.
Going back and on again with nothing changed draws what was calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's winds: the forecast, past days, or one wind; no test shots' winds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is a step of its own, between the targets and the fallout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel says it is an estimate; how it compares with the test bursts goes in the help
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets are tried out until saved; the saved ones are loaded first, and saved all at once
Nuclear mode starts with no targets. Targets added are tried out, and the saved
targets join them when the user loads them. Saving replaces the saved targets
with the list, in one change, and is refused until they were loaded (or there are
none), so none are lost unseen. A target can be taken out of the list. The
burst tried out from the map's menu is gone: a target tried out does the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Nuclear targets are kept in their own config, map_nuclear.yaml, and listed apart from the pins
The pins are plain pins again. The targets have their own endpoints, and their
own table on the Pins tab, where one can be deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rest of keeping nuclear targets in map_nuclear.yaml: the config, its endpoints, and the table
The commit before this one was missing these files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is the forecast when it has the winds until the fallout is down, else one wind
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The weather is a subscription: a forecast around the saved targets, downloaded every day
The Open-Meteo fetch is a recurring Download (daily) instead of a Job the panel
starts. The Manage tab has a Weather section: turning it on or off, what it
downloads, how its downloads went, and the forecast kept. Only the newest
forecast is kept, and it covers four days. The wind step asks the user to turn
the download on, and warns, there and beside the fallout, when the forecast runs
out before the fallout is down.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast service may take three minutes to answer, and a timeout says so
A batch of four days' forecasts took 43 seconds, near the old 60-second limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's targets step has an Add a target button: the next click on the map places it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:13 -07:00
|
|
|
import React, {useEffect, useMemo, useRef, useState} from "react";
|
|
|
|
|
import {Button, Checkbox, NumberInput, Progress, Select} from "./ui";
|
|
|
|
|
import {decayFromH1, doseGrid, landedGrid, profileFromTable} from "../map-shared/fallout/model.js";
|
|
|
|
|
import {loadTerrainGrid} from "./falloutTerrain";
|
|
|
|
|
import {formatYield, formatYieldAndFission, WEAPON_GROUPS} from "../map-shared/fallout/weapons.js";
|
|
|
|
|
import {
|
|
|
|
|
fieldCovers,
|
|
|
|
|
forecastAge,
|
|
|
|
|
forecastCoversFallout,
|
|
|
|
|
forecastExpired,
|
|
|
|
|
forecastRunsOut,
|
|
|
|
|
nearestHour,
|
|
|
|
|
prepareField,
|
|
|
|
|
rainNear,
|
|
|
|
|
} from "../map-shared/fallout/winds.js";
|
|
|
|
|
import {combineBursts, CUSTOM_WEAPON, targetWeapon} from "../map-shared/fallout/targets.js";
|
|
|
|
|
import {getFalloutClimatology, getFalloutClimatologyMonth, getLatestFalloutWinds} from "../api";
|
|
|
|
|
import {climateDay, dayCounter, gunzip, parseClimatology, reachedCells} from "../map-shared/fallout/climatology.js";
|
|
|
|
|
import {runPool, workerCount} from "../map-shared/fallout/pool.js";
|
|
|
|
|
import {makeFalloutWorker} from "../map-shared/fallout/falloutWorker.js";
|
|
|
|
|
import {burstSpots, burstsFrame, burstWinds, gridPart, gridParts, joinParts, portablePrepared} from "../map-shared/fallout/work.js";
|
|
|
|
|
import {downloadTime, useWeather} from "./MapWeather";
|
|
|
|
|
|
|
|
|
|
// The map's fallout view (nuclear mode), in steps: the targets (and how their fallout is carried),
|
|
|
|
|
// then the fallout of all the targets at once, saved or only tried out: hour by
|
|
|
|
|
// hour as it lands and weakens, or the total dose of the first two weeks.
|
|
|
|
|
|
|
|
|
|
const SOURCE = "fallout-dose";
|
|
|
|
|
const LAYER = "fallout-dose";
|
|
|
|
|
const METERS_PER_DEGREE = 111320;
|
|
|
|
|
|
|
|
|
|
// The dose-rate bands drawn (R/hr at H+1), from the highest.
|
|
|
|
|
export const DOSE_BANDS = [
|
|
|
|
|
{rate: 1000, color: [110, 0, 30]},
|
|
|
|
|
{rate: 100, color: [200, 20, 40]},
|
|
|
|
|
{rate: 10, color: [240, 110, 20]},
|
|
|
|
|
{rate: 1, color: [250, 200, 40]},
|
|
|
|
|
{rate: 0.1, color: [250, 240, 150]},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// The total dose bands drawn (R, outdoors), from the highest, with what such a dose, taken over
|
|
|
|
|
// days, does to a person [Glasstone and Dolan, Table 12.108].
|
|
|
|
|
export const TOTAL_BANDS = [
|
|
|
|
|
{rate: 1000, color: DOSE_BANDS[0].color, meaning: "nearly everyone dies"},
|
|
|
|
|
{rate: 450, color: DOSE_BANDS[1].color, meaning: "about half die without care"},
|
|
|
|
|
{rate: 100, color: DOSE_BANDS[2].color, meaning: "radiation sickness"},
|
|
|
|
|
{rate: 25, color: DOSE_BANDS[3].color, meaning: "no sickness; a higher cancer risk"},
|
|
|
|
|
{rate: 5, color: DOSE_BANDS[4].color, meaning: "a radiation worker's yearly limit"},
|
|
|
|
|
];
|
|
|
|
|
// What the map shows: the dose rate hour by hour, or the total dose of someone outdoors.
|
|
|
|
|
const RATE = "rate";
|
|
|
|
|
const TOTAL = "total";
|
|
|
|
|
// The total dose is over the first two weeks, when fallout does most of its harm.
|
|
|
|
|
const TWO_WEEKS = 336;
|
|
|
|
|
// The steps of the panel: the targets, the wind which carries their fallout, then what is shown.
|
|
|
|
|
// The first step is the nuclear button, which opens the panel.
|
|
|
|
|
const TARGETS = "targets";
|
|
|
|
|
const WIND = "wind";
|
|
|
|
|
const VIEW = "view";
|
|
|
|
|
|
|
|
|
|
// The weapons, grouped by country, then a yield of the user's own.
|
|
|
|
|
export const WEAPON_CHOICES = [
|
|
|
|
|
...WEAPON_GROUPS.map((g) => ({
|
|
|
|
|
group: g.name,
|
|
|
|
|
items: g.weapons.map((w) => ({value: w.key, label: `${w.name}, ${formatYieldAndFission(w.yield_kt, w.fission_fraction)}`})),
|
|
|
|
|
})),
|
|
|
|
|
{group: "Other", items: [{value: CUSTOM_WEAPON, label: "A yield of my own"}]},
|
|
|
|
|
];
|
|
|
|
|
// The panel floats over the map (z-index 1002); its dropdowns open above it.
|
|
|
|
|
const DROPDOWN = {zIndex: 1100};
|
|
|
|
|
const FORECAST = "forecast";
|
|
|
|
|
const MANUAL = "manual";
|
|
|
|
|
const WINDS = [
|
|
|
|
|
{value: FORECAST, label: "Forecast winds aloft"},
|
|
|
|
|
{value: MANUAL, label: "One wind at every height"},
|
|
|
|
|
];
|
|
|
|
|
// Winds of past days: the climatology, the share of a month's days fallout reached each place.
|
|
|
|
|
const CLIMATE = "climate";
|
|
|
|
|
const MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October",
|
|
|
|
|
"November", "December"];
|
|
|
|
|
// The shares of days drawn, from the most; the last is "any of the days".
|
|
|
|
|
export const CLIMATE_BANDS = [
|
|
|
|
|
{rate: 0.5, color: DOSE_BANDS[0].color, label: "half the days or more"},
|
|
|
|
|
{rate: 0.25, color: DOSE_BANDS[1].color, label: "a quarter of the days or more"},
|
|
|
|
|
{rate: 0.1, color: DOSE_BANDS[2].color, label: "a tenth of the days or more"},
|
|
|
|
|
{rate: 1e-6, color: DOSE_BANDS[4].color, label: "any of the days"},
|
|
|
|
|
];
|
|
|
|
|
// The dose rates (R/hr at H+1) a day may be counted at.
|
|
|
|
|
const CLIMATE_RATES = [1000, 100, 10, 1].map((r) => ({value: String(r), label: `${r}+ R/hr at H+1`}));
|
|
|
|
|
// The cells days are counted on are at least this wide (m), and each is shown as the average of
|
|
|
|
|
// itself and its neighbors this many cells around.
|
|
|
|
|
const CLIMATE_CELL = 4000;
|
|
|
|
|
const CLIMATE_SMOOTH = 1;
|
|
|
|
|
|
|
|
|
|
// The hours after the bursts the fallout can be watched in: landing in the first hours, then
|
|
|
|
|
// weakening over days and weeks. And how long each is shown (ms) when they play.
|
|
|
|
|
export const HOURS = [1, 2, 3, 6, 12, 24, 48, 72, 120, 168, 336];
|
|
|
|
|
const FRAME_MS = 900;
|
|
|
|
|
// Rain this heavy in the hours ahead (mm) is worth a warning.
|
|
|
|
|
const RAIN_WARNING_MM = 0.5;
|
|
|
|
|
|
|
|
|
|
// Web Mercator's y of `lat` (degrees), and back.
|
|
|
|
|
const mercatorY = (lat) => Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360));
|
|
|
|
|
const mercatorLat = (y) => (2 * Math.atan(Math.exp(y)) - Math.PI / 2) * 180 / Math.PI;
|
|
|
|
|
// The map takes no latitude past the poles' edge of the Web Mercator world.
|
|
|
|
|
const clampLat = (lat) => Math.min(Math.max(lat, -85), 85);
|
|
|
|
|
|
|
|
|
|
// The grid's row (from the south) under each of `height` image rows (from the top), for a grid
|
|
|
|
|
// around `lat`. The map stretches an image evenly in Web Mercator between its corners, but the
|
|
|
|
|
// grid's rows are evenly apart in latitude: over many degrees they part ways, so each image row
|
|
|
|
|
// takes the grid row at its own latitude.
|
|
|
|
|
export function imageRows(grid, lat, height) {
|
|
|
|
|
const north = clampLat(lat + (grid.y0 + grid.ny * grid.cell) / METERS_PER_DEGREE);
|
|
|
|
|
const south = clampLat(lat + grid.y0 / METERS_PER_DEGREE);
|
|
|
|
|
const top = mercatorY(north), bottom = mercatorY(south);
|
|
|
|
|
const rows = new Int32Array(height);
|
|
|
|
|
for (let r = 0; r < height; r++) {
|
|
|
|
|
const rowLat = mercatorLat(top + (r + 0.5) / height * (bottom - top));
|
|
|
|
|
const j = Math.floor(((rowLat - lat) * METERS_PER_DEGREE - grid.y0) / grid.cell);
|
|
|
|
|
rows[r] = Math.min(Math.max(j, 0), grid.ny - 1);
|
|
|
|
|
}
|
|
|
|
|
return rows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The grid as an image for a map, around `lat`: each cell colored by the highest band it reaches,
|
|
|
|
|
// transparent below them.
|
|
|
|
|
export function gridImage(grid, lat, bands = DOSE_BANDS) {
|
|
|
|
|
const canvas = document.createElement("canvas");
|
|
|
|
|
canvas.width = grid.nx;
|
|
|
|
|
canvas.height = grid.ny;
|
|
|
|
|
const context = canvas.getContext("2d");
|
|
|
|
|
const image = context.createImageData(grid.nx, grid.ny);
|
|
|
|
|
const rows = imageRows(grid, lat, grid.ny);
|
|
|
|
|
for (let r = 0; r < grid.ny; r++) {
|
|
|
|
|
const from = rows[r] * grid.nx, to = r * grid.nx;
|
|
|
|
|
for (let i = 0; i < grid.nx; i++) {
|
|
|
|
|
const band = bands.find((b) => grid.values[from + i] >= b.rate);
|
|
|
|
|
if (!band) continue;
|
|
|
|
|
const p = (to + i) * 4;
|
|
|
|
|
image.data[p] = band.color[0];
|
|
|
|
|
image.data[p + 1] = band.color[1];
|
|
|
|
|
image.data[p + 2] = band.color[2];
|
|
|
|
|
image.data[p + 3] = 255;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
context.putImageData(image, 0, 0);
|
|
|
|
|
return canvas.toDataURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The corners of the grid (top-left, top-right, bottom-right, bottom-left) as [lon, lat], around
|
|
|
|
|
// `lon`, `lat`.
|
|
|
|
|
export function gridCorners(grid, lon, lat) {
|
|
|
|
|
const toLon = (x) => lon + x / (METERS_PER_DEGREE * Math.cos(lat * Math.PI / 180));
|
|
|
|
|
const toLat = (y) => clampLat(lat + y / METERS_PER_DEGREE);
|
|
|
|
|
const west = toLon(grid.x0), east = toLon(grid.x0 + grid.nx * grid.cell);
|
|
|
|
|
const south = toLat(grid.y0), north = toLat(grid.y0 + grid.ny * grid.cell);
|
|
|
|
|
return [[west, north], [east, north], [east, south], [west, south]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The image of the fallout `ran` ({grid, spots, origin}) as shown: the dose rate `after` hours after
|
|
|
|
|
// the bursts, of the fallout landed by then; or the total dose outdoors in the first two weeks.
|
|
|
|
|
export function frameOf(ran, show, after) {
|
|
|
|
|
const grid = show === TOTAL ? doseGrid(ran.spots, ran.grid, TWO_WEEKS) : landedGrid(ran.spots, ran.grid, after);
|
|
|
|
|
const url = gridImage(grid, ran.origin.lat, show === TOTAL ? TOTAL_BANDS : DOSE_BANDS);
|
|
|
|
|
return {url, coordinates: gridCorners(grid, ran.origin.lon, ran.origin.lat)};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The wind profile the model takes, for a wind not of the forecast: one wind at every height (also
|
|
|
|
|
// while there is no forecast).
|
|
|
|
|
export function windProfile({direction, speed}) {
|
|
|
|
|
return profileFromTable([[0, direction, speed]], 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The area ([west, south, east, north], degrees) where the grid reaches the lowest band, with a margin.
|
|
|
|
|
export function plumeBounds(grid, lon, lat) {
|
|
|
|
|
const lowest = DOSE_BANDS[DOSE_BANDS.length - 1].rate;
|
|
|
|
|
let x0 = 0, x1 = 0, y0 = 0, y1 = 0;
|
|
|
|
|
for (let j = 0; j < grid.ny; j++) {
|
|
|
|
|
for (let i = 0; i < grid.nx; i++) {
|
|
|
|
|
if (grid.values[j * grid.nx + i] < lowest) continue;
|
|
|
|
|
const x = grid.x0 + (i + 0.5) * grid.cell, y = grid.y0 + (j + 0.5) * grid.cell;
|
|
|
|
|
x0 = Math.min(x0, x); x1 = Math.max(x1, x); y0 = Math.min(y0, y); y1 = Math.max(y1, y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const margin = Math.max(0.25 * Math.max(x1 - x0, y1 - y0), 20000);
|
|
|
|
|
const perLon = METERS_PER_DEGREE * Math.cos(lat * Math.PI / 180);
|
|
|
|
|
return [lon + (x0 - margin) / perLon, lat + (y0 - margin) / METERS_PER_DEGREE,
|
|
|
|
|
lon + (x1 + margin) / perLon, lat + (y1 + margin) / METERS_PER_DEGREE];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A forecast hour as the user reads it: the day and time where they are.
|
|
|
|
|
export function hourLabel(time, nearest) {
|
|
|
|
|
const label = new Date(time).toLocaleString(undefined, {weekday: "short", hour: "numeric", minute: "2-digit"});
|
|
|
|
|
return nearest ? `${label} (now)` : label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// How often the progress is shown, at most (ms): each time redraws the panel.
|
|
|
|
|
const PROGRESS_MS = 100;
|
|
|
|
|
|
|
|
|
|
// `report(done, total)`, called at most every PROGRESS_MS, but always when all is done.
|
|
|
|
|
export function everySoOften(report) {
|
|
|
|
|
let last = -Infinity;
|
|
|
|
|
return (done, total) => {
|
|
|
|
|
const now = Date.now();
|
|
|
|
|
if (done < total && now - last < PROGRESS_MS) return;
|
|
|
|
|
last = now;
|
|
|
|
|
report(done, total);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Let the page draw and answer the user when the model has had the thread for a while. A message
|
|
|
|
|
// channel, not a timer: a browser holds a hidden tab's timers back to one a second.
|
|
|
|
|
const SLICE_MS = 40;
|
|
|
|
|
function yielder() {
|
|
|
|
|
let since = performance.now();
|
|
|
|
|
return async () => {
|
|
|
|
|
if (performance.now() - since < SLICE_MS) return;
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
|
if (typeof MessageChannel === "undefined") {
|
|
|
|
|
setTimeout(resolve, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const channel = new MessageChannel();
|
|
|
|
|
channel.port1.onmessage = () => resolve();
|
|
|
|
|
channel.port2.postMessage(null);
|
|
|
|
|
});
|
|
|
|
|
since = performance.now();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The fallout of `bursts` ([{lat, lon, yieldKt, fissionFraction}]) on one grid around the first:
|
|
|
|
|
// {grid, spots (as combineBursts gives them, for the fallout hour by hour), origin, terrainStatus}.
|
|
|
|
|
// `winds` are the winds over them, as burstWinds takes them. The bursts are spread over `workers`
|
|
|
|
|
// workers (on the page, without them, or if they fail). `onProgress(done, total)` hears how far it
|
|
|
|
|
// has got, `onFlat({grid, spots, origin})` gets the fallout on flat ground while the terrain is read, and it stops
|
|
|
|
|
// (null) once `signal` (an AbortSignal) is aborted or `cancelled()`.
|
|
|
|
|
export async function simulateBursts(bursts, {winds, useTerrain = true, workers = 0, signal = null,
|
|
|
|
|
cancelled = () => false, onProgress = () => null, onFlat = () => null, makeWorker = makeFalloutWorker}) {
|
|
|
|
|
const stopped = () => cancelled() || !!signal?.aborted;
|
|
|
|
|
const origin = bursts[0];
|
|
|
|
|
const {windsFor, groundOf} = burstWinds(winds);
|
|
|
|
|
const total = useTerrain ? bursts.length * 2 : bursts.length;
|
|
|
|
|
// The bursts before this pass's, of the progress.
|
|
|
|
|
let before = 0;
|
|
|
|
|
const plain = bursts.map(({lat, lon, yieldKt, fissionFraction}) => ({lat, lon, yieldKt, fissionFraction}));
|
|
|
|
|
// The bursts' spots, by the workers: null once stopped, undefined if they cannot.
|
|
|
|
|
const spread = async (terrain) => {
|
|
|
|
|
if (workers <= 0) return undefined;
|
|
|
|
|
try {
|
|
|
|
|
return await runPool({
|
|
|
|
|
tasks: bursts.length, total, count: workers, makeWorker, signal,
|
|
|
|
|
start: {kind: 'bursts', bursts: plain, prepared: portablePrepared(winds.prepared),
|
|
|
|
|
startMs: winds.startMs || 0, profile: winds.profile || null, terrain},
|
|
|
|
|
onProgress: (done) => onProgress(before + done, total),
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Fallout: the workers failed; calculating on the page", e);
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const here = async (terrain) => {
|
|
|
|
|
const pause = yielder();
|
|
|
|
|
const found = [];
|
|
|
|
|
for (const b of bursts) {
|
|
|
|
|
found.push(burstSpots(b, {windsFor, groundOf, terrain}));
|
|
|
|
|
onProgress(before + found.length, total);
|
|
|
|
|
await pause();
|
|
|
|
|
if (stopped()) return null;
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
};
|
|
|
|
|
// The grid of the bursts' `spots`, its parts made by the workers (or here): null once stopped.
|
|
|
|
|
const gridOf = async (spots) => {
|
|
|
|
|
const frame = burstsFrame(spots, DOSE_BANDS[DOSE_BANDS.length - 1].rate);
|
|
|
|
|
const parts = gridParts(spots);
|
|
|
|
|
let made;
|
|
|
|
|
if (workers > 0) {
|
|
|
|
|
try {
|
|
|
|
|
made = await runPool({
|
|
|
|
|
tasks: parts.length, total: parts.length, count: workers, makeWorker, signal,
|
|
|
|
|
start: {kind: 'grid', frame}, payload: (k) => ({spots: parts[k]}),
|
|
|
|
|
});
|
|
|
|
|
if (!made) return null;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Fallout: the workers failed; calculating on the page", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!made) {
|
|
|
|
|
const pause = yielder();
|
|
|
|
|
made = [];
|
|
|
|
|
for (const part of parts) {
|
|
|
|
|
made.push(gridPart(frame, part));
|
|
|
|
|
await pause();
|
|
|
|
|
if (stopped()) return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return joinParts(frame, made);
|
|
|
|
|
};
|
|
|
|
|
const run = async (terrain) => {
|
|
|
|
|
if (stopped()) return null;
|
|
|
|
|
let found = await spread(terrain);
|
|
|
|
|
if (found === null) return null;
|
|
|
|
|
if (!found) found = await here(terrain);
|
|
|
|
|
if (!found || stopped()) return null;
|
|
|
|
|
before += bursts.length;
|
|
|
|
|
const runs = bursts.map((b, i) => ({burst: b, spots: found[i].spots, yieldKt: b.yieldKt,
|
|
|
|
|
fissionFraction: b.fissionFraction}));
|
|
|
|
|
const offMap = bursts.filter((b, i) => found[i].offMap);
|
|
|
|
|
if (offMap.length) console.warn(`Fallout: some spots of ${offMap.length} bursts were not on the map`, offMap);
|
|
|
|
|
const spots = combineBursts(origin, runs);
|
|
|
|
|
const grid = await gridOf(spots);
|
|
|
|
|
if (!grid || stopped()) return null;
|
|
|
|
|
return {grid, spots};
|
|
|
|
|
};
|
|
|
|
|
// On flat ground first: that is where the plumes are, so the terrain under them can be read.
|
|
|
|
|
let ran = await run(null);
|
|
|
|
|
if (!ran) return null;
|
|
|
|
|
let terrainStatus = "Flat ground (terrain is off).";
|
|
|
|
|
if (useTerrain) {
|
|
|
|
|
onFlat({...ran, origin});
|
|
|
|
|
let loaded = null;
|
|
|
|
|
try {
|
|
|
|
|
loaded = await loadTerrainGrid(plumeBounds(ran.grid, origin.lon, origin.lat), origin.lon, origin.lat);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Could not read the terrain", e);
|
|
|
|
|
}
|
|
|
|
|
if (stopped()) return null;
|
|
|
|
|
if (loaded) {
|
|
|
|
|
ran = await run(loaded.grid);
|
|
|
|
|
if (!ran) return null;
|
|
|
|
|
const covered = Math.round(loaded.coverage * 100);
|
|
|
|
|
terrainStatus = `Follows the terrain (zoom ${loaded.zoom}${covered < 100 ? `, ${covered}% of the area` : ""}).`;
|
|
|
|
|
} else {
|
|
|
|
|
terrainStatus = "No terrain file covers this place: flat ground.";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return {grid: ran.grid, spots: ran.spots, origin, terrainStatus};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The fallout of `bursts` in each day of `clim` (as parseClimatology gives it): on what share of the
|
|
|
|
|
// days each place had `rate` R/hr at H+1 or more, as a grid ({x0, y0, cell, nx, ny, values (0..1),
|
|
|
|
|
// days}) around the first burst, smoothed; and that burst ({grid, origin}). On flat ground at sea
|
|
|
|
|
// level: the days' winds are read by height above the sea. The days are spread over `workers`
|
|
|
|
|
// workers (on the page, without them, or if they fail); null once `signal` (an AbortSignal) is
|
|
|
|
|
// aborted or `cancelled()`.
|
|
|
|
|
export async function simulateClimate(bursts, clim, {rate = 1, workers = 0, signal = null, cancelled = () => false,
|
|
|
|
|
onProgress = () => null, makeWorker = makeFalloutWorker} = {}) {
|
|
|
|
|
const stopped = () => cancelled() || !!signal?.aborted;
|
|
|
|
|
if (stopped()) return null;
|
|
|
|
|
let days = null;
|
|
|
|
|
if (workers > 0) {
|
|
|
|
|
try {
|
|
|
|
|
const plain = bursts.map(({lat, lon, yieldKt, fissionFraction}) => ({lat, lon, yieldKt, fissionFraction}));
|
|
|
|
|
days = await runPool({
|
|
|
|
|
tasks: clim.days, total: clim.days * bursts.length, count: workers, makeWorker, signal, onProgress,
|
|
|
|
|
start: {kind: 'days', bytes: clim.bytes, bursts: plain, rate},
|
|
|
|
|
});
|
|
|
|
|
if (!days) return null;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Fallout: the workers failed; calculating on the page", e);
|
|
|
|
|
days = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!days) {
|
|
|
|
|
days = [];
|
|
|
|
|
const pause = yielder();
|
|
|
|
|
let done = 0;
|
|
|
|
|
const total = clim.days * bursts.length;
|
|
|
|
|
const onBurst = async () => {
|
|
|
|
|
onProgress(++done, total);
|
|
|
|
|
await pause();
|
|
|
|
|
};
|
|
|
|
|
for (let k = 0; k < clim.days; k++) {
|
|
|
|
|
const grid = await climateDay(clim, k, bursts, {stopped, onBurst});
|
|
|
|
|
if (!grid || stopped()) return null;
|
|
|
|
|
days.push(reachedCells(grid, rate));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (stopped()) return null;
|
|
|
|
|
// Counted on cells as wide as the coarsest day's: a finer count would leave holes between its cells.
|
|
|
|
|
const counter = dayCounter(rate, Math.max(CLIMATE_CELL, ...days.map((d) => d.cell)));
|
|
|
|
|
for (const day of days) counter.add(day);
|
|
|
|
|
return {grid: counter.grid(CLIMATE_SMOOTH), origin: bursts[0]};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A weapon to burst with: one of those offered, or a yield of one's own. `value` and onChange's
|
|
|
|
|
// argument are {weapon, yield_kt?, fission_fraction?}, as a target keeps them.
|
|
|
|
|
export function WeaponPicker({value, onChange, label}) {
|
|
|
|
|
const chosen = targetWeapon(value);
|
|
|
|
|
const [customYield, setCustomYield] = useState(chosen.yieldKt);
|
|
|
|
|
const [customFission, setCustomFission] = useState(Math.round(chosen.fissionFraction * 100));
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setCustomYield(chosen.yieldKt);
|
|
|
|
|
setCustomFission(Math.round(chosen.fissionFraction * 100));
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [value?.weapon, value?.yield_kt, value?.fission_fraction]);
|
|
|
|
|
const choose = (key) => {
|
|
|
|
|
if (!key || key === chosen.key) return;
|
|
|
|
|
if (key === CUSTOM_WEAPON) {
|
|
|
|
|
onChange({weapon: key, yield_kt: chosen.yieldKt, fission_fraction: chosen.fissionFraction});
|
|
|
|
|
} else {
|
|
|
|
|
onChange({weapon: key, fission_fraction: targetWeapon({weapon: key}).fissionFraction});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// A yield of one's own is kept when the user has finished typing it.
|
|
|
|
|
const keepCustom = () => {
|
|
|
|
|
const kt = Number(customYield), fission = Number(customFission) / 100;
|
|
|
|
|
if (!(kt > 0) || !(fission > 0 && fission <= 1)) return;
|
|
|
|
|
if (kt === chosen.yieldKt && fission === chosen.fissionFraction) return;
|
|
|
|
|
onChange({weapon: CUSTOM_WEAPON, yield_kt: kt, fission_fraction: fission});
|
|
|
|
|
};
|
|
|
|
|
return <div>
|
|
|
|
|
<Select label={label} size="xs" data={WEAPON_CHOICES} value={chosen.key} onChange={choose} searchable
|
|
|
|
|
allowDeselect={false} maxDropdownHeight={320} comboboxProps={DROPDOWN} aria-label="Weapon"/>
|
|
|
|
|
{chosen.weapon && chosen.weapon.yield_range_kt && <div style={{color: "var(--muted)", fontSize: "0.75rem"}}>
|
|
|
|
|
Estimates range from {formatYield(chosen.weapon.yield_range_kt[0])} to{" "}
|
|
|
|
|
{formatYield(chosen.weapon.yield_range_kt[1])}.
|
|
|
|
|
</div>}
|
|
|
|
|
{!chosen.weapon && <div style={{display: "flex", gap: "0.5rem"}}>
|
|
|
|
|
<NumberInput label="Yield (kt)" size="xs" min={0.01} max={100000} value={customYield}
|
|
|
|
|
onChange={setCustomYield} onBlur={keepCustom}/>
|
|
|
|
|
<NumberInput label="Fission (%)" size="xs" min={1} max={100} value={customFission}
|
|
|
|
|
onChange={setCustomFission} onBlur={keepCustom}/>
|
|
|
|
|
</div>}
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The targets simulated once the saved targets (`saved`, pins) are loaded: those, then the ones
|
|
|
|
|
// being tried out (`tried`) which are not saved.
|
|
|
|
|
export function withSavedTargets(saved, tried) {
|
|
|
|
|
return [...saved.map((t) => ({...t, key: `saved-${t.id}`})), ...tried.filter((t) => !t.id)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Whether the targets simulated differ from the saved ones (`saved`), which were loaded or not.
|
|
|
|
|
export function targetsUnsaved(targets, saved, loaded) {
|
|
|
|
|
if (!loaded) return targets.length > 0;
|
|
|
|
|
const plain = (list) => JSON.stringify(list.map((t) => [t.id, t.lat, t.lon, t.label, t.weapon, t.yield_kt,
|
|
|
|
|
t.fission_fraction]));
|
|
|
|
|
return plain(targets) !== plain(saved);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A target with `weapon` ({weapon, yield_kt?, fission_fraction?}) in place of its old one.
|
|
|
|
|
export function withWeapon(target, weapon) {
|
|
|
|
|
const {weapon: _weapon, yield_kt: _yield, fission_fraction: _fission, ...rest} = target;
|
|
|
|
|
return {...rest, ...weapon};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A button which reads as a link, for small actions beside a target.
|
|
|
|
|
const LINK = {background: "none", border: "none", padding: 0, color: "var(--link, #4183c4)", cursor: "pointer",
|
|
|
|
|
font: "inherit"};
|
|
|
|
|
|
|
|
|
|
// A target in the list: its name and weapon (and whether it is saved), the weapon picker when the
|
|
|
|
|
// user asks to change it, and taking it out of the list.
|
|
|
|
|
function TargetRow({target, onWeapon, onRemove}) {
|
|
|
|
|
const [changing, setChanging] = useState(false);
|
|
|
|
|
const chosen = targetWeapon(target);
|
|
|
|
|
const muted = {color: "var(--muted)", fontSize: "0.75rem"};
|
|
|
|
|
return <div style={{marginBottom: "0.375rem"}}>
|
|
|
|
|
<div><span aria-hidden>☢ </span><strong>{target.label}</strong>
|
|
|
|
|
{!target.id && <span style={muted}> (not saved)</span>}</div>
|
|
|
|
|
<div style={muted}>
|
|
|
|
|
{chosen.weapon ? chosen.weapon.name : "A yield of my own"},{" "}
|
|
|
|
|
{formatYieldAndFission(chosen.yieldKt, chosen.fissionFraction)}{" "}
|
|
|
|
|
<button type="button" style={LINK} onClick={() => setChanging(!changing)}>
|
|
|
|
|
{changing ? "done" : "change"}
|
|
|
|
|
</button>
|
|
|
|
|
{" · "}
|
|
|
|
|
<button type="button" style={LINK} onClick={onRemove} aria-label={`Remove ${target.label}`}>remove</button>
|
|
|
|
|
</div>
|
|
|
|
|
{changing && <WeaponPicker value={target} onChange={onWeapon}/>}
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The fallout view. `targets` are those simulated ({key, id (if saved), lat, lon, label, weapon,
|
|
|
|
|
// yield_kt?, fission_fraction?}): tried out, and the saved ones once the user loads them
|
|
|
|
|
// (`onLoad`; there are `savedCount`, and `loaded` says whether they were). `onSave` saves them in
|
|
|
|
|
// place of the saved ones, which is refused until those are loaded; `unsaved` says whether the list
|
|
|
|
|
// differs from what is saved. `onPlaceTarget(true)` asks for the next click on the map to add a target
|
|
|
|
|
// there (`placingTarget` while it waits), `onPlaceTarget(false)` stops.
|
|
|
|
|
// `onTargetWeapon(target, weapon)` keeps a target's weapon.
|
|
|
|
|
export default function FalloutPanel({map, targets = [], savedCount = 0, loaded = false, unsaved = false, onLoad,
|
|
|
|
|
onSave, onRemoveTarget, onTargetWeapon, onAllTargetsWeapon,
|
|
|
|
|
placingTarget = false, onPlaceTarget, onClose}) {
|
|
|
|
|
const [step, setStep] = useState(TARGETS);
|
|
|
|
|
const [saving, setSaving] = useState(false);
|
|
|
|
|
const [wind, setWind] = useState(FORECAST);
|
|
|
|
|
// The climatology: which months are kept, the month and dose rate shown, and the months read.
|
|
|
|
|
const [climateStatus, setClimateStatus] = useState(null);
|
|
|
|
|
const [climateMonth, setClimateMonth] = useState(new Date().getMonth() + 1);
|
|
|
|
|
const [climateRate, setClimateRate] = useState("1");
|
|
|
|
|
const climates = useRef(new Map());
|
|
|
|
|
const [forecastChecked, setForecastChecked] = useState(false);
|
|
|
|
|
const chosenForUs = useRef(false);
|
|
|
|
|
const [direction, setDirection] = useState(270);
|
|
|
|
|
const [speed, setSpeed] = useState(20);
|
|
|
|
|
// The field of forecast winds around the targets downloaded most recently, and the weather
|
|
|
|
|
// subscription which downloads it.
|
|
|
|
|
const [forecast, setForecast] = useState(null);
|
|
|
|
|
const [hour, setHour] = useState(0);
|
|
|
|
|
const {weather, downloading: weatherDownloading, setEnabled: setWeatherEnabled} = useWeather();
|
|
|
|
|
const [busy, setBusy] = useState(false);
|
|
|
|
|
const [useTerrain, setUseTerrain] = useState(true);
|
|
|
|
|
const [terrainStatus, setTerrainStatus] = useState(null);
|
|
|
|
|
const [progress, setProgress] = useState(null);
|
|
|
|
|
// The calculation running (an AbortController), whether the user stopped it, and a count which
|
|
|
|
|
// starts it again.
|
|
|
|
|
const running = useRef(null);
|
|
|
|
|
const [stopped, setStopped] = useState(false);
|
|
|
|
|
const [again, setAgain] = useState(0);
|
|
|
|
|
// The hour after the bursts shown (one of HOURS), and whether the hours play.
|
|
|
|
|
const [after, setAfter] = useState(1);
|
|
|
|
|
const [show, setShow] = useState(RATE);
|
|
|
|
|
const [playing, setPlaying] = useState(false);
|
|
|
|
|
// The fallout last calculated ({grid, spots, origin}), and its images by what is shown.
|
|
|
|
|
const result = useRef(null);
|
|
|
|
|
const frames = useRef(new Map());
|
|
|
|
|
const [calculated, setCalculated] = useState(0);
|
|
|
|
|
const drawn = useRef(null);
|
|
|
|
|
const calculatedFor = useRef(null);
|
|
|
|
|
|
|
|
|
|
const bursts = useMemo(() => [
|
|
|
|
|
...targets.map((t) => ({lat: t.lat, lon: t.lon, ...targetWeapon(t)})),
|
|
|
|
|
], [targets]);
|
|
|
|
|
// What the fallout depends on, as one value an effect can watch.
|
|
|
|
|
const burstsKey = JSON.stringify(bursts.map((b) => [b.lat, b.lon, b.yieldKt, b.fissionFraction]));
|
|
|
|
|
|
|
|
|
|
// Placing a target is of the targets step.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (step !== TARGETS && placingTarget) onPlaceTarget?.(false);
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [step]);
|
|
|
|
|
|
|
|
|
|
// With nothing to burst, the targets are needed first.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!bursts.length) setStep(TARGETS);
|
|
|
|
|
}, [bursts.length]);
|
|
|
|
|
|
|
|
|
|
// The forecast fetched most recently.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let cancelled = false;
|
|
|
|
|
getFalloutClimatology().then((s) => !cancelled && setClimateStatus(s));
|
|
|
|
|
getLatestFalloutWinds().then((latest) => {
|
|
|
|
|
if (!cancelled) setForecastChecked(true);
|
|
|
|
|
if (cancelled || !latest) return;
|
|
|
|
|
setForecast(latest);
|
|
|
|
|
setHour(nearestHour(latest.hours));
|
|
|
|
|
}).catch(() => !cancelled && setForecastChecked(true));
|
|
|
|
|
return () => {
|
|
|
|
|
cancelled = true;
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
// A forecast downloaded while the panel is open is used: its winds, from the hour nearest now.
|
|
|
|
|
const downloadedAt = weather?.field?.fetched_at;
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!downloadedAt || !forecastChecked || downloadedAt === forecast?.fetched_at) return;
|
|
|
|
|
let cancelled = false;
|
|
|
|
|
getLatestFalloutWinds().then((latest) => {
|
|
|
|
|
if (cancelled || !latest) return;
|
|
|
|
|
setForecast(latest);
|
|
|
|
|
setHour(nearestHour(latest.hours));
|
|
|
|
|
if (forecastCoversFallout(latest)) setWind(FORECAST);
|
|
|
|
|
}).catch(() => null);
|
|
|
|
|
return () => {
|
|
|
|
|
cancelled = true;
|
|
|
|
|
};
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [downloadedAt, forecastChecked]);
|
|
|
|
|
|
|
|
|
|
const prepared = useMemo(() => forecast ? prepareField(forecast) : null, [forecast]);
|
|
|
|
|
const useField = wind === FORECAST && !!prepared;
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let cancelled = false;
|
|
|
|
|
// What the fallout is calculated from: the same again is drawn as it was.
|
|
|
|
|
const inputs = JSON.stringify([burstsKey, wind, direction, speed, useTerrain, forecast?.fetched_at,
|
|
|
|
|
hour, climateMonth, climateRate, again]);
|
|
|
|
|
// Nothing is calculated until the user has chosen the targets, and the map is clear meanwhile.
|
|
|
|
|
if (!bursts.length || step !== VIEW) {
|
|
|
|
|
if (!bursts.length) {
|
|
|
|
|
drawn.current = null;
|
|
|
|
|
result.current = null;
|
|
|
|
|
frames.current = new Map();
|
|
|
|
|
calculatedFor.current = null;
|
|
|
|
|
setTerrainStatus(null);
|
|
|
|
|
}
|
|
|
|
|
erase();
|
|
|
|
|
setBusy(false);
|
|
|
|
|
setProgress(null);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (calculatedFor.current === inputs && drawn.current) {
|
|
|
|
|
if (result.current) setCalculated((n) => n + 1);
|
|
|
|
|
else draw();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
calculatedFor.current = null;
|
|
|
|
|
const controller = new AbortController();
|
|
|
|
|
running.current = controller;
|
|
|
|
|
setStopped(false);
|
|
|
|
|
setBusy(true);
|
|
|
|
|
setProgress(null);
|
|
|
|
|
if (wind === CLIMATE) {
|
|
|
|
|
// The bursts in each of the month's past days, counted. Said at once: not the forecast's terrain while counting.
|
|
|
|
|
setTerrainStatus("Flat ground: the past days' winds are read by height above the sea.");
|
|
|
|
|
const timer = setTimeout(async () => {
|
|
|
|
|
let clim = climates.current.get(climateMonth);
|
|
|
|
|
if (!clim) {
|
|
|
|
|
const zipped = await getFalloutClimatologyMonth(climateMonth);
|
|
|
|
|
if (cancelled) return;
|
|
|
|
|
if (!zipped) {
|
|
|
|
|
setBusy(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
clim = parseClimatology(await gunzip(zipped));
|
|
|
|
|
climates.current.set(climateMonth, clim);
|
|
|
|
|
}
|
|
|
|
|
if (cancelled || controller.signal.aborted) return;
|
|
|
|
|
const ran = await simulateClimate(bursts, clim, {
|
|
|
|
|
rate: Number(climateRate), workers: workerCount(typeof navigator === "undefined" ? {} : navigator),
|
|
|
|
|
signal: controller.signal, cancelled: () => cancelled,
|
|
|
|
|
onProgress: everySoOften((done, total) => !cancelled && setProgress({done, total})),
|
|
|
|
|
});
|
|
|
|
|
if (cancelled || !ran) return;
|
|
|
|
|
setProgress(null);
|
|
|
|
|
result.current = null;
|
|
|
|
|
frames.current = new Map();
|
|
|
|
|
drawn.current = ran.grid ? {url: gridImage(ran.grid, ran.origin.lat, CLIMATE_BANDS),
|
|
|
|
|
coordinates: gridCorners(ran.grid, ran.origin.lon, ran.origin.lat)} : null;
|
|
|
|
|
calculatedFor.current = inputs;
|
|
|
|
|
if (drawn.current) draw();
|
|
|
|
|
else erase();
|
|
|
|
|
setBusy(false);
|
|
|
|
|
}, 30);
|
|
|
|
|
return () => {
|
|
|
|
|
cancelled = true;
|
|
|
|
|
controller.abort();
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// Each burst is carried by the winds where it is, from the hour chosen; or by one profile.
|
|
|
|
|
const winds = useField
|
|
|
|
|
? {prepared, startMs: Date.parse(forecast.hours[hour])}
|
|
|
|
|
: {profile: windProfile({direction: Number(direction) || 0, speed: Number(speed) || 0})};
|
|
|
|
|
// Let the panel paint "Calculating" before the model takes the thread.
|
|
|
|
|
const timer = setTimeout(async () => {
|
|
|
|
|
const ran = await simulateBursts(bursts, {
|
|
|
|
|
winds, useTerrain, workers: workerCount(typeof navigator === "undefined" ? {} : navigator),
|
|
|
|
|
signal: controller.signal, cancelled: () => cancelled,
|
|
|
|
|
onProgress: everySoOften((done, total) => !cancelled && setProgress({done, total})),
|
|
|
|
|
// Something to look at while the terrain is read: what is shown, on flat ground.
|
|
|
|
|
onFlat: (flat) => {
|
|
|
|
|
if (cancelled) return;
|
|
|
|
|
drawn.current = frameOf(flat, show, after);
|
|
|
|
|
draw();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
if (cancelled || !ran) return;
|
|
|
|
|
setProgress(null);
|
|
|
|
|
result.current = ran;
|
|
|
|
|
frames.current = new Map();
|
|
|
|
|
calculatedFor.current = inputs;
|
|
|
|
|
// The hour shown is drawn from it.
|
|
|
|
|
setCalculated((n) => n + 1);
|
|
|
|
|
setTerrainStatus(ran.terrainStatus);
|
|
|
|
|
setBusy(false);
|
|
|
|
|
}, 30);
|
|
|
|
|
return () => {
|
|
|
|
|
cancelled = true;
|
|
|
|
|
controller.abort();
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
};
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [burstsKey, wind, direction, speed, useTerrain, forecast, hour, climateMonth, climateRate, again, step]);
|
|
|
|
|
|
|
|
|
|
// Stop the calculation running (and its workers); what was drawn before stays.
|
|
|
|
|
function cancel() {
|
|
|
|
|
running.current?.abort();
|
|
|
|
|
setBusy(false);
|
|
|
|
|
setProgress(null);
|
|
|
|
|
setStopped(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The forecast's winds when it has them for bursts now, until all their fallout is down; otherwise
|
|
|
|
|
// one wind at every height. Chosen once: then the wind is the user's to choose.
|
|
|
|
|
const climateKept = !!climateStatus?.months?.includes(climateMonth);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (chosenForUs.current || !forecastChecked) return;
|
|
|
|
|
chosenForUs.current = true;
|
|
|
|
|
if (!forecastCoversFallout(forecast)) setWind(MANUAL);
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [forecastChecked]);
|
|
|
|
|
|
|
|
|
|
// What is shown: the fallout landed by the hour, as strong as it is then; or the total dose of
|
|
|
|
|
// someone outdoors in the first two weeks.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const ran = result.current;
|
|
|
|
|
if (!ran) return;
|
|
|
|
|
const key = show === TOTAL ? TOTAL : `${RATE}:${after}`;
|
|
|
|
|
if (!frames.current.has(key)) frames.current.set(key, frameOf(ran, show, after));
|
|
|
|
|
drawn.current = frames.current.get(key);
|
|
|
|
|
draw();
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [after, show, calculated]);
|
|
|
|
|
|
|
|
|
|
// Playing, the next hour is shown after this one; from the last, it starts over.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!playing) return;
|
|
|
|
|
const timer = setTimeout(() => setAfter((h) => HOURS[(HOURS.indexOf(h) + 1) % HOURS.length]), FRAME_MS);
|
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
|
}, [playing, after, calculated]);
|
|
|
|
|
|
|
|
|
|
// The layer is of the map's style, which a change of style removes: it is put back when the
|
|
|
|
|
// style has loaded.
|
|
|
|
|
function draw() {
|
|
|
|
|
if (!map || !drawn.current) return;
|
|
|
|
|
const source = map.getSource(SOURCE);
|
|
|
|
|
if (source) {
|
|
|
|
|
source.updateImage(drawn.current);
|
|
|
|
|
} else {
|
|
|
|
|
map.addSource(SOURCE, {type: "image", ...drawn.current});
|
|
|
|
|
map.addLayer({id: LAYER, type: "raster", source: SOURCE, paint: {"raster-opacity": 0.6, "raster-resampling": "nearest"}});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function erase() {
|
|
|
|
|
try {
|
|
|
|
|
if (map.getLayer(LAYER)) map.removeLayer(LAYER);
|
|
|
|
|
if (map.getSource(SOURCE)) map.removeSource(SOURCE);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// The map is gone.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!map) return;
|
|
|
|
|
const restore = () => draw();
|
|
|
|
|
map.on("style.load", restore);
|
|
|
|
|
return () => {
|
|
|
|
|
map.off("style.load", restore);
|
|
|
|
|
erase();
|
|
|
|
|
};
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [map]);
|
|
|
|
|
|
|
|
|
|
const muted = {color: "var(--muted)", fontSize: "0.75rem"};
|
|
|
|
|
const panelStyle = {
|
|
|
|
|
position: "absolute", left: "0.75rem", bottom: "2.5rem", zIndex: 1002, width: "20rem",
|
|
|
|
|
maxHeight: "calc(100% - 7rem)", overflowY: "auto",
|
|
|
|
|
background: "var(--panel)", border: "1px solid var(--border)", color: "var(--text)", padding: "0.75rem",
|
|
|
|
|
fontSize: "0.8125rem",
|
|
|
|
|
};
|
|
|
|
|
const targetCount = targets.length === 1 ? "1 target" : `${targets.length} targets`;
|
|
|
|
|
// Saving replaces the saved targets, so they must be among these first.
|
|
|
|
|
const mustLoad = savedCount > 0 && !loaded;
|
|
|
|
|
const save = async () => {
|
|
|
|
|
setSaving(true);
|
|
|
|
|
try {
|
|
|
|
|
await onSave?.();
|
|
|
|
|
} finally {
|
|
|
|
|
setSaving(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// How the fallout is carried, in a few words.
|
|
|
|
|
const carried = wind === CLIMATE ? `past ${MONTHS[climateMonth - 1]} days' winds`
|
|
|
|
|
: useField ? `forecast winds, ${hourLabel(forecast.hours[hour], false)}`
|
|
|
|
|
: `one wind from ${Number(direction) || 0}° at ${Number(speed) || 0} mph`;
|
|
|
|
|
const ground = wind === CLIMATE ? "" : useTerrain ? "; the terrain" : "; flat ground";
|
|
|
|
|
const close = <Button role="cancel" size="sm" onClick={onClose}>Close</Button>;
|
|
|
|
|
|
|
|
|
|
if (step === TARGETS) return <div style={panelStyle}>
|
|
|
|
|
<FalloutSteps step={step}/>
|
|
|
|
|
<div style={{fontWeight: 600}}>Step 2 of 4: Choose the targets</div>
|
|
|
|
|
<div style={{...muted, marginBottom: "0.5rem"}}>
|
|
|
|
|
Targets you add are tried out, not saved, until you save the targets. Right-clicking the map adds
|
|
|
|
|
one too.
|
|
|
|
|
</div>
|
|
|
|
|
{placingTarget
|
|
|
|
|
? <div style={{display: "flex", alignItems: "center", gap: "0.5rem", marginBottom: "0.5rem"}}>
|
|
|
|
|
<strong style={{flex: 1}}>Click the map where the target is.</strong>
|
|
|
|
|
<Button size="xs" role="cancel" onClick={() => onPlaceTarget?.(false)}>Stop</Button>
|
|
|
|
|
</div>
|
|
|
|
|
: <div style={{display: "flex", flexWrap: "wrap", gap: "0.5rem", marginBottom: "0.5rem"}}>
|
|
|
|
|
<Button size="xs" role="primary" onClick={() => onPlaceTarget?.(true)}>Add a target</Button>
|
|
|
|
|
{mustLoad && <Button size="xs" onClick={onLoad}>Load Saved Targets ({savedCount})</Button>}
|
|
|
|
|
</div>}
|
|
|
|
|
<div style={{marginBottom: "0.25rem"}}>
|
|
|
|
|
<strong>{bursts.length ? targetCount : "No targets yet"}</strong>; surface bursts.
|
|
|
|
|
{unsaved && <span style={muted}> Not saved.</span>}
|
|
|
|
|
</div>
|
|
|
|
|
{targets.length > 1 && <div style={{marginBottom: "0.5rem"}}>
|
|
|
|
|
{/* Empty until chosen, and always applied: the targets may have any weapons now. */}
|
|
|
|
|
<Select label="Set every target's weapon" size="xs" data={WEAPON_CHOICES.slice(0, -1)} value={null}
|
|
|
|
|
placeholder="Choose a weapon for every target" searchable maxDropdownHeight={320}
|
|
|
|
|
comboboxProps={DROPDOWN} aria-label="Every target's weapon"
|
|
|
|
|
onChange={(key) => key && onAllTargetsWeapon?.({
|
|
|
|
|
weapon: key, fission_fraction: targetWeapon({weapon: key}).fissionFraction,
|
|
|
|
|
})}/>
|
|
|
|
|
</div>}
|
|
|
|
|
<div style={{maxHeight: "14rem", overflowY: "auto", marginBottom: "0.5rem"}}>
|
|
|
|
|
{targets.map((t) => <TargetRow key={t.key} target={t} onRemove={() => onRemoveTarget?.(t)}
|
|
|
|
|
onWeapon={(weapon) => onTargetWeapon?.(t, weapon)}/>)}
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{marginBottom: "0.75rem"}}>
|
|
|
|
|
<Button size="xs" onClick={save} disabled={mustLoad || saving || (!loaded && !targets.length)}>
|
|
|
|
|
{saving ? "Saving…" : "Save Targets"}
|
|
|
|
|
</Button>
|
|
|
|
|
{mustLoad && <div style={muted}>
|
|
|
|
|
Saving replaces the saved targets: load them first, to keep them.
|
|
|
|
|
</div>}
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{display: "flex", justifyContent: "space-between"}}>
|
|
|
|
|
{close}
|
|
|
|
|
<Button role="primary" size="sm" disabled={!bursts.length} onClick={() => setStep(WIND)}>
|
|
|
|
|
Next: the wind
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>;
|
|
|
|
|
|
|
|
|
|
if (step === WIND) return <div style={panelStyle}>
|
|
|
|
|
<FalloutSteps step={step}/>
|
|
|
|
|
<div style={{fontWeight: 600}}>Step 3 of 4: The wind</div>
|
|
|
|
|
<div style={{...muted, marginBottom: "0.5rem"}}>The wind carries the fallout from the targets.</div>
|
|
|
|
|
<WeatherNote weather={weather} downloading={weatherDownloading} onEnable={() => setWeatherEnabled(true)}/>
|
|
|
|
|
<Select label="Wind" size="xs" value={wind} onChange={(v) => v && setWind(v)}
|
|
|
|
|
data={climateStatus?.months?.length
|
|
|
|
|
? [WINDS[0], {value: CLIMATE, label: "Past days of a month (no forecast needed)"}, ...WINDS.slice(1)]
|
|
|
|
|
: WINDS}
|
|
|
|
|
allowDeselect={false} comboboxProps={DROPDOWN}/>
|
|
|
|
|
{wind === CLIMATE && <div style={{display: "flex", gap: "0.5rem"}}>
|
|
|
|
|
<Select label="Month" size="xs" value={String(climateMonth)} allowDeselect={false} comboboxProps={DROPDOWN}
|
|
|
|
|
data={MONTHS.map((name, k) => ({value: String(k + 1), label: name,
|
|
|
|
|
disabled: !climateStatus?.months?.includes(k + 1)}))}
|
|
|
|
|
onChange={(v) => v && setClimateMonth(Number(v))}/>
|
|
|
|
|
<Select label="Count days with" size="xs" value={climateRate} data={CLIMATE_RATES}
|
|
|
|
|
allowDeselect={false} comboboxProps={DROPDOWN} onChange={(v) => v && setClimateRate(v)}/>
|
|
|
|
|
</div>}
|
|
|
|
|
{wind === CLIMATE && !climateKept && <div style={{...muted, color: "var(--warning)"}}>
|
|
|
|
|
{MONTHS[climateMonth - 1]}'s past winds are not on this WROLPi yet: they are fetched once, while
|
|
|
|
|
there is the Internet.
|
|
|
|
|
</div>}
|
|
|
|
|
{wind === FORECAST && <ForecastControls
|
|
|
|
|
forecast={forecast} hour={hour} onHour={setHour}/>}
|
|
|
|
|
{(wind === MANUAL || (wind === FORECAST && !forecast)) && <div style={{display: "flex", gap: "0.5rem"}}>
|
|
|
|
|
<NumberInput label="From (degrees)" size="xs" min={0} max={359} value={direction} onChange={setDirection}/>
|
|
|
|
|
<NumberInput label="Speed (mph)" size="xs" min={0} max={200} value={speed} onChange={setSpeed}/>
|
|
|
|
|
</div>}
|
|
|
|
|
{wind !== CLIMATE && <Checkbox label="Follow the terrain" size="xs" style={{marginTop: "0.5rem"}}
|
|
|
|
|
checked={useTerrain} onChange={(e) => setUseTerrain(e.currentTarget.checked)}/>}
|
|
|
|
|
<div style={{display: "flex", justifyContent: "space-between", marginTop: "0.75rem"}}>
|
|
|
|
|
<Button role="cancel" size="sm" onClick={() => setStep(TARGETS)}>Back</Button>
|
|
|
|
|
{close}
|
|
|
|
|
<Button role="primary" size="sm" onClick={() => setStep(VIEW)}>Next: the fallout</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>;
|
|
|
|
|
|
|
|
|
|
return <div style={panelStyle}>
|
|
|
|
|
<FalloutSteps step={step}/>
|
|
|
|
|
<div style={{fontWeight: 600}}>Step 4 of 4: The fallout</div>
|
|
|
|
|
<div style={{...muted, marginBottom: "0.5rem"}}>{targetCount}; {carried}{ground}.</div>
|
|
|
|
|
<FalloutProgress busy={busy} progress={progress} onCancel={cancel}/>
|
|
|
|
|
{stopped && !busy && <div style={{...muted, display: "flex", alignItems: "center", gap: "0.5rem", marginBottom: "0.5rem"}}>
|
|
|
|
|
Calculation cancelled.
|
|
|
|
|
<Button size="xs" onClick={() => setAgain((n) => n + 1)}>Calculate</Button>
|
|
|
|
|
</div>}
|
|
|
|
|
{terrainStatus && <div style={muted}>{terrainStatus}</div>}
|
|
|
|
|
{useField && forecastShortText(forecast, hour) && <div style={{...muted, color: "var(--warning)"}}>
|
|
|
|
|
{forecastShortText(forecast, hour)}
|
|
|
|
|
</div>}
|
|
|
|
|
{wind === FORECAST && prepared && <ForecastWarnings prepared={prepared} bursts={bursts} hour={hour}/>}
|
|
|
|
|
{wind === CLIMATE ? <div style={{margin: "0.5rem 0"}}>
|
|
|
|
|
<div style={{fontWeight: 600}}>Typical {MONTHS[climateMonth - 1]}: not today's winds</div>
|
|
|
|
|
<div style={muted}>
|
|
|
|
|
On how many of 30 past {MONTHS[climateMonth - 1]} days (one from each year, 1991 to 2020) the
|
|
|
|
|
fallout of these bursts reached {climateRate} R/hr or more at H+1. Real winds vary from day to day:
|
|
|
|
|
a place outside the bands can still be reached.
|
|
|
|
|
</div>
|
|
|
|
|
{CLIMATE_BANDS.map((b) => <div key={b.rate} style={{display: "flex", alignItems: "center", gap: "0.375rem"}}>
|
|
|
|
|
<span style={{display: "inline-block", width: "0.875rem", height: "0.875rem", flexShrink: 0,
|
|
|
|
|
background: `rgb(${b.color.join(",")})`, opacity: 0.8}}/>
|
|
|
|
|
{b.label}
|
|
|
|
|
</div>)}
|
|
|
|
|
</div> : <div style={{margin: "0.5rem 0"}}>
|
|
|
|
|
<div style={{display: "flex", gap: "0.5rem"}}>
|
|
|
|
|
<Button size="xs" role={show === RATE ? "primary" : "cancel"} aria-pressed={show === RATE}
|
|
|
|
|
style={{flex: 1}} onClick={() => setShow(RATE)}>Hour by hour</Button>
|
|
|
|
|
<Button size="xs" role={show === TOTAL ? "primary" : "cancel"} aria-pressed={show === TOTAL}
|
|
|
|
|
style={{flex: 1}} onClick={() => {
|
|
|
|
|
setPlaying(false);
|
|
|
|
|
setShow(TOTAL);
|
|
|
|
|
}}>Total dose</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{fontWeight: 600, marginTop: "0.5rem"}}>{legendHeading(show, after)}</div>
|
|
|
|
|
{show === RATE && <Timeline after={after} onAfter={(h) => {
|
|
|
|
|
setPlaying(false);
|
|
|
|
|
setAfter(h);
|
|
|
|
|
}} playing={playing} onPlaying={setPlaying}
|
|
|
|
|
startMs={useField ? Date.parse(forecast.hours[hour]) : null}/>}
|
|
|
|
|
<div style={muted}>{legendText(show)}</div>
|
|
|
|
|
{(show === TOTAL ? TOTAL_BANDS : DOSE_BANDS).map((b) => <div key={b.rate}
|
|
|
|
|
style={{display: "flex", alignItems: "center", gap: "0.375rem"}}>
|
|
|
|
|
<span style={{display: "inline-block", width: "0.875rem", height: "0.875rem", flexShrink: 0,
|
|
|
|
|
background: `rgb(${b.color.join(",")})`, opacity: 0.8}}/>
|
|
|
|
|
{show === TOTAL ? `${b.rate}+ R: ${b.meaning}` : `${b.rate}+ R/hr`}
|
|
|
|
|
</div>)}
|
|
|
|
|
</div>}
|
|
|
|
|
<div style={{...muted, marginBottom: "0.5rem"}}>An estimate, not a forecast.</div>
|
|
|
|
|
<div style={{display: "flex", justifyContent: "space-between"}}>
|
|
|
|
|
<Button role="cancel" size="sm" onClick={() => {
|
|
|
|
|
setPlaying(false);
|
|
|
|
|
setStep(WIND);
|
|
|
|
|
}}>Back</Button>
|
|
|
|
|
{close}
|
|
|
|
|
</div>
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Where the user is in the panel's steps: the nuclear button (done once the panel is open), the
|
|
|
|
|
// targets, the wind, and the fallout.
|
|
|
|
|
export function FalloutSteps({step}) {
|
|
|
|
|
const names = [["Nuclear", null], ["Targets", TARGETS], ["Wind", WIND], ["Fallout", VIEW]];
|
|
|
|
|
const at = names.findIndex(([, s]) => s === step);
|
|
|
|
|
return <ol aria-label="Steps" style={{display: "flex", gap: "0.75rem", listStyle: "none", padding: 0,
|
|
|
|
|
margin: "0 0 0.5rem 0", fontSize: "0.75rem"}}>
|
|
|
|
|
{names.map(([name], k) => <li key={name} aria-current={k === at ? "step" : undefined}
|
|
|
|
|
style={{color: k === at ? "var(--text)" : "var(--muted)", fontWeight: k === at ? 600 : 400}}>
|
|
|
|
|
{k < at ? "✓" : `${k + 1}.`} {name}
|
|
|
|
|
</li>)}
|
|
|
|
|
</ol>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// How far the calculation has got, while it runs: a bar filled as far as the bursts are done
|
|
|
|
|
// (`progress`: {done, total}), or moving without a count until there is one; and a button which
|
|
|
|
|
// stops it (`onCancel`).
|
|
|
|
|
export function FalloutProgress({busy, progress, onCancel}) {
|
|
|
|
|
if (!busy) return null;
|
|
|
|
|
return <div style={{display: "flex", alignItems: "center", gap: "0.5rem", marginBottom: "0.5rem"}}>
|
|
|
|
|
<div style={{flex: 1, minWidth: 0}}>
|
|
|
|
|
{progress && progress.total > 0
|
|
|
|
|
? <Progress percent={100 * progress.done / progress.total}
|
|
|
|
|
label={`Calculating ${progress.done.toLocaleString()} of ${progress.total.toLocaleString()}`}/>
|
|
|
|
|
: <Progress indeterminate showPercent={false} label="Calculating…"/>}
|
|
|
|
|
</div>
|
|
|
|
|
{onCancel && <Button size="xs" role="cancel" onClick={onCancel}>Cancel</Button>}
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// `hours` after the bursts, as the user reads it: hours, then days, then weeks.
|
|
|
|
|
export function afterLabel(hours) {
|
|
|
|
|
if (hours < 24) return hours === 1 ? "1 hour" : `${hours} hours`;
|
|
|
|
|
if (hours % 168 === 0) return hours === 168 ? "1 week" : `${hours / 168} weeks`;
|
|
|
|
|
return hours === 24 ? "1 day" : `${hours / 24} days`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// How many times weaker fallout is `hours` after the bursts than at H+1, as the user reads it.
|
|
|
|
|
export function weakerThanH1(hours) {
|
|
|
|
|
return Number((1 / decayFromH1(hours)).toPrecision(2)).toLocaleString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The heading of the legend, for what is shown and the hour.
|
|
|
|
|
export function legendHeading(show, after) {
|
|
|
|
|
if (show === TOTAL) return "Total dose outdoors in the first two weeks";
|
|
|
|
|
return `Dose rate ${afterLabel(after)} after the bursts`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// What the legend's bands are, for what is shown.
|
|
|
|
|
export function legendText(show) {
|
|
|
|
|
if (show === TOTAL) {
|
|
|
|
|
return "R: roentgens, about 10 mSv each. The dose of someone outdoors the whole time, from when the "
|
|
|
|
|
+ "fallout arrives, with the usual decay; real fallout can decay faster or slower, which only "
|
|
|
|
|
+ "readings can tell. Indoors is less: about 2 to 3 times in a house, 10 or more in a basement.";
|
|
|
|
|
}
|
|
|
|
|
return "R/hr: roentgens an hour, about 10 mSv each. Only the fallout which has landed by then is shown, "
|
|
|
|
|
+ "as strong as it is then. Downwind it lands hours after the bursts, and everywhere it weakens: about "
|
|
|
|
|
+ "10 times for every 7 times longer since the bursts. That is the usual decay; real fallout can decay "
|
|
|
|
|
+ "faster or slower, which only readings can tell.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Which hour after the bursts is shown (one of HOURS), and playing them in turn. `startMs` is when
|
|
|
|
|
// the bursts are (the forecast hour), if known.
|
|
|
|
|
export function Timeline({after, onAfter, playing, onPlaying, startMs}) {
|
|
|
|
|
const muted = {color: "var(--muted)", fontSize: "0.75rem"};
|
|
|
|
|
const when = startMs !== null && startMs !== undefined
|
|
|
|
|
? `, ${new Date(startMs + after * 3600000).toLocaleString(undefined, {weekday: "short", hour: "numeric", minute: "2-digit"})}`
|
|
|
|
|
: "";
|
|
|
|
|
const at = Math.max(HOURS.indexOf(after), 0);
|
|
|
|
|
return <div style={{margin: "0.25rem 0"}}>
|
|
|
|
|
<div style={{display: "flex", alignItems: "center", gap: "0.5rem"}}>
|
|
|
|
|
<Button size="xs" onClick={() => onPlaying(!playing)} aria-label={playing ? "Pause" : "Play"}>
|
|
|
|
|
{playing ? "❚❚" : "▶"}
|
|
|
|
|
</Button>
|
|
|
|
|
<input type="range" min={0} max={HOURS.length - 1} step={1} value={at} style={{flex: 1}}
|
|
|
|
|
aria-label="Time after the bursts" aria-valuetext={afterLabel(after)}
|
|
|
|
|
onChange={(e) => onAfter(HOURS[Number(e.target.value)])}/>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={muted}>
|
|
|
|
|
H+{after}{when}: the fallout landed by then
|
|
|
|
|
{after > 1 ? `, about ${weakerThanH1(after)} times weaker than at H+1` : ""}.
|
|
|
|
|
</div>
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-25 12:19:33 -07:00
|
|
|
// A warning about the forecast for bursts at its hour `hour` (an index), or null: whether it is out of
|
|
|
|
|
// date, and whether its winds run out before their fallout is down. The winds follow the hour chosen,
|
|
|
|
|
// so the last hour is held for the whole simulation only when it is the hour chosen.
|
A fallout simulator on the map: nuclear mode, targets, live winds aloft (#1007)
* A fallout model, checked against six Nevada tests
The local fallout of a surface burst lands where layered winds carry particles of every size
from the stabilized cloud. Cloud and particle sizes come from DNAF-1, WSEG-10 and DELFIC;
the air is the 1976 standard atmosphere. The six shots' wind profiles, measured contour
areas and plume bearings are in nts-shots.json with their sources, alongside HPAC's
predictions of the same contours.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A prototype fallout panel on the map
Right-click "Simulate Fallout Here" draws the dose rate at H+1 of one surface burst, in one
wind or in the winds aloft of one of the six Nevada tests. Nothing is saved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout lands where it meets the ground
A particle stops falling at the first level where it is at or below the ground under it, not
at a plane at the height of ground zero: early on a ridge in its way, later in a valley. The
map panel reads the ground from the terrain files the user has downloaded; the Nevada tests
are checked against a small elevation grid of Mapterhorn terrain, as WROLPi publishes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout falls from the cloud's cap, skirt and stem
The cloud of a surface burst holds 77.5% of its activity in the cap, 15% in a skirt below it
and 7.5% in the stem (Philippe et al.); the stem starts as narrow as the early fireball at the
ground and widens up to the cap (DNAF-1). More of the fallout lands near ground zero: a 1 Mt
burst now draws a 1000 R/hr contour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Close-in fallout measured after three Nevada surface bursts
Jangle Sugar, Small Boy and Johnie Boy, from DNAF-1's Table 3: the area, hotline length and
azimuth of each contour from 35 to 1000 R/hr, as observed and as DNAF-1, DELFIC and WSEG-10
predicted them, with each shot's winds. The deposition grid can look closely at part of the
fallout, and measures hotlines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout rises with the cloud, and heavy particles drop out low
All of the activity starts in the early fireball and rises with the cloud, whose base and top
climb with the square root of time (SIMFIC). Each particle rises with the air less its own
settling speed, so a heavy one leaves the cloud low and early and lands near ground zero, and a
light one rides to the top. A burst above the ground puts down less, by its scaled height.
Against the close-in fallout of Jangle Sugar and Small Boy this is within 2.4x in area and 1.7x
in hotline length (it was 100x short); across the six Nevada tests, 4.2x a priori (it was 8.9x).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel offers the weapons in service today
Weapons deployed or stockpiled by each country, each with its yield quoted from the 2025-2026
Nuclear Notebook or SIPRI Yearbook, and the improvised devices FEMA plans for; no retired or
historical weapons, and none whose yield no source gives. Variable-yield weapons have one entry
for each published setting. Fission shares are not public; they are assumed as Glasstone and
Dolan plan for, and the user may change them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's dropdowns open above it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A variable-yield weapon is named once, with each setting's yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel uses the forecast winds aloft
WROLPi fetches, on request, Open-Meteo's hourly forecast of the wind at nineteen pressure levels
(about 100 m to 24 km) and the rain, for the whole degree around the burst: the place is rounded
before it is sent. The forecast is kept, so the panel can use it offline. The panel picks the
hour nearest now, gives the forecast's age, and warns of rain, which brings fallout down in places
the map does not show.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A nuclear mode on the map: targets, and fallout
A radiation button under the print button turns nuclear mode on and off. In it, targets (likely
detonation sites) are shown alongside the pins, a pin added is saved as a target, and fallout can
be simulated at a target or anywhere on the map. A pin's kind is kept in map_pins.yaml; a pin
without one is a plain pin, as every pin was.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets keep their weapon, and nuclear mode shows the fallout of all of them
A target keeps the weapon chosen for it (or a yield of the user's own) and its fission share in
map_pins.yaml. Nuclear mode opens on the fallout of every saved target at once, in the forecast
winds aloft fetched most recently; a burst tried out from the map can be saved as a target.
A whole-degree latitude or longitude, which a browser sends as an integer, is a valid pin, and a
pin's label and color may be left out of an update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* An improvised device is named once, with each yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout of many targets is calculated in seconds, and shown as it goes
A particle size's settling speed is read from a table by altitude rather than solved again for
every fall of every burst (a burst: 40 ms to 6 ms). The view yields to the page only every 40 ms,
through a message channel, which a browser does not hold back in a hidden tab as it does timers;
it says how far it has got, and draws the fallout on flat ground while the terrain is read.
A target in the list shows its weapon, and is given a weapon picker when asked; one picker sets
every target's weapon.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout grid covers where fallout shows, not past the poles
The faintest particles of a burst are carried thousands of km in two days; with many targets the
grid stretched past 90 degrees and the map refused the image ("Invalid LngLat latitude"). The grid
now covers the spots which can reach the faintest band drawn, the image's corners stay within
Web Mercator's 85 degrees, and so does the area whose terrain is read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout across a continent is drawn where it lands
The map stretches an image evenly in Web Mercator between its corners, but the fallout grid's rows
are evenly apart in latitude; over tens of degrees (targets across a country) they part ways, and
the southern part of the image was drawn far from its targets. Each image row now takes the grid
row at its own latitude. A burst far from the first target keeps its plume as wide, east to west,
as at its own latitude.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Terrain across the antimeridian, and ground with no number, do not break the fallout
Targets in Alaska and Hawaii carry fallout west of 180 degrees, where the terrain's tile arithmetic
read past the tile's pixels; one sample with no number made every target's lowest ground NaN and
every spot fall off the map, and the grid's size Infinity. Longitudes wrap, a sample with no number
is left out (of the lowest ground, and of the elevation between samples), and a spot not on the map
is left out of the grid rather than breaking it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Every target's weapon is set in one change
Setting it target by target, eight at once, lost most of the changes: each request wrote the whole
pin list, undoing the others (QA: 47 of 156 changed). PUT /api/map/pins/targets/weapon gives
every target the weapon in one change of the config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The every-target weapon picker starts empty and always applies
It showed the first target's weapon, so choosing that weapon for all of them did nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout is carried by the winds where it is, region by region
A field of forecasts on a grid over the targets replaces the one forecast for
all of them. Each particle rises and falls through the wind at its place,
height and hour, read between the surrounding grid points, hours and heights.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The winds aloft are fetched as a Job, ninety places a minute
The free forecast service allows 600 calls a minute and a place costs six, so
a field of up to 540 points is fetched in paced batches by a Job, which the
fallout panel follows, instead of inside one request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A small burst's hot fallout is kept on a grid over many, and the panel says what it shows
- Each burst's narrow close-in fallout is also put on a fine grid, so the
lethal zone of a small target is not averaged away in the cells kilometers
wide of a grid over targets far apart.
- The legend says the dose rate is as at one hour, with all the fallout down,
and what R/hr is; the error quoted is the unscaled model's.
- The TNA's yield is 150 kt: its source gives only an upper bound below 300.
- Weapons show their fission share beside their yield.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout can be watched landing, hour by hour
A timeline under the legend plays, or steps through, the 48 hours after the
bursts: each hour shows only the fallout which has landed by then, at its
dose rate then (t^-1.2 from H+1), on the same cells as the whole of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The map can show the total dose of someone outdoors, hour by hour
A "Show" picker switches from the dose rate to the total dose (R) someone
outdoors gets from when the fallout arrives: t^-1.2 added up from each spot's
arrival to the hour on the timeline, or over the first two weeks. Its bands
say what each dose does to a person.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against the Army's fallout manuals
- FM 3-3-1's worked decay and dose problems are tests.
- FM 3-11.3's cloud and Zone I nomograms, read from their images, are a
fixture; the model's cloud top is within 10% of them from 1 kt to 10 Mt,
and its Zone I within 0.7-1.7 times from 10 kt to 1 Mt, the yields of
modern weapons, which the test shots do not reach.
- The legend says real fallout may decay faster or slower than usual.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against two megaton bursts in the Pacific
Redwing Zuni (3.5 Mt), whose winds were measured above its cloud: the hot
fallout goes where it went and about as far. Castle Bravo (15 Mt), whose
winds were measured only below its cloud: its fallout arrives when it did,
and its hot fallout reaching a third as far is kept in view as a known gap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Winds are read from the right points at every spacing, and cover the landing
- A field's points were filed by rounding (lat + 90) / spacing but looked up
by flooring it: at 4 and 8 degrees, which do not divide 90, every point read
half its neighbor's wind. Both now count whole spacings from the equator.
- The forecast starts at midnight UTC, so two days could end before the
fallout of a burst this hour was down; three are fetched (the same call
weight), and the panel says when the last hour's winds are held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bravo's known gap is not its unmeasured upper winds
Reanalysis winds above the 1954 sounding turn the plume to within 10 degrees
of the measured one but do not lengthen its hot contours; the fixture's caveat
and the test's explanation said otherwise, and now say what was found.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Rain takes fallout out of the air where it falls
A falling particle in rain loses a share of its activity every step: fast
inside the rain cloud ("rainout"), slower below it, by how hard it rains
("washout"), at Glasstone and Dolan's rates (Tables 9.74a and b), and none
above it. What is taken out comes down where the particle was. The forecast
now asks for relative humidity at 14 levels, and each hour's rain cloud is
taken as HYSPLIT takes it: from the lowest level 80% humid to the first above
it less than 60%.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* With no forecast, the fallout of 30 past days of the month
- wrolpi/scripts/build_fallout_climatology.py builds, from NOAA's reanalysis,
the winds aloft of 30 days of each month (one from each year 1991-2020) over
the whole world: a gzip file a month, about 4 MB, for the release download
location.
- WROLPi fetches the months it lacks once, while there is the Internet, each
checked against a sha256 pinned in modules/map/climatology.py (none pinned
until the files are published), and serves them to the panel.
- The panel's "Past days of a month" wind runs the bursts in each day and shows
on what share of the days each place had the chosen dose rate; it is chosen
for us when there is no forecast, or it has run out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology's months are published, and their sha256 pinned
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology worker waits for the Internet and the drive on startup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Counting the past days says flat ground at once, not the forecast's terrain
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout reuses each yield's paths, about 10 times faster
On flat ground in a day's held winds, how each parcel rises with the cloud
and falls does not depend on the wind, so it is worked out once per yield
and kept for every burst and day. The rising cloud is carried by the winds
over ground zero (it drifts about 10 km); the fall still reads the winds
where the particle is. A field of one hour is read without its hours, and
the nearest point to a cell past the field is kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rising cloud reads the winds over ground zero from arrays, by level
Each parcel's rise is kept as the levels of the column it passes through
(steps in the same level as one) and their seconds, so a burst reads the
column once and sums.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel shows a progress bar while it calculates
At the top of the panel, filled as far as the bursts are done, or moving
without a count until there is one. A calculation stopped by removing the
last target no longer leaves the panel busy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout runs in Web Workers, with a Cancel button
The days are spread over workers, one for each core but one (left for the
page), at most 6, and at most 2 where the browser says it has 2 GB or less.
A worker is given the next day as it finishes one, and sends back only the
cells reached. Where workers cannot be made, or fail, the days are
calculated on the page as before.
The days are counted on cells as wide as the coarsest day's grid, so the
count does not depend on which day finishes first.
Cancel, beside the progress bar, stops a calculation (and its workers) at
once; Calculate starts it again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's bursts are spread over Web Workers too
The workers now take any task: a past day, or a burst. The page and the
workers build each burst's winds and terrain with the same functions
(work.js), so the fallout is the same either way; the flat pass and the
terrain pass each run on their own workers, and Cancel stops them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The bursts' grid is made in parts by the Web Workers
The grid is a sum over the bursts' spots, sharpened by the most any burst
raises a cell, so it is made in a fixed number of parts (a burst's spots
in one) on one frame, and joined on the page. The page makes the same
parts when there are no workers, so the grid is the same either way.
The forecast's warnings (bursts outside the winds, rain) are no longer
worked out again on every progress update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's hours are labeled once an hour, not on every progress update
Writing each hour's label (toLocaleString) took most of the page's time
while the workers calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Faster forecast fallout: the nearest point outside the field, progress, and what workers are sent
- Outside the forecast's field, the nearest point is looked for only
among the points which can be nearest somewhere in the grid cell (kept
for each cell); the same point as looking through them all. Longitudes
are wrapped however far round the world a particle is carried.
- The progress is shown at most ten times a second.
- The workers are sent the forecast's arrays, not the forecast as fetched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel in steps: the targets, then the fallout hour by hour or in total
Nuclear mode opens on the targets; nothing is calculated until the user goes on.
The winds and terrain wait under Options, with what is used said beside it.
The timeline runs from the first hour to two weeks, saying how much the fallout
has weakened since H+1; the view of all the fallout as if landed at H+1 is gone.
Going back and on again with nothing changed draws what was calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's winds: the forecast, past days, or one wind; no test shots' winds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is a step of its own, between the targets and the fallout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel says it is an estimate; how it compares with the test bursts goes in the help
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets are tried out until saved; the saved ones are loaded first, and saved all at once
Nuclear mode starts with no targets. Targets added are tried out, and the saved
targets join them when the user loads them. Saving replaces the saved targets
with the list, in one change, and is refused until they were loaded (or there are
none), so none are lost unseen. A target can be taken out of the list. The
burst tried out from the map's menu is gone: a target tried out does the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Nuclear targets are kept in their own config, map_nuclear.yaml, and listed apart from the pins
The pins are plain pins again. The targets have their own endpoints, and their
own table on the Pins tab, where one can be deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rest of keeping nuclear targets in map_nuclear.yaml: the config, its endpoints, and the table
The commit before this one was missing these files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is the forecast when it has the winds until the fallout is down, else one wind
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The weather is a subscription: a forecast around the saved targets, downloaded every day
The Open-Meteo fetch is a recurring Download (daily) instead of a Job the panel
starts. The Manage tab has a Weather section: turning it on or off, what it
downloads, how its downloads went, and the forecast kept. Only the newest
forecast is kept, and it covers four days. The wind step asks the user to turn
the download on, and warns, there and beside the fallout, when the forecast runs
out before the fallout is down.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast service may take three minutes to answer, and a timeout says so
A batch of four days' forecasts took 43 seconds, near the old 60-second limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's targets step has an Add a target button: the next click on the map places it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:13 -07:00
|
|
|
export function forecastShortText(forecast, hour) {
|
|
|
|
|
if (!forecast) return null;
|
2026-11-25 12:19:33 -07:00
|
|
|
const last = forecast.hours.length - 1;
|
|
|
|
|
let held = null;
|
|
|
|
|
if (hour >= last) {
|
|
|
|
|
held = "Its last hour's winds are held for the whole simulation.";
|
|
|
|
|
} else if (forecastRunsOut(forecast, hour) !== null) {
|
|
|
|
|
held = `It ends at ${hourLabel(forecast.hours[last], false)}, before all the fallout is down: `
|
|
|
|
|
+ "its last hour's winds are held from then on.";
|
A fallout simulator on the map: nuclear mode, targets, live winds aloft (#1007)
* A fallout model, checked against six Nevada tests
The local fallout of a surface burst lands where layered winds carry particles of every size
from the stabilized cloud. Cloud and particle sizes come from DNAF-1, WSEG-10 and DELFIC;
the air is the 1976 standard atmosphere. The six shots' wind profiles, measured contour
areas and plume bearings are in nts-shots.json with their sources, alongside HPAC's
predictions of the same contours.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A prototype fallout panel on the map
Right-click "Simulate Fallout Here" draws the dose rate at H+1 of one surface burst, in one
wind or in the winds aloft of one of the six Nevada tests. Nothing is saved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout lands where it meets the ground
A particle stops falling at the first level where it is at or below the ground under it, not
at a plane at the height of ground zero: early on a ridge in its way, later in a valley. The
map panel reads the ground from the terrain files the user has downloaded; the Nevada tests
are checked against a small elevation grid of Mapterhorn terrain, as WROLPi publishes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout falls from the cloud's cap, skirt and stem
The cloud of a surface burst holds 77.5% of its activity in the cap, 15% in a skirt below it
and 7.5% in the stem (Philippe et al.); the stem starts as narrow as the early fireball at the
ground and widens up to the cap (DNAF-1). More of the fallout lands near ground zero: a 1 Mt
burst now draws a 1000 R/hr contour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Close-in fallout measured after three Nevada surface bursts
Jangle Sugar, Small Boy and Johnie Boy, from DNAF-1's Table 3: the area, hotline length and
azimuth of each contour from 35 to 1000 R/hr, as observed and as DNAF-1, DELFIC and WSEG-10
predicted them, with each shot's winds. The deposition grid can look closely at part of the
fallout, and measures hotlines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout rises with the cloud, and heavy particles drop out low
All of the activity starts in the early fireball and rises with the cloud, whose base and top
climb with the square root of time (SIMFIC). Each particle rises with the air less its own
settling speed, so a heavy one leaves the cloud low and early and lands near ground zero, and a
light one rides to the top. A burst above the ground puts down less, by its scaled height.
Against the close-in fallout of Jangle Sugar and Small Boy this is within 2.4x in area and 1.7x
in hotline length (it was 100x short); across the six Nevada tests, 4.2x a priori (it was 8.9x).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel offers the weapons in service today
Weapons deployed or stockpiled by each country, each with its yield quoted from the 2025-2026
Nuclear Notebook or SIPRI Yearbook, and the improvised devices FEMA plans for; no retired or
historical weapons, and none whose yield no source gives. Variable-yield weapons have one entry
for each published setting. Fission shares are not public; they are assumed as Glasstone and
Dolan plan for, and the user may change them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's dropdowns open above it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A variable-yield weapon is named once, with each setting's yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel uses the forecast winds aloft
WROLPi fetches, on request, Open-Meteo's hourly forecast of the wind at nineteen pressure levels
(about 100 m to 24 km) and the rain, for the whole degree around the burst: the place is rounded
before it is sent. The forecast is kept, so the panel can use it offline. The panel picks the
hour nearest now, gives the forecast's age, and warns of rain, which brings fallout down in places
the map does not show.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A nuclear mode on the map: targets, and fallout
A radiation button under the print button turns nuclear mode on and off. In it, targets (likely
detonation sites) are shown alongside the pins, a pin added is saved as a target, and fallout can
be simulated at a target or anywhere on the map. A pin's kind is kept in map_pins.yaml; a pin
without one is a plain pin, as every pin was.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets keep their weapon, and nuclear mode shows the fallout of all of them
A target keeps the weapon chosen for it (or a yield of the user's own) and its fission share in
map_pins.yaml. Nuclear mode opens on the fallout of every saved target at once, in the forecast
winds aloft fetched most recently; a burst tried out from the map can be saved as a target.
A whole-degree latitude or longitude, which a browser sends as an integer, is a valid pin, and a
pin's label and color may be left out of an update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* An improvised device is named once, with each yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout of many targets is calculated in seconds, and shown as it goes
A particle size's settling speed is read from a table by altitude rather than solved again for
every fall of every burst (a burst: 40 ms to 6 ms). The view yields to the page only every 40 ms,
through a message channel, which a browser does not hold back in a hidden tab as it does timers;
it says how far it has got, and draws the fallout on flat ground while the terrain is read.
A target in the list shows its weapon, and is given a weapon picker when asked; one picker sets
every target's weapon.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout grid covers where fallout shows, not past the poles
The faintest particles of a burst are carried thousands of km in two days; with many targets the
grid stretched past 90 degrees and the map refused the image ("Invalid LngLat latitude"). The grid
now covers the spots which can reach the faintest band drawn, the image's corners stay within
Web Mercator's 85 degrees, and so does the area whose terrain is read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout across a continent is drawn where it lands
The map stretches an image evenly in Web Mercator between its corners, but the fallout grid's rows
are evenly apart in latitude; over tens of degrees (targets across a country) they part ways, and
the southern part of the image was drawn far from its targets. Each image row now takes the grid
row at its own latitude. A burst far from the first target keeps its plume as wide, east to west,
as at its own latitude.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Terrain across the antimeridian, and ground with no number, do not break the fallout
Targets in Alaska and Hawaii carry fallout west of 180 degrees, where the terrain's tile arithmetic
read past the tile's pixels; one sample with no number made every target's lowest ground NaN and
every spot fall off the map, and the grid's size Infinity. Longitudes wrap, a sample with no number
is left out (of the lowest ground, and of the elevation between samples), and a spot not on the map
is left out of the grid rather than breaking it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Every target's weapon is set in one change
Setting it target by target, eight at once, lost most of the changes: each request wrote the whole
pin list, undoing the others (QA: 47 of 156 changed). PUT /api/map/pins/targets/weapon gives
every target the weapon in one change of the config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The every-target weapon picker starts empty and always applies
It showed the first target's weapon, so choosing that weapon for all of them did nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout is carried by the winds where it is, region by region
A field of forecasts on a grid over the targets replaces the one forecast for
all of them. Each particle rises and falls through the wind at its place,
height and hour, read between the surrounding grid points, hours and heights.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The winds aloft are fetched as a Job, ninety places a minute
The free forecast service allows 600 calls a minute and a place costs six, so
a field of up to 540 points is fetched in paced batches by a Job, which the
fallout panel follows, instead of inside one request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A small burst's hot fallout is kept on a grid over many, and the panel says what it shows
- Each burst's narrow close-in fallout is also put on a fine grid, so the
lethal zone of a small target is not averaged away in the cells kilometers
wide of a grid over targets far apart.
- The legend says the dose rate is as at one hour, with all the fallout down,
and what R/hr is; the error quoted is the unscaled model's.
- The TNA's yield is 150 kt: its source gives only an upper bound below 300.
- Weapons show their fission share beside their yield.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout can be watched landing, hour by hour
A timeline under the legend plays, or steps through, the 48 hours after the
bursts: each hour shows only the fallout which has landed by then, at its
dose rate then (t^-1.2 from H+1), on the same cells as the whole of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The map can show the total dose of someone outdoors, hour by hour
A "Show" picker switches from the dose rate to the total dose (R) someone
outdoors gets from when the fallout arrives: t^-1.2 added up from each spot's
arrival to the hour on the timeline, or over the first two weeks. Its bands
say what each dose does to a person.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against the Army's fallout manuals
- FM 3-3-1's worked decay and dose problems are tests.
- FM 3-11.3's cloud and Zone I nomograms, read from their images, are a
fixture; the model's cloud top is within 10% of them from 1 kt to 10 Mt,
and its Zone I within 0.7-1.7 times from 10 kt to 1 Mt, the yields of
modern weapons, which the test shots do not reach.
- The legend says real fallout may decay faster or slower than usual.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against two megaton bursts in the Pacific
Redwing Zuni (3.5 Mt), whose winds were measured above its cloud: the hot
fallout goes where it went and about as far. Castle Bravo (15 Mt), whose
winds were measured only below its cloud: its fallout arrives when it did,
and its hot fallout reaching a third as far is kept in view as a known gap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Winds are read from the right points at every spacing, and cover the landing
- A field's points were filed by rounding (lat + 90) / spacing but looked up
by flooring it: at 4 and 8 degrees, which do not divide 90, every point read
half its neighbor's wind. Both now count whole spacings from the equator.
- The forecast starts at midnight UTC, so two days could end before the
fallout of a burst this hour was down; three are fetched (the same call
weight), and the panel says when the last hour's winds are held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bravo's known gap is not its unmeasured upper winds
Reanalysis winds above the 1954 sounding turn the plume to within 10 degrees
of the measured one but do not lengthen its hot contours; the fixture's caveat
and the test's explanation said otherwise, and now say what was found.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Rain takes fallout out of the air where it falls
A falling particle in rain loses a share of its activity every step: fast
inside the rain cloud ("rainout"), slower below it, by how hard it rains
("washout"), at Glasstone and Dolan's rates (Tables 9.74a and b), and none
above it. What is taken out comes down where the particle was. The forecast
now asks for relative humidity at 14 levels, and each hour's rain cloud is
taken as HYSPLIT takes it: from the lowest level 80% humid to the first above
it less than 60%.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* With no forecast, the fallout of 30 past days of the month
- wrolpi/scripts/build_fallout_climatology.py builds, from NOAA's reanalysis,
the winds aloft of 30 days of each month (one from each year 1991-2020) over
the whole world: a gzip file a month, about 4 MB, for the release download
location.
- WROLPi fetches the months it lacks once, while there is the Internet, each
checked against a sha256 pinned in modules/map/climatology.py (none pinned
until the files are published), and serves them to the panel.
- The panel's "Past days of a month" wind runs the bursts in each day and shows
on what share of the days each place had the chosen dose rate; it is chosen
for us when there is no forecast, or it has run out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology's months are published, and their sha256 pinned
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology worker waits for the Internet and the drive on startup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Counting the past days says flat ground at once, not the forecast's terrain
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout reuses each yield's paths, about 10 times faster
On flat ground in a day's held winds, how each parcel rises with the cloud
and falls does not depend on the wind, so it is worked out once per yield
and kept for every burst and day. The rising cloud is carried by the winds
over ground zero (it drifts about 10 km); the fall still reads the winds
where the particle is. A field of one hour is read without its hours, and
the nearest point to a cell past the field is kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rising cloud reads the winds over ground zero from arrays, by level
Each parcel's rise is kept as the levels of the column it passes through
(steps in the same level as one) and their seconds, so a burst reads the
column once and sums.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel shows a progress bar while it calculates
At the top of the panel, filled as far as the bursts are done, or moving
without a count until there is one. A calculation stopped by removing the
last target no longer leaves the panel busy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout runs in Web Workers, with a Cancel button
The days are spread over workers, one for each core but one (left for the
page), at most 6, and at most 2 where the browser says it has 2 GB or less.
A worker is given the next day as it finishes one, and sends back only the
cells reached. Where workers cannot be made, or fail, the days are
calculated on the page as before.
The days are counted on cells as wide as the coarsest day's grid, so the
count does not depend on which day finishes first.
Cancel, beside the progress bar, stops a calculation (and its workers) at
once; Calculate starts it again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's bursts are spread over Web Workers too
The workers now take any task: a past day, or a burst. The page and the
workers build each burst's winds and terrain with the same functions
(work.js), so the fallout is the same either way; the flat pass and the
terrain pass each run on their own workers, and Cancel stops them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The bursts' grid is made in parts by the Web Workers
The grid is a sum over the bursts' spots, sharpened by the most any burst
raises a cell, so it is made in a fixed number of parts (a burst's spots
in one) on one frame, and joined on the page. The page makes the same
parts when there are no workers, so the grid is the same either way.
The forecast's warnings (bursts outside the winds, rain) are no longer
worked out again on every progress update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's hours are labeled once an hour, not on every progress update
Writing each hour's label (toLocaleString) took most of the page's time
while the workers calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Faster forecast fallout: the nearest point outside the field, progress, and what workers are sent
- Outside the forecast's field, the nearest point is looked for only
among the points which can be nearest somewhere in the grid cell (kept
for each cell); the same point as looking through them all. Longitudes
are wrapped however far round the world a particle is carried.
- The progress is shown at most ten times a second.
- The workers are sent the forecast's arrays, not the forecast as fetched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel in steps: the targets, then the fallout hour by hour or in total
Nuclear mode opens on the targets; nothing is calculated until the user goes on.
The winds and terrain wait under Options, with what is used said beside it.
The timeline runs from the first hour to two weeks, saying how much the fallout
has weakened since H+1; the view of all the fallout as if landed at H+1 is gone.
Going back and on again with nothing changed draws what was calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's winds: the forecast, past days, or one wind; no test shots' winds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is a step of its own, between the targets and the fallout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel says it is an estimate; how it compares with the test bursts goes in the help
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets are tried out until saved; the saved ones are loaded first, and saved all at once
Nuclear mode starts with no targets. Targets added are tried out, and the saved
targets join them when the user loads them. Saving replaces the saved targets
with the list, in one change, and is refused until they were loaded (or there are
none), so none are lost unseen. A target can be taken out of the list. The
burst tried out from the map's menu is gone: a target tried out does the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Nuclear targets are kept in their own config, map_nuclear.yaml, and listed apart from the pins
The pins are plain pins again. The targets have their own endpoints, and their
own table on the Pins tab, where one can be deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rest of keeping nuclear targets in map_nuclear.yaml: the config, its endpoints, and the table
The commit before this one was missing these files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is the forecast when it has the winds until the fallout is down, else one wind
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The weather is a subscription: a forecast around the saved targets, downloaded every day
The Open-Meteo fetch is a recurring Download (daily) instead of a Job the panel
starts. The Manage tab has a Weather section: turning it on or off, what it
downloads, how its downloads went, and the forecast kept. Only the newest
forecast is kept, and it covers four days. The wind step asks the user to turn
the download on, and warns, there and beside the fallout, when the forecast runs
out before the fallout is down.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast service may take three minutes to answer, and a timeout says so
A batch of four days' forecasts took 43 seconds, near the old 60-second limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's targets step has an Add a target button: the next click on the map places it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:13 -07:00
|
|
|
}
|
2026-11-25 12:19:33 -07:00
|
|
|
if (forecastExpired(forecast)) {
|
|
|
|
|
return ["This forecast is out of date: its winds are past ones, not today's.", held,
|
|
|
|
|
"Download a new one on the map's Manage tab, or use one wind at every height."]
|
|
|
|
|
.filter(Boolean).join(" ");
|
A fallout simulator on the map: nuclear mode, targets, live winds aloft (#1007)
* A fallout model, checked against six Nevada tests
The local fallout of a surface burst lands where layered winds carry particles of every size
from the stabilized cloud. Cloud and particle sizes come from DNAF-1, WSEG-10 and DELFIC;
the air is the 1976 standard atmosphere. The six shots' wind profiles, measured contour
areas and plume bearings are in nts-shots.json with their sources, alongside HPAC's
predictions of the same contours.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A prototype fallout panel on the map
Right-click "Simulate Fallout Here" draws the dose rate at H+1 of one surface burst, in one
wind or in the winds aloft of one of the six Nevada tests. Nothing is saved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout lands where it meets the ground
A particle stops falling at the first level where it is at or below the ground under it, not
at a plane at the height of ground zero: early on a ridge in its way, later in a valley. The
map panel reads the ground from the terrain files the user has downloaded; the Nevada tests
are checked against a small elevation grid of Mapterhorn terrain, as WROLPi publishes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout falls from the cloud's cap, skirt and stem
The cloud of a surface burst holds 77.5% of its activity in the cap, 15% in a skirt below it
and 7.5% in the stem (Philippe et al.); the stem starts as narrow as the early fireball at the
ground and widens up to the cap (DNAF-1). More of the fallout lands near ground zero: a 1 Mt
burst now draws a 1000 R/hr contour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Close-in fallout measured after three Nevada surface bursts
Jangle Sugar, Small Boy and Johnie Boy, from DNAF-1's Table 3: the area, hotline length and
azimuth of each contour from 35 to 1000 R/hr, as observed and as DNAF-1, DELFIC and WSEG-10
predicted them, with each shot's winds. The deposition grid can look closely at part of the
fallout, and measures hotlines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout rises with the cloud, and heavy particles drop out low
All of the activity starts in the early fireball and rises with the cloud, whose base and top
climb with the square root of time (SIMFIC). Each particle rises with the air less its own
settling speed, so a heavy one leaves the cloud low and early and lands near ground zero, and a
light one rides to the top. A burst above the ground puts down less, by its scaled height.
Against the close-in fallout of Jangle Sugar and Small Boy this is within 2.4x in area and 1.7x
in hotline length (it was 100x short); across the six Nevada tests, 4.2x a priori (it was 8.9x).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel offers the weapons in service today
Weapons deployed or stockpiled by each country, each with its yield quoted from the 2025-2026
Nuclear Notebook or SIPRI Yearbook, and the improvised devices FEMA plans for; no retired or
historical weapons, and none whose yield no source gives. Variable-yield weapons have one entry
for each published setting. Fission shares are not public; they are assumed as Glasstone and
Dolan plan for, and the user may change them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's dropdowns open above it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A variable-yield weapon is named once, with each setting's yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel uses the forecast winds aloft
WROLPi fetches, on request, Open-Meteo's hourly forecast of the wind at nineteen pressure levels
(about 100 m to 24 km) and the rain, for the whole degree around the burst: the place is rounded
before it is sent. The forecast is kept, so the panel can use it offline. The panel picks the
hour nearest now, gives the forecast's age, and warns of rain, which brings fallout down in places
the map does not show.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A nuclear mode on the map: targets, and fallout
A radiation button under the print button turns nuclear mode on and off. In it, targets (likely
detonation sites) are shown alongside the pins, a pin added is saved as a target, and fallout can
be simulated at a target or anywhere on the map. A pin's kind is kept in map_pins.yaml; a pin
without one is a plain pin, as every pin was.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets keep their weapon, and nuclear mode shows the fallout of all of them
A target keeps the weapon chosen for it (or a yield of the user's own) and its fission share in
map_pins.yaml. Nuclear mode opens on the fallout of every saved target at once, in the forecast
winds aloft fetched most recently; a burst tried out from the map can be saved as a target.
A whole-degree latitude or longitude, which a browser sends as an integer, is a valid pin, and a
pin's label and color may be left out of an update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* An improvised device is named once, with each yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout of many targets is calculated in seconds, and shown as it goes
A particle size's settling speed is read from a table by altitude rather than solved again for
every fall of every burst (a burst: 40 ms to 6 ms). The view yields to the page only every 40 ms,
through a message channel, which a browser does not hold back in a hidden tab as it does timers;
it says how far it has got, and draws the fallout on flat ground while the terrain is read.
A target in the list shows its weapon, and is given a weapon picker when asked; one picker sets
every target's weapon.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout grid covers where fallout shows, not past the poles
The faintest particles of a burst are carried thousands of km in two days; with many targets the
grid stretched past 90 degrees and the map refused the image ("Invalid LngLat latitude"). The grid
now covers the spots which can reach the faintest band drawn, the image's corners stay within
Web Mercator's 85 degrees, and so does the area whose terrain is read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout across a continent is drawn where it lands
The map stretches an image evenly in Web Mercator between its corners, but the fallout grid's rows
are evenly apart in latitude; over tens of degrees (targets across a country) they part ways, and
the southern part of the image was drawn far from its targets. Each image row now takes the grid
row at its own latitude. A burst far from the first target keeps its plume as wide, east to west,
as at its own latitude.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Terrain across the antimeridian, and ground with no number, do not break the fallout
Targets in Alaska and Hawaii carry fallout west of 180 degrees, where the terrain's tile arithmetic
read past the tile's pixels; one sample with no number made every target's lowest ground NaN and
every spot fall off the map, and the grid's size Infinity. Longitudes wrap, a sample with no number
is left out (of the lowest ground, and of the elevation between samples), and a spot not on the map
is left out of the grid rather than breaking it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Every target's weapon is set in one change
Setting it target by target, eight at once, lost most of the changes: each request wrote the whole
pin list, undoing the others (QA: 47 of 156 changed). PUT /api/map/pins/targets/weapon gives
every target the weapon in one change of the config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The every-target weapon picker starts empty and always applies
It showed the first target's weapon, so choosing that weapon for all of them did nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout is carried by the winds where it is, region by region
A field of forecasts on a grid over the targets replaces the one forecast for
all of them. Each particle rises and falls through the wind at its place,
height and hour, read between the surrounding grid points, hours and heights.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The winds aloft are fetched as a Job, ninety places a minute
The free forecast service allows 600 calls a minute and a place costs six, so
a field of up to 540 points is fetched in paced batches by a Job, which the
fallout panel follows, instead of inside one request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A small burst's hot fallout is kept on a grid over many, and the panel says what it shows
- Each burst's narrow close-in fallout is also put on a fine grid, so the
lethal zone of a small target is not averaged away in the cells kilometers
wide of a grid over targets far apart.
- The legend says the dose rate is as at one hour, with all the fallout down,
and what R/hr is; the error quoted is the unscaled model's.
- The TNA's yield is 150 kt: its source gives only an upper bound below 300.
- Weapons show their fission share beside their yield.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout can be watched landing, hour by hour
A timeline under the legend plays, or steps through, the 48 hours after the
bursts: each hour shows only the fallout which has landed by then, at its
dose rate then (t^-1.2 from H+1), on the same cells as the whole of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The map can show the total dose of someone outdoors, hour by hour
A "Show" picker switches from the dose rate to the total dose (R) someone
outdoors gets from when the fallout arrives: t^-1.2 added up from each spot's
arrival to the hour on the timeline, or over the first two weeks. Its bands
say what each dose does to a person.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against the Army's fallout manuals
- FM 3-3-1's worked decay and dose problems are tests.
- FM 3-11.3's cloud and Zone I nomograms, read from their images, are a
fixture; the model's cloud top is within 10% of them from 1 kt to 10 Mt,
and its Zone I within 0.7-1.7 times from 10 kt to 1 Mt, the yields of
modern weapons, which the test shots do not reach.
- The legend says real fallout may decay faster or slower than usual.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against two megaton bursts in the Pacific
Redwing Zuni (3.5 Mt), whose winds were measured above its cloud: the hot
fallout goes where it went and about as far. Castle Bravo (15 Mt), whose
winds were measured only below its cloud: its fallout arrives when it did,
and its hot fallout reaching a third as far is kept in view as a known gap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Winds are read from the right points at every spacing, and cover the landing
- A field's points were filed by rounding (lat + 90) / spacing but looked up
by flooring it: at 4 and 8 degrees, which do not divide 90, every point read
half its neighbor's wind. Both now count whole spacings from the equator.
- The forecast starts at midnight UTC, so two days could end before the
fallout of a burst this hour was down; three are fetched (the same call
weight), and the panel says when the last hour's winds are held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bravo's known gap is not its unmeasured upper winds
Reanalysis winds above the 1954 sounding turn the plume to within 10 degrees
of the measured one but do not lengthen its hot contours; the fixture's caveat
and the test's explanation said otherwise, and now say what was found.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Rain takes fallout out of the air where it falls
A falling particle in rain loses a share of its activity every step: fast
inside the rain cloud ("rainout"), slower below it, by how hard it rains
("washout"), at Glasstone and Dolan's rates (Tables 9.74a and b), and none
above it. What is taken out comes down where the particle was. The forecast
now asks for relative humidity at 14 levels, and each hour's rain cloud is
taken as HYSPLIT takes it: from the lowest level 80% humid to the first above
it less than 60%.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* With no forecast, the fallout of 30 past days of the month
- wrolpi/scripts/build_fallout_climatology.py builds, from NOAA's reanalysis,
the winds aloft of 30 days of each month (one from each year 1991-2020) over
the whole world: a gzip file a month, about 4 MB, for the release download
location.
- WROLPi fetches the months it lacks once, while there is the Internet, each
checked against a sha256 pinned in modules/map/climatology.py (none pinned
until the files are published), and serves them to the panel.
- The panel's "Past days of a month" wind runs the bursts in each day and shows
on what share of the days each place had the chosen dose rate; it is chosen
for us when there is no forecast, or it has run out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology's months are published, and their sha256 pinned
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology worker waits for the Internet and the drive on startup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Counting the past days says flat ground at once, not the forecast's terrain
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout reuses each yield's paths, about 10 times faster
On flat ground in a day's held winds, how each parcel rises with the cloud
and falls does not depend on the wind, so it is worked out once per yield
and kept for every burst and day. The rising cloud is carried by the winds
over ground zero (it drifts about 10 km); the fall still reads the winds
where the particle is. A field of one hour is read without its hours, and
the nearest point to a cell past the field is kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rising cloud reads the winds over ground zero from arrays, by level
Each parcel's rise is kept as the levels of the column it passes through
(steps in the same level as one) and their seconds, so a burst reads the
column once and sums.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel shows a progress bar while it calculates
At the top of the panel, filled as far as the bursts are done, or moving
without a count until there is one. A calculation stopped by removing the
last target no longer leaves the panel busy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout runs in Web Workers, with a Cancel button
The days are spread over workers, one for each core but one (left for the
page), at most 6, and at most 2 where the browser says it has 2 GB or less.
A worker is given the next day as it finishes one, and sends back only the
cells reached. Where workers cannot be made, or fail, the days are
calculated on the page as before.
The days are counted on cells as wide as the coarsest day's grid, so the
count does not depend on which day finishes first.
Cancel, beside the progress bar, stops a calculation (and its workers) at
once; Calculate starts it again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's bursts are spread over Web Workers too
The workers now take any task: a past day, or a burst. The page and the
workers build each burst's winds and terrain with the same functions
(work.js), so the fallout is the same either way; the flat pass and the
terrain pass each run on their own workers, and Cancel stops them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The bursts' grid is made in parts by the Web Workers
The grid is a sum over the bursts' spots, sharpened by the most any burst
raises a cell, so it is made in a fixed number of parts (a burst's spots
in one) on one frame, and joined on the page. The page makes the same
parts when there are no workers, so the grid is the same either way.
The forecast's warnings (bursts outside the winds, rain) are no longer
worked out again on every progress update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's hours are labeled once an hour, not on every progress update
Writing each hour's label (toLocaleString) took most of the page's time
while the workers calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Faster forecast fallout: the nearest point outside the field, progress, and what workers are sent
- Outside the forecast's field, the nearest point is looked for only
among the points which can be nearest somewhere in the grid cell (kept
for each cell); the same point as looking through them all. Longitudes
are wrapped however far round the world a particle is carried.
- The progress is shown at most ten times a second.
- The workers are sent the forecast's arrays, not the forecast as fetched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel in steps: the targets, then the fallout hour by hour or in total
Nuclear mode opens on the targets; nothing is calculated until the user goes on.
The winds and terrain wait under Options, with what is used said beside it.
The timeline runs from the first hour to two weeks, saying how much the fallout
has weakened since H+1; the view of all the fallout as if landed at H+1 is gone.
Going back and on again with nothing changed draws what was calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's winds: the forecast, past days, or one wind; no test shots' winds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is a step of its own, between the targets and the fallout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel says it is an estimate; how it compares with the test bursts goes in the help
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets are tried out until saved; the saved ones are loaded first, and saved all at once
Nuclear mode starts with no targets. Targets added are tried out, and the saved
targets join them when the user loads them. Saving replaces the saved targets
with the list, in one change, and is refused until they were loaded (or there are
none), so none are lost unseen. A target can be taken out of the list. The
burst tried out from the map's menu is gone: a target tried out does the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Nuclear targets are kept in their own config, map_nuclear.yaml, and listed apart from the pins
The pins are plain pins again. The targets have their own endpoints, and their
own table on the Pins tab, where one can be deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rest of keeping nuclear targets in map_nuclear.yaml: the config, its endpoints, and the table
The commit before this one was missing these files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is the forecast when it has the winds until the fallout is down, else one wind
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The weather is a subscription: a forecast around the saved targets, downloaded every day
The Open-Meteo fetch is a recurring Download (daily) instead of a Job the panel
starts. The Manage tab has a Weather section: turning it on or off, what it
downloads, how its downloads went, and the forecast kept. Only the newest
forecast is kept, and it covers four days. The wind step asks the user to turn
the download on, and warns, there and beside the fallout, when the forecast runs
out before the fallout is down.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast service may take three minutes to answer, and a timeout says so
A batch of four days' forecasts took 43 seconds, near the old 60-second limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's targets step has an Add a target button: the next click on the map places it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:13 -07:00
|
|
|
}
|
2026-11-25 12:19:33 -07:00
|
|
|
return held && `This forecast is short. ${held}`;
|
A fallout simulator on the map: nuclear mode, targets, live winds aloft (#1007)
* A fallout model, checked against six Nevada tests
The local fallout of a surface burst lands where layered winds carry particles of every size
from the stabilized cloud. Cloud and particle sizes come from DNAF-1, WSEG-10 and DELFIC;
the air is the 1976 standard atmosphere. The six shots' wind profiles, measured contour
areas and plume bearings are in nts-shots.json with their sources, alongside HPAC's
predictions of the same contours.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A prototype fallout panel on the map
Right-click "Simulate Fallout Here" draws the dose rate at H+1 of one surface burst, in one
wind or in the winds aloft of one of the six Nevada tests. Nothing is saved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout lands where it meets the ground
A particle stops falling at the first level where it is at or below the ground under it, not
at a plane at the height of ground zero: early on a ridge in its way, later in a valley. The
map panel reads the ground from the terrain files the user has downloaded; the Nevada tests
are checked against a small elevation grid of Mapterhorn terrain, as WROLPi publishes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout falls from the cloud's cap, skirt and stem
The cloud of a surface burst holds 77.5% of its activity in the cap, 15% in a skirt below it
and 7.5% in the stem (Philippe et al.); the stem starts as narrow as the early fireball at the
ground and widens up to the cap (DNAF-1). More of the fallout lands near ground zero: a 1 Mt
burst now draws a 1000 R/hr contour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Close-in fallout measured after three Nevada surface bursts
Jangle Sugar, Small Boy and Johnie Boy, from DNAF-1's Table 3: the area, hotline length and
azimuth of each contour from 35 to 1000 R/hr, as observed and as DNAF-1, DELFIC and WSEG-10
predicted them, with each shot's winds. The deposition grid can look closely at part of the
fallout, and measures hotlines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout rises with the cloud, and heavy particles drop out low
All of the activity starts in the early fireball and rises with the cloud, whose base and top
climb with the square root of time (SIMFIC). Each particle rises with the air less its own
settling speed, so a heavy one leaves the cloud low and early and lands near ground zero, and a
light one rides to the top. A burst above the ground puts down less, by its scaled height.
Against the close-in fallout of Jangle Sugar and Small Boy this is within 2.4x in area and 1.7x
in hotline length (it was 100x short); across the six Nevada tests, 4.2x a priori (it was 8.9x).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel offers the weapons in service today
Weapons deployed or stockpiled by each country, each with its yield quoted from the 2025-2026
Nuclear Notebook or SIPRI Yearbook, and the improvised devices FEMA plans for; no retired or
historical weapons, and none whose yield no source gives. Variable-yield weapons have one entry
for each published setting. Fission shares are not public; they are assumed as Glasstone and
Dolan plan for, and the user may change them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's dropdowns open above it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A variable-yield weapon is named once, with each setting's yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel uses the forecast winds aloft
WROLPi fetches, on request, Open-Meteo's hourly forecast of the wind at nineteen pressure levels
(about 100 m to 24 km) and the rain, for the whole degree around the burst: the place is rounded
before it is sent. The forecast is kept, so the panel can use it offline. The panel picks the
hour nearest now, gives the forecast's age, and warns of rain, which brings fallout down in places
the map does not show.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A nuclear mode on the map: targets, and fallout
A radiation button under the print button turns nuclear mode on and off. In it, targets (likely
detonation sites) are shown alongside the pins, a pin added is saved as a target, and fallout can
be simulated at a target or anywhere on the map. A pin's kind is kept in map_pins.yaml; a pin
without one is a plain pin, as every pin was.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets keep their weapon, and nuclear mode shows the fallout of all of them
A target keeps the weapon chosen for it (or a yield of the user's own) and its fission share in
map_pins.yaml. Nuclear mode opens on the fallout of every saved target at once, in the forecast
winds aloft fetched most recently; a burst tried out from the map can be saved as a target.
A whole-degree latitude or longitude, which a browser sends as an integer, is a valid pin, and a
pin's label and color may be left out of an update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* An improvised device is named once, with each yield beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout of many targets is calculated in seconds, and shown as it goes
A particle size's settling speed is read from a table by altitude rather than solved again for
every fall of every burst (a burst: 40 ms to 6 ms). The view yields to the page only every 40 ms,
through a message channel, which a browser does not hold back in a hidden tab as it does timers;
it says how far it has got, and draws the fallout on flat ground while the terrain is read.
A target in the list shows its weapon, and is given a weapon picker when asked; one picker sets
every target's weapon.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout grid covers where fallout shows, not past the poles
The faintest particles of a burst are carried thousands of km in two days; with many targets the
grid stretched past 90 degrees and the map refused the image ("Invalid LngLat latitude"). The grid
now covers the spots which can reach the faintest band drawn, the image's corners stay within
Web Mercator's 85 degrees, and so does the area whose terrain is read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout across a continent is drawn where it lands
The map stretches an image evenly in Web Mercator between its corners, but the fallout grid's rows
are evenly apart in latitude; over tens of degrees (targets across a country) they part ways, and
the southern part of the image was drawn far from its targets. Each image row now takes the grid
row at its own latitude. A burst far from the first target keeps its plume as wide, east to west,
as at its own latitude.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Terrain across the antimeridian, and ground with no number, do not break the fallout
Targets in Alaska and Hawaii carry fallout west of 180 degrees, where the terrain's tile arithmetic
read past the tile's pixels; one sample with no number made every target's lowest ground NaN and
every spot fall off the map, and the grid's size Infinity. Longitudes wrap, a sample with no number
is left out (of the lowest ground, and of the elevation between samples), and a spot not on the map
is left out of the grid rather than breaking it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Every target's weapon is set in one change
Setting it target by target, eight at once, lost most of the changes: each request wrote the whole
pin list, undoing the others (QA: 47 of 156 changed). PUT /api/map/pins/targets/weapon gives
every target the weapon in one change of the config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The every-target weapon picker starts empty and always applies
It showed the first target's weapon, so choosing that weapon for all of them did nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fallout is carried by the winds where it is, region by region
A field of forecasts on a grid over the targets replaces the one forecast for
all of them. Each particle rises and falls through the wind at its place,
height and hour, read between the surrounding grid points, hours and heights.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The winds aloft are fetched as a Job, ninety places a minute
The free forecast service allows 600 calls a minute and a place costs six, so
a field of up to 540 points is fetched in paced batches by a Job, which the
fallout panel follows, instead of inside one request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A small burst's hot fallout is kept on a grid over many, and the panel says what it shows
- Each burst's narrow close-in fallout is also put on a fine grid, so the
lethal zone of a small target is not averaged away in the cells kilometers
wide of a grid over targets far apart.
- The legend says the dose rate is as at one hour, with all the fallout down,
and what R/hr is; the error quoted is the unscaled model's.
- The TNA's yield is 150 kt: its source gives only an upper bound below 300.
- Weapons show their fission share beside their yield.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout can be watched landing, hour by hour
A timeline under the legend plays, or steps through, the 48 hours after the
bursts: each hour shows only the fallout which has landed by then, at its
dose rate then (t^-1.2 from H+1), on the same cells as the whole of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The map can show the total dose of someone outdoors, hour by hour
A "Show" picker switches from the dose rate to the total dose (R) someone
outdoors gets from when the fallout arrives: t^-1.2 added up from each spot's
arrival to the hour on the timeline, or over the first two weeks. Its bands
say what each dose does to a person.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against the Army's fallout manuals
- FM 3-3-1's worked decay and dose problems are tests.
- FM 3-11.3's cloud and Zone I nomograms, read from their images, are a
fixture; the model's cloud top is within 10% of them from 1 kt to 10 Mt,
and its Zone I within 0.7-1.7 times from 10 kt to 1 Mt, the yields of
modern weapons, which the test shots do not reach.
- The legend says real fallout may decay faster or slower than usual.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The model is checked against two megaton bursts in the Pacific
Redwing Zuni (3.5 Mt), whose winds were measured above its cloud: the hot
fallout goes where it went and about as far. Castle Bravo (15 Mt), whose
winds were measured only below its cloud: its fallout arrives when it did,
and its hot fallout reaching a third as far is kept in view as a known gap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Winds are read from the right points at every spacing, and cover the landing
- A field's points were filed by rounding (lat + 90) / spacing but looked up
by flooring it: at 4 and 8 degrees, which do not divide 90, every point read
half its neighbor's wind. Both now count whole spacings from the equator.
- The forecast starts at midnight UTC, so two days could end before the
fallout of a burst this hour was down; three are fetched (the same call
weight), and the panel says when the last hour's winds are held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Bravo's known gap is not its unmeasured upper winds
Reanalysis winds above the 1954 sounding turn the plume to within 10 degrees
of the measured one but do not lengthen its hot contours; the fixture's caveat
and the test's explanation said otherwise, and now say what was found.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Rain takes fallout out of the air where it falls
A falling particle in rain loses a share of its activity every step: fast
inside the rain cloud ("rainout"), slower below it, by how hard it rains
("washout"), at Glasstone and Dolan's rates (Tables 9.74a and b), and none
above it. What is taken out comes down where the particle was. The forecast
now asks for relative humidity at 14 levels, and each hour's rain cloud is
taken as HYSPLIT takes it: from the lowest level 80% humid to the first above
it less than 60%.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* With no forecast, the fallout of 30 past days of the month
- wrolpi/scripts/build_fallout_climatology.py builds, from NOAA's reanalysis,
the winds aloft of 30 days of each month (one from each year 1991-2020) over
the whole world: a gzip file a month, about 4 MB, for the release download
location.
- WROLPi fetches the months it lacks once, while there is the Internet, each
checked against a sha256 pinned in modules/map/climatology.py (none pinned
until the files are published), and serves them to the panel.
- The panel's "Past days of a month" wind runs the bursts in each day and shows
on what share of the days each place had the chosen dose rate; it is chosen
for us when there is no forecast, or it has run out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology's months are published, and their sha256 pinned
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The climatology worker waits for the Internet and the drive on startup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Counting the past days says flat ground at once, not the forecast's terrain
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout reuses each yield's paths, about 10 times faster
On flat ground in a day's held winds, how each parcel rises with the cloud
and falls does not depend on the wind, so it is worked out once per yield
and kept for every burst and day. The rising cloud is carried by the winds
over ground zero (it drifts about 10 km); the fall still reads the winds
where the particle is. A field of one hour is read without its hours, and
the nearest point to a cell past the field is kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rising cloud reads the winds over ground zero from arrays, by level
Each parcel's rise is kept as the levels of the column it passes through
(steps in the same level as one) and their seconds, so a burst reads the
column once and sums.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel shows a progress bar while it calculates
At the top of the panel, filled as far as the bursts are done, or moving
without a count until there is one. A calculation stopped by removing the
last target no longer leaves the panel busy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Past days' fallout runs in Web Workers, with a Cancel button
The days are spread over workers, one for each core but one (left for the
page), at most 6, and at most 2 where the browser says it has 2 GB or less.
A worker is given the next day as it finishes one, and sends back only the
cells reached. Where workers cannot be made, or fail, the days are
calculated on the page as before.
The days are counted on cells as wide as the coarsest day's grid, so the
count does not depend on which day finishes first.
Cancel, beside the progress bar, stops a calculation (and its workers) at
once; Calculate starts it again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's bursts are spread over Web Workers too
The workers now take any task: a past day, or a burst. The page and the
workers build each burst's winds and terrain with the same functions
(work.js), so the fallout is the same either way; the flat pass and the
terrain pass each run on their own workers, and Cancel stops them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The bursts' grid is made in parts by the Web Workers
The grid is a sum over the bursts' spots, sharpened by the most any burst
raises a cell, so it is made in a fixed number of parts (a burst's spots
in one) on one frame, and joined on the page. The page makes the same
parts when there are no workers, so the grid is the same either way.
The forecast's warnings (bursts outside the winds, rain) are no longer
worked out again on every progress update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast's hours are labeled once an hour, not on every progress update
Writing each hour's label (toLocaleString) took most of the page's time
while the workers calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Faster forecast fallout: the nearest point outside the field, progress, and what workers are sent
- Outside the forecast's field, the nearest point is looked for only
among the points which can be nearest somewhere in the grid cell (kept
for each cell); the same point as looking through them all. Longitudes
are wrapped however far round the world a particle is carried.
- The progress is shown at most ten times a second.
- The workers are sent the forecast's arrays, not the forecast as fetched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel in steps: the targets, then the fallout hour by hour or in total
Nuclear mode opens on the targets; nothing is calculated until the user goes on.
The winds and terrain wait under Options, with what is used said beside it.
The timeline runs from the first hour to two weeks, saying how much the fallout
has weakened since H+1; the view of all the fallout as if landed at H+1 is gone.
Going back and on again with nothing changed draws what was calculated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's winds: the forecast, past days, or one wind; no test shots' winds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is a step of its own, between the targets and the fallout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel says it is an estimate; how it compares with the test bursts goes in the help
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Targets are tried out until saved; the saved ones are loaded first, and saved all at once
Nuclear mode starts with no targets. Targets added are tried out, and the saved
targets join them when the user loads them. Saving replaces the saved targets
with the list, in one change, and is refused until they were loaded (or there are
none), so none are lost unseen. A target can be taken out of the list. The
burst tried out from the map's menu is gone: a target tried out does the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Nuclear targets are kept in their own config, map_nuclear.yaml, and listed apart from the pins
The pins are plain pins again. The targets have their own endpoints, and their
own table on the Pins tab, where one can be deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The rest of keeping nuclear targets in map_nuclear.yaml: the config, its endpoints, and the table
The commit before this one was missing these files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's wind is the forecast when it has the winds until the fallout is down, else one wind
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The weather is a subscription: a forecast around the saved targets, downloaded every day
The Open-Meteo fetch is a recurring Download (daily) instead of a Job the panel
starts. The Manage tab has a Weather section: turning it on or off, what it
downloads, how its downloads went, and the forecast kept. Only the newest
forecast is kept, and it covers four days. The wind step asks the user to turn
the download on, and warns, there and beside the fallout, when the forecast runs
out before the fallout is down.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The forecast service may take three minutes to answer, and a timeout says so
A batch of four days' forecasts took 43 seconds, near the old 60-second limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The fallout panel's targets step has an Add a target button: the next click on the map places it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The forecast winds aloft: which hour, how old, where they reach, and whether they last until the
|
|
|
|
|
// fallout is down.
|
|
|
|
|
function ForecastControls({forecast, hour, onHour}) {
|
|
|
|
|
const muted = {color: "var(--muted)", fontSize: "0.75rem"};
|
|
|
|
|
// Not again while the panel shows its progress: the hours' labels are slow to write.
|
|
|
|
|
// Written again at half past each hour, when the hour nearest now moves on.
|
|
|
|
|
const nowHour = Math.round(Date.now() / 3600000);
|
|
|
|
|
const hours = useMemo(() => {
|
|
|
|
|
if (!forecast) return [];
|
|
|
|
|
const nearest = nearestHour(forecast.hours, new Date(nowHour * 3600000));
|
|
|
|
|
return forecast.hours.map((time, i) => ({value: String(i), label: hourLabel(time, i === nearest)}));
|
|
|
|
|
}, [forecast, nowHour]);
|
|
|
|
|
if (!forecast) {
|
|
|
|
|
return <div style={muted}>No forecast has been downloaded; until one is, this wind is used at every
|
|
|
|
|
height:</div>;
|
|
|
|
|
}
|
|
|
|
|
const age = forecastAge(forecast);
|
|
|
|
|
const points = forecast.points.length;
|
|
|
|
|
const short = forecastShortText(forecast, hour);
|
|
|
|
|
return <div>
|
|
|
|
|
<Select label="Hour of the bursts" size="xs" data={hours} value={String(hour)}
|
|
|
|
|
onChange={(v) => v !== null && onHour(Number(v))} allowDeselect={false}
|
|
|
|
|
maxDropdownHeight={240} comboboxProps={DROPDOWN}/>
|
|
|
|
|
<div style={muted}>
|
|
|
|
|
{forecast.source}, {points === 1 ? "1 place" : `${points} places`} {forecast.spacing}° apart,
|
|
|
|
|
downloaded {age < 1 ? "within the hour" : `${Math.round(age)} hours ago`}. Fallout is carried by
|
|
|
|
|
the wind where it is, as it changes hour by hour.
|
|
|
|
|
</div>
|
|
|
|
|
{short && <div style={{...muted, color: "var(--warning)"}}>{short}</div>}
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The weather subscription, on the wind step: asking the user to turn it on, and saying when it is
|
|
|
|
|
// downloading.
|
|
|
|
|
function WeatherNote({weather, downloading, onEnable}) {
|
|
|
|
|
const muted = {color: "var(--muted)", fontSize: "0.75rem"};
|
|
|
|
|
if (!weather) return null;
|
|
|
|
|
if (!weather.enabled) {
|
|
|
|
|
return <div style={{marginBottom: "0.5rem"}}>
|
|
|
|
|
<div style={muted}>
|
|
|
|
|
For fallout carried by the real winds aloft, download the weather forecast every day: the winds
|
|
|
|
|
around the saved targets, from Open-Meteo, while there is the Internet.
|
|
|
|
|
</div>
|
|
|
|
|
<Button size="xs" style={{marginTop: "0.25rem"}} onClick={onEnable}>Download the forecast every day</Button>
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
if (downloading) {
|
|
|
|
|
return <div style={{...muted, marginBottom: "0.5rem"}}>
|
|
|
|
|
Downloading the forecast, which takes {downloadTime(weather.seconds)}. It is used once it is down.
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// What the user should know of the forecast, beside its fallout: bursts outside its winds, and rain.
|
|
|
|
|
function ForecastWarnings({prepared, bursts, hour}) {
|
|
|
|
|
const warning = {color: "var(--warning)", fontSize: "0.75rem"};
|
|
|
|
|
const outside = useMemo(() => bursts.filter((b) => !fieldCovers(prepared, b.lat, b.lon)).length,
|
|
|
|
|
[prepared, bursts]);
|
|
|
|
|
const rainy = useMemo(() => bursts.filter((b) => rainNear(prepared, b.lat, b.lon, hour) >= RAIN_WARNING_MM).length,
|
|
|
|
|
[prepared, bursts, hour]);
|
|
|
|
|
return <>
|
|
|
|
|
{outside > 0 && <div style={warning}>
|
|
|
|
|
{outside === 1 ? "1 burst is" : `${outside} bursts are`} outside the forecast's winds: the nearest
|
|
|
|
|
are used. The forecast is downloaded around the saved targets: save {outside === 1 ? "it" : "them"} to cover {outside === 1 ? "it" : "them"} the next time.
|
|
|
|
|
</div>}
|
|
|
|
|
{rainy > 0 && <div style={warning}>
|
|
|
|
|
Rain is forecast near {rainy === 1 ? "1 burst" : `${rainy} bursts`} in the 6 hours from then.
|
|
|
|
|
Rain washes fallout out of the air where it falls, which this map shows roughly; real rain is
|
|
|
|
|
patchier than a forecast, and its hot spots may be hotter.
|
|
|
|
|
</div>}
|
|
|
|
|
</>;
|
|
|
|
|
}
|