The Penguin Test: SCAR RAATD penguin tracks on the four maps, 3-day stretches against a penguin's top sustained speed (penguins.aethercosmology.com)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Corrections, new measurements and independent re-analyses are welcome,
|
Corrections, new measurements and independent re-analyses are welcome,
|
||||||
including ones that disagree with the results. Every figure on pingstats,
|
including ones that disagree with the results. Every figure on pingstats,
|
||||||
fe-map and iss-spoofing is rebuilt from this repository, so a change accepted here
|
fe-map, iss-spoofing and penguins is rebuilt from this repository, so a change accepted here
|
||||||
changes the published numbers. The Shape of Distance is included as published.
|
changes the published numbers. The Shape of Distance is included as published.
|
||||||
|
|
||||||
Issues and pull requests: https://git.aethercosmology.com/toby/cable-latency-survey. Register at
|
Issues and pull requests: https://git.aethercosmology.com/toby/cable-latency-survey. Register at
|
||||||
@@ -28,6 +28,7 @@ output, not only a summary.
|
|||||||
| Flight | Flight number and date for both directions, the track log URL (FlightAware or another ADS-B record), and the aircraft type. |
|
| Flight | Flight number and date for both directions, the track log URL (FlightAware or another ADS-B record), and the aircraft type. |
|
||||||
| Rail or road | The route and its published length, with the source. |
|
| Rail or road | The route and its published length, with the source. |
|
||||||
| Satellite pass | SatNOGS observation IDs, or raw recordings with station location and UTC timestamps. |
|
| Satellite pass | SatNOGS observation IDs, or raw recordings with station location and UTC timestamps. |
|
||||||
|
| Animal track | A published tracking dataset (DOI or repository link) with tag type, fix times and positions; speed or depth logger records where they exist. |
|
||||||
|
|
||||||
Routes in the southern hemisphere are the most informative: South America to
|
Routes in the southern hemisphere are the most informative: South America to
|
||||||
Africa and Australia, Africa to Australia, and New Zealand to anywhere.
|
Africa and Australia, Africa to Australia, and New Zealand to anywhere.
|
||||||
@@ -45,6 +46,7 @@ numbers change.
|
|||||||
| pingstats.aethercosmology.com | `src/` | `cd src && python3 build.py` |
|
| pingstats.aethercosmology.com | `src/` | `cd src && python3 build.py` |
|
||||||
| fe-map.aethercosmology.com | `femap/` | `cd femap && python3 build.py` (about 10 minutes) |
|
| fe-map.aethercosmology.com | `femap/` | `cd femap && python3 build.py` (about 10 minutes) |
|
||||||
| iss-spoofing.aethercosmology.com | `satellites/` | `cd satellites && python3 build.py` |
|
| iss-spoofing.aethercosmology.com | `satellites/` | `cd satellites && python3 build.py` |
|
||||||
|
| penguins.aethercosmology.com | `penguins/` | `cd penguins && ./fetch.sh && python3 build.py` |
|
||||||
| distance.aethercosmology.com | `src/handoff/The_Shape_of_Distance_PRESENTATION.html` | single published file |
|
| distance.aethercosmology.com | `src/handoff/The_Shape_of_Distance_PRESENTATION.html` | single published file |
|
||||||
|
|
||||||
Browser checks: `cd tests && npm install && CH=/path/to/chromium ./run.sh`.
|
Browser checks: `cd tests && npm install && CH=/path/to/chromium ./run.sh`.
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Attribution: *Cable Latency Survey (2026), https://pingstats.aethercosmology.com
|
|||||||
| FlightAware, flightsfrom.com | Flight times in The Shape of Distance and `femap/`: per-direction median airborne times derived from FlightAware track logs (each linked), schedules from flightsfrom.com (each route linked). The logs themselves are not redistributed. | © FlightAware; © flightsfrom.com; their terms apply to the underlying records. |
|
| FlightAware, flightsfrom.com | Flight times in The Shape of Distance and `femap/`: per-direction median airborne times derived from FlightAware track logs (each linked), schedules from flightsfrom.com (each route linked). The logs themselves are not redistributed. | © FlightAware; © flightsfrom.com; their terms apply to the underlying records. |
|
||||||
| CelesTrak | ISS orbital elements, `satellites/data/iss_25544_20261028.tle` | CelesTrak (data from the U.S. Space Force, space-track.org); CelesTrak's terms apply. |
|
| CelesTrak | ISS orbital elements, `satellites/data/iss_25544_20261028.tle` | CelesTrak (data from the U.S. Space Force, space-track.org); CelesTrak's terms apply. |
|
||||||
| SatNOGS (Libre Space Foundation) | ISS recordings and their timings in The Shape of Distance; `satellites/data/satnogs_20261003.json` and the values derived from them in `satellites/` | CC BY-SA 4.0. Attribution: SatNOGS Network, Libre Space Foundation. |
|
| SatNOGS (Libre Space Foundation) | ISS recordings and their timings in The Shape of Distance; `satellites/data/satnogs_20261003.json` and the values derived from them in `satellites/` | CC BY-SA 4.0. Attribution: SatNOGS Network, Libre Space Foundation. |
|
||||||
|
| SCAR RAATD (Retrospective Analysis of Antarctic Tracking Data), v1.5 | Penguin tracks in `penguins/data/penguins.json` and `penguins/site/`, derived from the standardised tracking data (downloaded by `penguins/fetch.sh`, not redistributed). | CC BY 4.0. Attribution: Ropert-Coudert Y, Van de Putte AP, et al. (2020), The retrospective analysis of Antarctic tracking data project, Scientific Data 7:94; data doi:10.15468/uzmdpm. |
|
||||||
| GeoNames | `src/raw/geonames/cities15000.txt` | CC BY 4.0, https://www.geonames.org |
|
| GeoNames | `src/raw/geonames/cities15000.txt` | CC BY 4.0, https://www.geonames.org |
|
||||||
| Natural Earth, via world-atlas | `src/raw/geo/land-110m.json` | Natural Earth: public domain. world-atlas: ISC. |
|
| Natural Earth, via world-atlas | `src/raw/geo/land-110m.json` | Natural Earth: public domain. world-atlas: ISC. |
|
||||||
| d3 | `src/raw/lib/d3.min.js`, embedded in the report | ISC, Mike Bostock. |
|
| d3 | `src/raw/lib/d3.min.js`, embedded in the report | ISC, Mike Bostock. |
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
# Cable Latency Survey
|
# Cable Latency Survey
|
||||||
|
|
||||||
Measurements, code and data behind four sites:
|
Measurements, code and data behind five sites:
|
||||||
|
|
||||||
| Site | Contents | Source |
|
| Site | Contents | Source |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| https://pingstats.aethercosmology.com | Measured round-trip times between cities, compared with the minimum propagation time along submarine-cable routes on a sphere, a North-pole azimuthal equidistant (AE) map, an AE map centred on 0°N 0°E ("dual-pole") and a flat Mercator map | `src/` |
|
| https://pingstats.aethercosmology.com | Measured round-trip times between cities, compared with the minimum propagation time along submarine-cable routes on a sphere, a North-pole azimuthal equidistant (AE) map, an AE map centred on 0°N 0°E ("dual-pole") and a flat Mercator map | `src/` |
|
||||||
| https://fe-map.aethercosmology.com | The best layout of 219 cities on a plane that a solver can find from timed flights, pings, rail and road lengths and satellite passes, and the same solve released into 3D | `femap/` |
|
| https://fe-map.aethercosmology.com | The best layout of 219 cities on a plane that a solver can find from timed flights, pings, rail and road lengths and satellite passes, and the same solve released into 3D | `femap/` |
|
||||||
| https://iss-spoofing.aethercosmology.com | The Sync Test: the ISS at its published-orbit position on the globe and three flat maps, with a spoofed radio signal moving at the speed measured by SatNOGS stations | `satellites/` |
|
| https://iss-spoofing.aethercosmology.com | The Sync Test: the ISS at its published-orbit position on the globe and three flat maps, with a spoofed radio signal moving at the speed measured by SatNOGS stations | `satellites/` |
|
||||||
|
| https://penguins.aethercosmology.com | The Penguin Test: 916 satellite-tracked penguins drawn to scale on the globe and three flat maps, each 3-day stretch tested against a penguin's top sustained speed | `penguins/` |
|
||||||
| https://distance.aethercosmology.com | The Shape of Distance: flights, triangles and satellite recordings | `src/handoff/The_Shape_of_Distance_PRESENTATION.html` |
|
| https://distance.aethercosmology.com | The Shape of Distance: flights, triangles and satellite recordings | `src/handoff/The_Shape_of_Distance_PRESENTATION.html` |
|
||||||
|
|
||||||
- Code: MIT (`LICENSE`). Measurements and derived data: CC BY 4.0, with third-party terms (`LICENSE-DATA.md`).
|
- Code: MIT (`LICENSE`). Measurements and derived data: CC BY 4.0, with third-party terms (`LICENSE-DATA.md`).
|
||||||
@@ -22,6 +23,7 @@ Measurements, code and data behind four sites:
|
|||||||
| `src/` | Pipeline code, raw logs and derived data (below). |
|
| `src/` | Pipeline code, raw logs and derived data (below). |
|
||||||
| `femap/` | fe-map: solver (`fit.py`), build (`build.py`, `template.html`), result (`data/femap.json`), page (`site/`). |
|
| `femap/` | fe-map: solver (`fit.py`), build (`build.py`, `template.html`), result (`data/femap.json`), page (`site/`). |
|
||||||
| `satellites/` | iss-spoofing: build (`build.py`, `template.html`), orbital elements and SatNOGS timings (`data/`), page (`site/`). |
|
| `satellites/` | iss-spoofing: build (`build.py`, `template.html`), orbital elements and SatNOGS timings (`data/`), page (`site/`). |
|
||||||
|
| `penguins/` | penguins: build (`build.py`, `template.html`), result (`data/penguins.json`), page (`site/`); `fetch.sh` downloads the SCAR tracking archive it reads (checked against `raw/raatd.sha256`). |
|
||||||
| `src/handoff/The_Shape_of_Distance_PRESENTATION.html` | The Shape of Distance as published; the flights, limits and triangles used by `femap/` and the SatNOGS timings used by `satellites/` are read from it. |
|
| `src/handoff/The_Shape_of_Distance_PRESENTATION.html` | The Shape of Distance as published; the flights, limits and triangles used by `femap/` and the SatNOGS timings used by `satellites/` are read from it. |
|
||||||
| `tests/` | Headless-browser checks of the sites (`tests/run.sh`). |
|
| `tests/` | Headless-browser checks of the sites (`tests/run.sh`). |
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,295 @@
|
|||||||
|
"""The Penguin Test: tracked penguins on the globe and three flat maps.
|
||||||
|
|
||||||
|
./fetch.sh -> raw/raatd/ (SCAR archive, checked against raw/raatd.sha256)
|
||||||
|
../.venv/bin/python build.py -> data/penguins.json, site/index.html
|
||||||
|
|
||||||
|
Data: The Retrospective Analysis of Antarctic Tracking (Standardised) Data from the
|
||||||
|
Scientific Committee on Antarctic Research, version 1.5 (Ropert-Coudert et al. 2020,
|
||||||
|
Scientific Data 7:94; GBIF DOI 10.15468/uzmdpm; CC BY 4.0). Penguin species only.
|
||||||
|
|
||||||
|
For every tracked penguin:
|
||||||
|
daily one position per UTC day: median time, median latitude, median longitude
|
||||||
|
(longitudes unwrapped around the day's first fix), to damp Argos error
|
||||||
|
lengths the track's length on each map, summing straight steps between daily
|
||||||
|
positions (models.py: globe, North-pole AE, dual-pole AE on 0N 0E; Mercator
|
||||||
|
with its east and west edges joined so that a track can cross 180 deg)
|
||||||
|
stretches every pair of daily positions three days apart; the speed each needs on each
|
||||||
|
map is (map distance - position allowance) / elapsed time
|
||||||
|
The limit: no penguin can cover more than (swim + current) x time + allowance:
|
||||||
|
swim 2.3 m/s, the fastest mean swimming speed measured in any penguin species
|
||||||
|
(gentoo and chinstrap; Sato et al. 2007, Proc. R. Soc. B 274:471-477,
|
||||||
|
table 1: emperor 1.7, Adelie 2.0, king 2.1 m/s)
|
||||||
|
current 1.0 m/s, about twice the strongest jets of the Antarctic Circumpolar Current
|
||||||
|
(typically 0.1 m/s, up to 0.5-0.6 m/s at the fronts)
|
||||||
|
allowance 50 km per stretch for position error at its two ends
|
||||||
|
and the limit assumes the bird swims flat out for the whole stretch, never diving,
|
||||||
|
resting or walking.
|
||||||
|
"""
|
||||||
|
import collections, datetime as dt, json, math, os, re, statistics, sys
|
||||||
|
|
||||||
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
SRC = os.path.join(HERE, "..", "src")
|
||||||
|
sys.path.insert(0, SRC)
|
||||||
|
from models import R, ae_xy, dualpole_xy, globe # 6371.0 km sphere shared with the cable survey
|
||||||
|
|
||||||
|
RAW = os.path.join(HERE, "raw", "raatd")
|
||||||
|
GENERA = ("Aptenodytes", "Pygoscelis", "Eudyptes", "Spheniscus", "Eudyptula", "Megadyptes")
|
||||||
|
V_SWIM = 2.3 # m/s
|
||||||
|
V_CURRENT = 1.0 # m/s
|
||||||
|
ERR_KM = 50.0 # km per stretch
|
||||||
|
WINDOW = 3 # days
|
||||||
|
LIMIT_KMH = (V_SWIM + V_CURRENT) * 3.6
|
||||||
|
MAPS = ["globe", "ae", "dualpole", "mercator"]
|
||||||
|
DEFAULT = ("Aptenodytes forsteri", "Pointe Geologie, Terre Adelie", "2005")
|
||||||
|
SOUTH_DETAIL = -35.0 # land polygons reaching south of this use 1:50m, the rest 1:110m
|
||||||
|
|
||||||
|
|
||||||
|
def merc_dist(a, b):
|
||||||
|
"""Straight line on a Mercator map, true on the equator, east and west edges joined."""
|
||||||
|
y = lambda lat: R * math.log(math.tan(math.pi / 4 + math.radians(max(-85.0, min(85.0, lat))) / 2))
|
||||||
|
dl = (b[1] - a[1] + 540.0) % 360.0 - 180.0
|
||||||
|
return math.hypot(R * math.radians(dl), y(b[0]) - y(a[0]))
|
||||||
|
|
||||||
|
|
||||||
|
def dist(m, a, b):
|
||||||
|
if m == "globe":
|
||||||
|
return globe(*a, *b)
|
||||||
|
if m == "ae":
|
||||||
|
(x1, y1), (x2, y2) = ae_xy(*a), ae_xy(*b)
|
||||||
|
elif m == "dualpole":
|
||||||
|
(x1, y1), (x2, y2) = dualpole_xy(*a), dualpole_xy(*b)
|
||||||
|
else:
|
||||||
|
return merc_dist(a, b)
|
||||||
|
return math.hypot(x2 - x1, y2 - y1)
|
||||||
|
|
||||||
|
|
||||||
|
def stamp(date, time):
|
||||||
|
"""'2005-11-01T00:46:02' or '2005-11-1' + '03:45:00Z' -> POSIX seconds (UTC)."""
|
||||||
|
s = date if "T" in date else date + "T" + (time.rstrip("Z") or "00:00:00")
|
||||||
|
m = re.match(r"(\d{4})-(\d{1,2})-(\d{1,2})T(\d{1,2}):(\d{2})(?::(\d{2}(?:\.\d+)?))?", s)
|
||||||
|
if not m:
|
||||||
|
return None
|
||||||
|
y, mo, d, h, mi, sec = m.groups()
|
||||||
|
return dt.datetime(int(y), int(mo), int(d), int(h), int(mi), int(float(sec or 0)), tzinfo=dt.timezone.utc).timestamp()
|
||||||
|
|
||||||
|
|
||||||
|
def read_rows(name):
|
||||||
|
with open(os.path.join(RAW, name), encoding="utf-8") as f:
|
||||||
|
head = f.readline().rstrip("\n").split("\t")
|
||||||
|
for line in f:
|
||||||
|
r = line.rstrip("\n").split("\t")
|
||||||
|
if len(r) >= len(head):
|
||||||
|
yield dict(zip(head, r))
|
||||||
|
|
||||||
|
|
||||||
|
def load():
|
||||||
|
meta = {}
|
||||||
|
for r in read_rows("event.txt"):
|
||||||
|
if not r["eventID"].startswith("capture:"):
|
||||||
|
continue
|
||||||
|
sp = r["samplingProtocol"]
|
||||||
|
dev = sp.split("device type=")[1].split(":")[0].strip() if "device type=" in sp else ""
|
||||||
|
meta[r["eventID"]] = dict(dev=dev, colony=r["locality"].strip(), year=r["year"], dataset=r["datasetID"],
|
||||||
|
clat=float(r["decimalLatitude"] or "nan"), clon=float(r["decimalLongitude"] or "nan"))
|
||||||
|
fixes = collections.defaultdict(list)
|
||||||
|
who = {}
|
||||||
|
for r in read_rows("occurrence.txt"):
|
||||||
|
if not r["scientificName"].startswith(GENERA):
|
||||||
|
continue
|
||||||
|
if "::capture" in r["occurrenceID"]:
|
||||||
|
who.setdefault(r["id"], {}).update(sex=r["sex"], stage=r["lifeStage"])
|
||||||
|
continue
|
||||||
|
t = stamp(r["eventDate"], r["eventTime"])
|
||||||
|
try:
|
||||||
|
lat, lon = float(r["decimalLatitude"]), float(r["decimalLongitude"])
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
if t is None or not (-90 <= lat <= 90 and -180 <= lon <= 180):
|
||||||
|
continue
|
||||||
|
fixes[r["id"]].append((t, lat, lon))
|
||||||
|
who.setdefault(r["id"], {}).update(sp=r["scientificName"], name=r["vernacularName"])
|
||||||
|
return meta, fixes, who
|
||||||
|
|
||||||
|
|
||||||
|
def daily(fx):
|
||||||
|
"""One position per UTC day: median time, latitude and (unwrapped) longitude."""
|
||||||
|
by = collections.defaultdict(list)
|
||||||
|
for t, la, lo in sorted(fx):
|
||||||
|
by[int(t // 86400)].append((t, la, lo))
|
||||||
|
out = []
|
||||||
|
for d in sorted(by):
|
||||||
|
v = by[d]
|
||||||
|
l0 = v[0][2]
|
||||||
|
lons = [l0 + ((lo - l0 + 540.0) % 360.0 - 180.0) for _, _, lo in v]
|
||||||
|
lon = (statistics.median(lons) + 540.0) % 360.0 - 180.0
|
||||||
|
out.append((d, statistics.median(t for t, _, _ in v), statistics.median(la for _, la, _ in v), lon, len(v)))
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def track_stats(D):
|
||||||
|
"""Lengths on each map and the 3-day stretch that needs the highest speed on each map."""
|
||||||
|
P = [(x[2], x[3]) for x in D]
|
||||||
|
st = {}
|
||||||
|
for m in MAPS:
|
||||||
|
length = sum(dist(m, P[i - 1], P[i]) for i in range(1, len(P)))
|
||||||
|
best = None
|
||||||
|
for i in range(len(D)):
|
||||||
|
for j in range(i + 1, len(D)):
|
||||||
|
if D[j][0] - D[i][0] > WINDOW:
|
||||||
|
break
|
||||||
|
if D[j][0] - D[i][0] < WINDOW:
|
||||||
|
continue
|
||||||
|
hours = (D[j][1] - D[i][1]) / 3600
|
||||||
|
if hours < 24 * (WINDOW - 1):
|
||||||
|
continue
|
||||||
|
km = dist(m, P[i], P[j])
|
||||||
|
need = max(0.0, km - ERR_KM) / hours
|
||||||
|
if best is None or need > best[0]:
|
||||||
|
best = (need, km, hours, i, j)
|
||||||
|
st[m] = dict(len=length, need=best[0] if best else None, km=best[1] if best else None,
|
||||||
|
h=best[2] if best else None, i=best[3] if best else None, j=best[4] if best else None)
|
||||||
|
return st
|
||||||
|
|
||||||
|
|
||||||
|
def land(path, nd=2):
|
||||||
|
"""TopoJSON land -> list of polygons (rings of [lon, lat])."""
|
||||||
|
t = json.load(open(path))
|
||||||
|
sx, sy = t["transform"]["scale"]
|
||||||
|
tx, ty = t["transform"]["translate"]
|
||||||
|
arcs = []
|
||||||
|
for arc in t["arcs"]:
|
||||||
|
x = y = 0
|
||||||
|
pts = []
|
||||||
|
for dx, dy in arc:
|
||||||
|
x += dx; y += dy
|
||||||
|
pts.append([round(x * sx + tx, nd), round(y * sy + ty, nd)])
|
||||||
|
arcs.append(pts)
|
||||||
|
|
||||||
|
def ring(idx):
|
||||||
|
out = []
|
||||||
|
for i in idx:
|
||||||
|
a = arcs[i] if i >= 0 else arcs[~i][::-1]
|
||||||
|
out.extend(a if not out else a[1:])
|
||||||
|
return out
|
||||||
|
polys = []
|
||||||
|
for g in t["objects"]["land"]["geometries"]:
|
||||||
|
if g["type"] == "Polygon":
|
||||||
|
polys.append([ring(r) for r in g["arcs"]])
|
||||||
|
elif g["type"] == "MultiPolygon":
|
||||||
|
polys.extend([[ring(r) for r in p] for p in g["arcs"]])
|
||||||
|
return polys
|
||||||
|
|
||||||
|
|
||||||
|
def coast():
|
||||||
|
"""1:50m for land reaching south of SOUTH_DETAIL (Antarctica, the sub-Antarctic islands, the
|
||||||
|
southern continents' tips), 1:110m elsewhere."""
|
||||||
|
south = lambda p: min(y for _, y in p[0]) < SOUTH_DETAIL
|
||||||
|
fine = [p for p in land(os.path.join(SRC, "raw", "geo", "land-50m.json")) if south(p)]
|
||||||
|
coarse = [p for p in land(os.path.join(SRC, "raw", "geo", "land-110m.json")) if not south(p)]
|
||||||
|
return coarse + fine
|
||||||
|
|
||||||
|
|
||||||
|
SPECIES = {"Aptenodytes forsteri": "Emperor penguin", "Aptenodytes patagonicus": "King penguin",
|
||||||
|
"Pygoscelis adeliae": "Adélie penguin", "Eudyptes chrysolophus": "Macaroni penguin",
|
||||||
|
"Eudyptes schlegeli": "Royal penguin"}
|
||||||
|
COLONY_FIX = {"Pointe Geologie, Terre Adelie": "Pointe Géologie, Terre Adélie"}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
meta, fixes, who = load()
|
||||||
|
tracks = []
|
||||||
|
for iid, fx in fixes.items():
|
||||||
|
D = daily(fx)
|
||||||
|
if len(D) < 2:
|
||||||
|
continue
|
||||||
|
m = meta.get(iid, {})
|
||||||
|
st = track_stats(D)
|
||||||
|
d0 = D[0][0]
|
||||||
|
tracks.append(dict(
|
||||||
|
id=iid.replace("capture:", ""), sp=who[iid]["sp"], colony=m.get("colony", ""), year=m.get("year", ""),
|
||||||
|
dev=m.get("dev", ""), sex=who[iid].get("sex", ""), stage=who[iid].get("stage", ""), dataset=m.get("dataset", ""),
|
||||||
|
start=dt.datetime.fromtimestamp(D[0][1], dt.timezone.utc).strftime("%Y-%m-%d"),
|
||||||
|
end=dt.datetime.fromtimestamp(D[-1][1], dt.timezone.utc).strftime("%Y-%m-%d"),
|
||||||
|
fixes=len(fx), d=[x[0] - d0 for x in D], lat=[round(x[2], 3) for x in D], lon=[round(x[3], 3) for x in D],
|
||||||
|
st={k: {kk: (round(vv, 3) if isinstance(vv, float) else vv) for kk, vv in v.items()} for k, v in st.items()}))
|
||||||
|
tracks.sort(key=lambda t: (t["sp"], t["colony"], t["year"], t["start"], t["id"]))
|
||||||
|
tested = [t for t in tracks if t["st"]["globe"]["need"] is not None]
|
||||||
|
|
||||||
|
# summaries at the default limit
|
||||||
|
def beyond(t, m, lim=LIMIT_KMH):
|
||||||
|
return t["st"][m]["need"] is not None and t["st"][m]["need"] > lim
|
||||||
|
by_sp = collections.OrderedDict()
|
||||||
|
for sp in sorted({t["sp"] for t in tracks}, key=lambda s: -sum(t["sp"] == s for t in tracks)):
|
||||||
|
v = [t for t in tested if t["sp"] == sp]
|
||||||
|
by_sp[sp] = dict(name=SPECIES.get(sp, sp), tracks=sum(t["sp"] == sp for t in tracks), tested=len(v),
|
||||||
|
beyond={m: sum(beyond(t, m) for t in v) for m in MAPS},
|
||||||
|
med_need={m: round(statistics.median(t["st"][m]["need"] for t in v), 2) if v else None for m in MAPS},
|
||||||
|
med_len={m: round(statistics.median(t["st"][m]["len"] for t in v)) if v else None for m in MAPS})
|
||||||
|
tot = dict(tracks=len(tracks), tested=len(tested), beyond={m: sum(beyond(t, m) for t in tested) for m in MAPS},
|
||||||
|
days=sum(len(t["d"]) for t in tracks), fixes=sum(t["fixes"] for t in tracks),
|
||||||
|
colonies=len({t["colony"] for t in tracks}), years=[min(t["year"] for t in tracks), max(t["year"] for t in tracks)],
|
||||||
|
devices=dict(collections.Counter(t["dev"] or "unrecorded" for t in tracks)),
|
||||||
|
ratio_ae=round(statistics.median(t["st"]["ae"]["len"] / t["st"]["globe"]["len"] for t in tracks if t["st"]["globe"]["len"] > 50), 2))
|
||||||
|
groups = collections.OrderedDict()
|
||||||
|
for t in tracks:
|
||||||
|
k = f'{t["sp"]}|{t["colony"]}|{t["year"]}'
|
||||||
|
groups.setdefault(k, dict(sp=t["sp"], colony=COLONY_FIX.get(t["colony"], t["colony"]), year=t["year"], n=0))["n"] += 1
|
||||||
|
film = [t for t in tested if (t["sp"], t["colony"], t["year"]) == DEFAULT]
|
||||||
|
out = dict(tracks=tracks, groups=groups, species=by_sp, total=tot, film=dict(n=len(film), beyond={m: sum(beyond(t, m) for t in film) for m in MAPS}),
|
||||||
|
default="|".join(DEFAULT), limit=dict(v_swim=V_SWIM, v_current=V_CURRENT, err_km=ERR_KM, window=WINDOW, kmh=round(LIMIT_KMH, 2)),
|
||||||
|
names=SPECIES, colony_fix=COLONY_FIX, land=coast(),
|
||||||
|
built=dt.datetime.now(dt.timezone.utc).strftime("%Y-%m-%d %H:%M UTC"))
|
||||||
|
os.makedirs(os.path.join(HERE, "data"), exist_ok=True)
|
||||||
|
with open(os.path.join(HERE, "data", "penguins.json"), "w") as fh:
|
||||||
|
json.dump(out, fh, separators=(",", ":"))
|
||||||
|
print(f"{tot['tracks']} tracks ({tot['tested']} with a {WINDOW}-day stretch), {tot['days']} daily positions from {tot['fixes']} fixes, "
|
||||||
|
f"{len(groups)} colony-seasons; limit {LIMIT_KMH:.2f} km/h + {ERR_KM:.0f} km")
|
||||||
|
for sp, s in by_sp.items():
|
||||||
|
print(f" {s['name']:16s} {s['tested']:4d} tested | beyond the limit: " + " ".join(f"{m} {s['beyond'][m]}" for m in MAPS))
|
||||||
|
print(" all", tot["beyond"], "| film colony 2005:", out["film"])
|
||||||
|
render(out)
|
||||||
|
|
||||||
|
|
||||||
|
def fmt(n):
|
||||||
|
return f"{n:,}"
|
||||||
|
|
||||||
|
|
||||||
|
def copy_values(o):
|
||||||
|
t, sp, f, L = o["total"], o["species"], o["film"], o["limit"]
|
||||||
|
pct = lambda k: f"{100 * k / t['tested']:.0f}%"
|
||||||
|
v = dict(
|
||||||
|
N_TRACKS=fmt(t["tracks"]), N_TESTED=fmt(t["tested"]), N_DAYS=fmt(t["days"]), N_FIXES=fmt(t["fixes"]),
|
||||||
|
N_SPECIES=str(len(sp)), N_COLONIES=fmt(t["colonies"]), Y0=t["years"][0], Y1=t["years"][1],
|
||||||
|
LIMIT=f"{L['kmh']:.1f}", V_SWIM=f"{L['v_swim']:.1f}", V_CURRENT=f"{L['v_current']:.1f}", ERR=f"{L['err_km']:.0f}", WINDOW=str(L["window"]),
|
||||||
|
MIN_H=str(24 * (L["window"] - 1)),
|
||||||
|
RATIO_AE=f"{t['ratio_ae']:.1f}",
|
||||||
|
G_BEYOND=fmt(t["beyond"]["globe"]), AE_BEYOND=fmt(t["beyond"]["ae"]), DP_BEYOND=fmt(t["beyond"]["dualpole"]), ME_BEYOND=fmt(t["beyond"]["mercator"]),
|
||||||
|
AE_PCT=pct(t["beyond"]["ae"]), DP_PCT=pct(t["beyond"]["dualpole"]), ME_PCT=pct(t["beyond"]["mercator"]), G_PCT=pct(t["beyond"]["globe"]),
|
||||||
|
FILM_N=str(f["n"]), FILM_AE=str(f["beyond"]["ae"]), FILM_G=str(f["beyond"]["globe"]), FILM_DP=str(f["beyond"]["dualpole"]), FILM_ME=str(f["beyond"]["mercator"]),
|
||||||
|
DEVICES=", ".join(f"{fmt(n)} {k}" for k, n in sorted(t["devices"].items(), key=lambda x: -x[1])),
|
||||||
|
BUILT=o["built"],
|
||||||
|
)
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
def render(out):
|
||||||
|
tpl = os.path.join(HERE, "template.html")
|
||||||
|
if not os.path.exists(tpl):
|
||||||
|
return
|
||||||
|
html = open(tpl, encoding="utf-8").read()
|
||||||
|
for k, v in copy_values(out).items():
|
||||||
|
html = html.replace("{{" + k + "}}", v)
|
||||||
|
left = sorted(set(re.findall(r"\{\{(\w+)\}\}", html)))
|
||||||
|
assert not left, left
|
||||||
|
d3 = open(os.path.join(SRC, "raw", "lib", "d3.min.js"), encoding="utf-8").read()
|
||||||
|
html = html.replace("/*D3*/", d3).replace("/*DATA*/null", json.dumps(out, separators=(",", ":"), ensure_ascii=False))
|
||||||
|
os.makedirs(os.path.join(HERE, "site"), exist_ok=True)
|
||||||
|
open(os.path.join(HERE, "site", "index.html"), "w", encoding="utf-8").write(html)
|
||||||
|
print("site/index.html", round(len(html) / 1e6, 2), "MB")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) > 1 and sys.argv[1] == "render":
|
||||||
|
render(json.load(open(os.path.join(HERE, "data", "penguins.json"))))
|
||||||
|
else:
|
||||||
|
main()
|
||||||
File diff suppressed because one or more lines are too long
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Fetch the SCAR Retrospective Analysis of Antarctic Tracking (Standardised) Data, v1.5 (CC BY 4.0;
|
||||||
|
# GBIF doi:10.15468/uzmdpm), the input of build.py, into raw/, and check it against the copy used.
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
mkdir -p raw
|
||||||
|
curl -sSL -o raw/dwca-scar_raatd_trackingdata-v1.5.zip 'https://ipt.biodiversity.aq/archive.do?r=scar_raatd_trackingdata&v=1.5'
|
||||||
|
(cd raw && sha256sum -c --quiet raatd.sha256 && echo "RAATD v1.5 identical to the copy used") || echo "note: the archive differs from the copy used (raw/raatd.sha256)"
|
||||||
|
unzip -o -q raw/dwca-scar_raatd_trackingdata-v1.5.zip -d raw/raatd
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
b1f6e07dfa076008b29042b89153e2be3b1841bd0847144bc3abf9ec4d1acfe0 dwca-scar_raatd_trackingdata-v1.5.zip
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
@@ -0,0 +1,468 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
<title>The Penguin Test</title>
|
||||||
|
<meta name="description" content="{{N_TRACKS}} satellite-tracked penguins on the globe and three flat maps. No track needs more than a penguin's speed on the globe; on the North-pole AE map {{AE_BEYOND}} of {{N_TESTED}} do.">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:title" content="The Penguin Test">
|
||||||
|
<meta property="og:description" content="{{N_TRACKS}} tracked penguins drawn to scale on four maps. On the globe every track fits a penguin's speed; on the North-pole AE map {{AE_BEYOND}} of {{N_TESTED}} need more.">
|
||||||
|
<meta property="og:url" content="https://penguins.aethercosmology.com/">
|
||||||
|
<meta property="og:image" content="https://penguins.aethercosmology.com/og.png">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='13' fill='%23081120' stroke='%233ee6ff' stroke-width='2'/%3E%3Cpath d='M7 20c4-6 9-9 18-8' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='25' cy='12' r='2.6' fill='%23ff4d5e'/%3E%3C/svg%3E">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap">
|
||||||
|
<style>
|
||||||
|
/* Layout: four synchronised map panels in a row on wide screens (2 / 1 columns below), readouts under each; text in a ~74ch column above and below. Same system as The Sync Test. */
|
||||||
|
:root{
|
||||||
|
--bg:#02050c; --panel:#07101e; --panel2:#0b182b; --line:rgba(120,180,255,.14); --line2:rgba(120,180,255,.28);
|
||||||
|
--ink:#e8f0fb; --dim:#9badc6; --faint:#65789a;
|
||||||
|
--track:#3ee6ff; --ok:#3dffa0; --warn:#ffc94a; --bad:#ff4d5e;
|
||||||
|
--disp:"Space Grotesk","Inter",system-ui,sans-serif;
|
||||||
|
--sans:"Inter",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
|
||||||
|
--mono:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace;
|
||||||
|
color-scheme:dark;
|
||||||
|
}
|
||||||
|
*{box-sizing:border-box}
|
||||||
|
html{background:var(--bg)}
|
||||||
|
body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.6 var(--sans);-webkit-font-smoothing:antialiased;
|
||||||
|
padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
|
||||||
|
body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);z-index:20;background:var(--bg)}
|
||||||
|
a{color:var(--track);text-decoration-color:rgba(62,230,255,.35);text-underline-offset:2px}
|
||||||
|
a:hover{text-decoration-color:var(--track)}
|
||||||
|
:focus-visible{outline:2px solid var(--track);outline-offset:2px}
|
||||||
|
.wrap{max-width:1720px;margin:0 auto;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
|
||||||
|
.top{padding-block:28px 6px}
|
||||||
|
h1{font:700 clamp(28px,3.2vw,40px)/1.1 var(--disp);margin:0;letter-spacing:-.01em;text-wrap:balance}
|
||||||
|
.sub{margin:6px 0 0;color:var(--dim);font-size:15px}
|
||||||
|
.intro{display:grid;gap:10px 40px;padding-block:14px 18px}
|
||||||
|
@media (min-width:1100px){.intro{grid-template-columns:repeat(3,minmax(0,52ch))}}
|
||||||
|
.intro p{margin:0;max-width:74ch;color:var(--ink)}
|
||||||
|
.intro b{font-family:var(--disp);font-weight:600;color:var(--dim);letter-spacing:.01em}
|
||||||
|
.k-tr{color:var(--track);font-weight:600}.k-bad{color:var(--bad);font-weight:600}
|
||||||
|
|
||||||
|
.bar{position:sticky;top:env(safe-area-inset-top,0px);z-index:10;background:rgba(2,5,12,.9);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);border-block:1px solid var(--line)}
|
||||||
|
.barin{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;padding-block:9px}
|
||||||
|
.row2{padding-block:0 9px;gap:8px 22px}
|
||||||
|
.rowlab{font:500 10.5px var(--sans);letter-spacing:.07em;text-transform:uppercase;color:var(--faint)}
|
||||||
|
@media (max-width:620px){.bar{position:static}}
|
||||||
|
button,select{font:inherit;color:inherit}
|
||||||
|
#grp{min-width:0;max-width:100%;flex:0 1 430px;background:var(--panel2);border:1px solid var(--line2);border-radius:8px;padding:6px 10px;font:500 13px var(--sans);color:var(--ink)}
|
||||||
|
#play{width:38px;height:34px;border-radius:8px;border:1px solid var(--line2);background:var(--panel2);cursor:pointer;display:grid;place-items:center;flex:none}
|
||||||
|
#play svg{width:14px;height:14px;fill:var(--ink)}
|
||||||
|
.seg{display:flex;border:1px solid var(--line2);border-radius:8px;overflow:hidden}
|
||||||
|
.seg button{border:0;background:transparent;padding:6px 10px;font:500 12.5px var(--sans);color:var(--dim);cursor:pointer}
|
||||||
|
.seg.mono button{font-family:var(--mono)}
|
||||||
|
.seg button+button{border-left:1px solid var(--line)}
|
||||||
|
.seg button[aria-pressed="true"]{background:var(--panel2);color:var(--ink)}
|
||||||
|
#day{flex:1 1 200px;min-width:140px;accent-color:var(--track)}
|
||||||
|
.clock{display:flex;gap:12px;font:500 13px var(--mono);color:var(--dim);font-variant-numeric:tabular-nums;white-space:nowrap}
|
||||||
|
.clock b{color:var(--ink);font-weight:500}
|
||||||
|
.lim{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--dim)}
|
||||||
|
#lim{width:140px;accent-color:var(--bad)}
|
||||||
|
#limv{font:500 12.5px var(--mono);color:var(--ink);min-width:6.5em}
|
||||||
|
|
||||||
|
.legend{display:flex;flex-wrap:wrap;gap:6px 18px;padding-block:12px 0;margin-block:0;list-style:none;color:var(--dim);font-size:13px}
|
||||||
|
.legend li{display:flex;align-items:center;gap:7px}
|
||||||
|
.legend svg{width:22px;height:14px;flex:none}
|
||||||
|
|
||||||
|
.grid{display:grid;gap:12px;grid-template-columns:repeat(4,minmax(0,1fr));padding-block:12px 8px}
|
||||||
|
@media (max-width:1199px){.grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
||||||
|
@media (max-width:620px){.grid{grid-template-columns:minmax(0,1fr)}}
|
||||||
|
.panel{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:10px 10px 8px;display:flex;flex-direction:column;gap:8px;min-width:0}
|
||||||
|
.ph{display:flex;align-items:baseline;justify-content:space-between;gap:10px;min-width:0}
|
||||||
|
.ph h2{font:600 16px/1.2 var(--disp);margin:0}
|
||||||
|
.ph p{margin:0;color:var(--faint);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||||
|
.map{position:relative;aspect-ratio:1;width:100%;max-width:100%}
|
||||||
|
.map canvas{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:pan-y}
|
||||||
|
.ro{display:grid;grid-template-columns:1fr 1fr;gap:6px 10px;margin:0}
|
||||||
|
.ro div{min-width:0}
|
||||||
|
.ro .w{grid-column:1/-1}
|
||||||
|
.ro .w dd{white-space:normal;overflow:visible}
|
||||||
|
.ro dt{font:500 10.5px/1.3 var(--sans);letter-spacing:.07em;text-transform:uppercase;color:var(--faint)}
|
||||||
|
.ro dd{margin:1px 0 0;font:500 13px/1.35 var(--mono);font-variant-numeric:tabular-nums;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||||
|
.pill{display:inline-block;margin-left:6px;padding:0 6px;border-radius:999px;font-size:11.5px;line-height:18px;border:1px solid currentColor}
|
||||||
|
.pill.ok{color:var(--ok)}.pill.bad{color:var(--bad)}
|
||||||
|
|
||||||
|
.after{padding-block:22px 10px;display:grid;gap:10px}
|
||||||
|
.after h2{font:600 19px/1.25 var(--disp);margin:14px 0 2px}
|
||||||
|
.after p b{color:var(--ink);font-weight:600}
|
||||||
|
.after p{margin:0;max-width:74ch;color:var(--dim)}
|
||||||
|
.tw{overflow:auto;border:1px solid var(--line);border-radius:10px;max-width:1180px}
|
||||||
|
.tw.scroll{max-height:420px}
|
||||||
|
table{border-collapse:collapse;width:100%;min-width:640px;font-size:13.5px}
|
||||||
|
th,td{padding:7px 12px;text-align:right;border-bottom:1px solid var(--line);white-space:nowrap}
|
||||||
|
tr:last-child td,tr:last-child th{border-bottom:0}
|
||||||
|
thead th{font:600 12.5px var(--disp);color:var(--dim);background:var(--panel);position:sticky;top:0;z-index:1}
|
||||||
|
tbody th{text-align:left;font-weight:500;color:var(--dim)}
|
||||||
|
td{font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--ink)}
|
||||||
|
td.bad{color:var(--bad)}td.na{color:var(--faint)}
|
||||||
|
td.l{text-align:left;font-family:var(--sans)}
|
||||||
|
.method{display:grid;grid-template-columns:max-content minmax(0,74ch);gap:8px 20px;margin:0;color:var(--dim)}
|
||||||
|
.method dt{font:600 13.5px var(--disp);color:var(--ink);padding-top:1px}
|
||||||
|
.method dd{margin:0}
|
||||||
|
@media (max-width:620px){.method{grid-template-columns:minmax(0,1fr);gap:2px}.method dd{margin-bottom:10px}}
|
||||||
|
.refs{margin:0;padding-left:1.2em;color:var(--dim);max-width:92ch;display:grid;gap:4px}
|
||||||
|
#dl{justify-self:start;border:1px solid var(--line2);background:var(--panel2);border-radius:8px;padding:7px 14px;cursor:pointer;font-size:13.5px}
|
||||||
|
footer{padding-block:18px 30px;color:var(--faint);font-size:13px}
|
||||||
|
#tip{position:fixed;z-index:30;pointer-events:none;background:rgba(6,12,24,.96);border:1px solid var(--line2);border-radius:8px;padding:6px 9px;font-size:12.5px;line-height:1.4;max-width:270px}
|
||||||
|
#tip b{font-weight:600}
|
||||||
|
#tip span{display:block;color:var(--dim)}
|
||||||
|
@media (prefers-reduced-motion:reduce){*{scroll-behavior:auto}}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="wrap top">
|
||||||
|
<h1>The Penguin Test</h1>
|
||||||
|
<p class="sub">{{N_TRACKS}} tracked penguins on the globe and three flat maps</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section class="wrap intro">
|
||||||
|
<p><b>Data.</b> {{N_TRACKS}} penguins of {{N_SPECIES}} species tracked from {{N_COLONIES}} colonies around Antarctica and the sub-Antarctic islands, {{Y0}}–{{Y1}}: {{N_FIXES}} positions from satellite tags and GPS loggers, compiled by SCAR's Retrospective Analysis of Antarctic Tracking Data. The first selection is the emperor colony at Pointe Géologie, Terre Adélie, where <i>March of the Penguins</i> was filmed, tracked in 2005.</p>
|
||||||
|
<p><b>Test.</b> Each track is drawn to scale on every map and measured there. In {{WINDOW}} days a penguin can travel no farther than {{V_SWIM}} m/s of swimming, the fastest mean speed measured in any penguin species, plus {{V_CURRENT}} m/s of current, about twice the strongest jets of the Antarctic Circumpolar Current, with no time spent diving or resting, plus {{ERR}} km for position error: {{LIMIT}} km/h. A track turns <span class="k-bad">red</span> on a map where some {{WINDOW}}-day stretch needs more.</p>
|
||||||
|
<p><b>Positions.</b> The positions are those computed by the tags' location systems, Argos and GPS, which work on a globe. The test asks whether the same positions, drawn to scale on each map, describe journeys a penguin can make.</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="bar">
|
||||||
|
<div class="wrap barin">
|
||||||
|
<label class="rowlab" for="grp">Colony</label>
|
||||||
|
<select id="grp" aria-label="Colony and season"></select>
|
||||||
|
<button id="play" type="button" aria-label="Play"><svg viewBox="0 0 14 14" aria-hidden="true"><path id="playicon" d="M3 1.5v11l9-5.5z"/></svg></button>
|
||||||
|
<div class="seg mono" role="group" aria-label="Playback speed" id="rates">
|
||||||
|
<button type="button" data-rate="1" aria-pressed="false">1 d/s</button>
|
||||||
|
<button type="button" data-rate="4" aria-pressed="true">4 d/s</button>
|
||||||
|
<button type="button" data-rate="15" aria-pressed="false">15 d/s</button>
|
||||||
|
</div>
|
||||||
|
<input id="day" type="range" min="0" max="1" step="0.05" value="1" aria-label="Days since tagging">
|
||||||
|
<div class="clock"><b id="clock">—</b><span id="span">—</span></div>
|
||||||
|
</div>
|
||||||
|
<div class="wrap barin row2">
|
||||||
|
<span class="rowlab">View</span>
|
||||||
|
<div class="seg" role="group" aria-label="View" id="view">
|
||||||
|
<button type="button" data-v="fit" aria-pressed="true">Tracks</button>
|
||||||
|
<button type="button" data-v="all" aria-pressed="false">Whole map</button>
|
||||||
|
</div>
|
||||||
|
<label class="lim" for="lim"><span class="rowlab">Speed limit</span><input id="lim" type="range" min="6" max="24" step="0.1" value="{{LIMIT}}"><output id="limv">{{LIMIT}} km/h</output></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="wrap legend">
|
||||||
|
<li><svg viewBox="0 0 22 14" aria-hidden="true"><path d="M1 7h20" stroke="#3ee6ff" stroke-width="1.6"/></svg>Track within the speed limit on that map</li>
|
||||||
|
<li><svg viewBox="0 0 22 14" aria-hidden="true"><path d="M1 7h20" stroke="#ff4d5e" stroke-width="1.6"/></svg>Track beyond it</li>
|
||||||
|
<li><svg viewBox="0 0 22 14" aria-hidden="true"><path d="M1 7h20" stroke="#ff4d5e" stroke-width="3.6"/></svg>Its fastest {{WINDOW}}-day stretch</li>
|
||||||
|
<li><svg viewBox="0 0 22 14" aria-hidden="true"><circle cx="11" cy="7" r="3.2" fill="#fff"/></svg>Penguin on the day shown</li>
|
||||||
|
<li><svg viewBox="0 0 22 14" aria-hidden="true"><circle cx="11" cy="7" r="4.5" fill="none" stroke="#ffc94a" stroke-width="1.6"/></svg>Colony</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<main class="wrap grid">
|
||||||
|
<article class="panel" data-key="globe">
|
||||||
|
<header class="ph"><h2>Globe</h2><p>Sphere, radius 6,371 km</p></header>
|
||||||
|
<div class="map"><canvas aria-label="Globe: penguin tracks"></canvas></div>
|
||||||
|
<dl class="ro">
|
||||||
|
<div><dt>Track length, median</dt><dd data-f="len">—</dd></div>
|
||||||
|
<div><dt>Beyond the limit</dt><dd data-f="n">—</dd></div>
|
||||||
|
<div class="w"><dt>Fastest {{WINDOW}}-day stretch</dt><dd data-f="v">—</dd></div>
|
||||||
|
</dl>
|
||||||
|
</article>
|
||||||
|
<article class="panel" data-key="ae">
|
||||||
|
<header class="ph"><h2>North-pole AE</h2><p>Centered on the North Pole</p></header>
|
||||||
|
<div class="map"><canvas aria-label="North-pole AE map: penguin tracks"></canvas></div>
|
||||||
|
<dl class="ro">
|
||||||
|
<div><dt>Track length, median</dt><dd data-f="len">—</dd></div>
|
||||||
|
<div><dt>Beyond the limit</dt><dd data-f="n">—</dd></div>
|
||||||
|
<div class="w"><dt>Fastest {{WINDOW}}-day stretch</dt><dd data-f="v">—</dd></div>
|
||||||
|
</dl>
|
||||||
|
</article>
|
||||||
|
<article class="panel" data-key="dualpole">
|
||||||
|
<header class="ph"><h2>Dual-pole AE</h2><p>Centered on 0°N 0°E</p></header>
|
||||||
|
<div class="map"><canvas aria-label="Dual-pole AE map: penguin tracks"></canvas></div>
|
||||||
|
<dl class="ro">
|
||||||
|
<div><dt>Track length, median</dt><dd data-f="len">—</dd></div>
|
||||||
|
<div><dt>Beyond the limit</dt><dd data-f="n">—</dd></div>
|
||||||
|
<div class="w"><dt>Fastest {{WINDOW}}-day stretch</dt><dd data-f="v">—</dd></div>
|
||||||
|
</dl>
|
||||||
|
</article>
|
||||||
|
<article class="panel" data-key="mercator">
|
||||||
|
<header class="ph"><h2>Mercator</h2><p>True on the equator, edges joined</p></header>
|
||||||
|
<div class="map"><canvas aria-label="Mercator map: penguin tracks"></canvas></div>
|
||||||
|
<dl class="ro">
|
||||||
|
<div><dt>Track length, median</dt><dd data-f="len">—</dd></div>
|
||||||
|
<div><dt>Beyond the limit</dt><dd data-f="n">—</dd></div>
|
||||||
|
<div class="w"><dt>Fastest {{WINDOW}}-day stretch</dt><dd data-f="v">—</dd></div>
|
||||||
|
</dl>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<section class="wrap after">
|
||||||
|
<h2 id="seltitle">Selected penguins</h2>
|
||||||
|
<div class="tw scroll"><table id="animals"><thead></thead><tbody></tbody></table></div>
|
||||||
|
|
||||||
|
<h2>Result</h2>
|
||||||
|
<p>Of the {{N_TESTED}} tracks long enough to contain a {{WINDOW}}-day stretch, <b>none needs more than {{LIMIT}} km/h on the globe</b>. On the North-pole AE map <b>{{AE_BEYOND}} ({{AE_PCT}}) do</b>, on Mercator {{ME_BEYOND}} and on the dual-pole AE map {{DP_BEYOND}}. At Pointe Géologie, {{FILM_AE}} of the {{FILM_N}} emperors tagged in 2005 need more than the limit on the North-pole map and {{FILM_G}} on the globe.</p>
|
||||||
|
<p>The North-pole map keeps north–south distances true and stretches east–west ones more the farther they lie from its center: by a factor of about 7 at the latitude of the Antarctic coast. A median track is {{RATIO_AE}} times as long there as on the globe. Mercator stretches distances by the secant of the latitude, 2.5 at 66°S. The dual-pole map, centered on the equator, stretches the far south by up to about 2 in one direction, and these tracks alone do not rule it out. The flight times in <a href="https://fe-map.aethercosmology.com/">The Best Flat Map</a> rule out every flat map, this one included.</p>
|
||||||
|
<div class="tw"><table id="species"><thead></thead><tbody></tbody></table></div>
|
||||||
|
|
||||||
|
<h2>Method</h2>
|
||||||
|
<dl class="method">
|
||||||
|
<dt>Data</dt><dd>SCAR Retrospective Analysis of Antarctic Tracking Data, standardized tracking data version 1.5: penguin species only ({{N_TRACKS}} tracks: {{DEVICES}}). Each track is one tagged bird, from the capture record to its last position.</dd>
|
||||||
|
<dt>Positions</dt><dd>As published. Argos positions are computed from the Doppler shift of the tag's transmissions as recorded by polar-orbiting satellites; GPS positions from satellite ranging; both are expressed as latitude and longitude on the WGS 84 ellipsoid. No position is filtered on speed or on any map.</dd>
|
||||||
|
<dt>Daily positions</dt><dd>One per UTC day: the median time, latitude and longitude of that day's fixes ({{N_DAYS}} daily positions in all), to damp the error of single Argos fixes. Longitudes are unwrapped around the day's first fix before the median.</dd>
|
||||||
|
<dt>Lengths</dt><dd>On each map, the sum of straight steps between consecutive daily positions: great-circle steps on the globe, straight lines across the plane on the flat maps.</dd>
|
||||||
|
<dt>Stretches</dt><dd>Every pair of daily positions {{WINDOW}} days apart, with the elapsed time taken from their median times (at least {{MIN_H}} h). The speed a stretch needs is its distance on the map, less {{ERR}} km for position error at its two ends, divided by the elapsed time. A track is beyond the limit on a map if any of its stretches needs more than the limit there; tracks shorter than {{WINDOW}} days are drawn but not tested.</dd>
|
||||||
|
<dt>Limit</dt><dd>{{LIMIT}} km/h: {{V_SWIM}} m/s, the highest mean swimming speed measured with speed loggers in any penguin species (gentoo and chinstrap penguins; emperor 1.7, Adélie 2.0, king 2.1 m/s), plus {{V_CURRENT}} m/s of current flowing with the bird for the whole stretch. Surface currents in the Antarctic Circumpolar Current are typically about 0.1 m/s and reach 0.5–0.6 m/s in its frontal jets. Each term favors the flat maps; the bird is also assumed to swim without diving, resting or walking. The slider above changes the limit.</dd>
|
||||||
|
<dt>Maps</dt><dd>As in the <a href="https://pingstats.aethercosmology.com">Cable Latency Survey</a> and <a href="https://iss-spoofing.aethercosmology.com">The Sync Test</a>: the North-pole and dual-pole maps are azimuthal equidistant, true in distance from their centers; Mercator is true on the equator, with its east and west edges joined so that a track can cross 180°. Lengths are map kilometers at that scale. <i>Tracks</i> fits each map to the selected tracks; the scale bar gives map kilometers.</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2>Sources</h2>
|
||||||
|
<ol class="refs">
|
||||||
|
<li>Ropert-Coudert Y, Van de Putte AP, Reisinger RR, et al. (2020). The retrospective analysis of Antarctic tracking data project. <i>Scientific Data</i> 7, 94. <a href="https://doi.org/10.1038/s41597-020-0406-x">doi:10.1038/s41597-020-0406-x</a>. Data: The Retrospective Analysis of Antarctic Tracking (Standardised) Data from the Scientific Committee on Antarctic Research, v1.5, SCAR AntOBIS, <a href="https://doi.org/10.15468/uzmdpm">doi:10.15468/uzmdpm</a>, CC BY 4.0.</li>
|
||||||
|
<li>Sato K, Watanuki Y, Takahashi A, et al. (2007). Stroke frequency, but not swimming speed, is related to body size in free-ranging seabirds, pinnipeds and cetaceans. <i>Proceedings of the Royal Society B</i> 274, 471–477. <a href="https://doi.org/10.1098/rspb.2006.0005">doi:10.1098/rspb.2006.0005</a>.</li>
|
||||||
|
<li>Antarctic Circumpolar Current speeds: <a href="https://glossary.ametsoc.org/wiki/antarctic-circumpolar-current/">AMS Glossary of Meteorology</a>; Stewart RH, <a href="https://geo.libretexts.org/Bookshelves/Oceanography/Introduction_to_Physical_Oceanography_(Stewart)/13%3A_Deep_Circulation_in_the_Ocean/13.5%3A_Antarctic_Circumpolar_Current"><i>Introduction to Physical Oceanography</i>, §13.5</a>.</li>
|
||||||
|
<li><a href="https://www.naturalearthdata.com/">Natural Earth</a> land, 1:50m south of 35°S and 1:110m elsewhere · <a href="https://d3js.org/">D3</a>.</li>
|
||||||
|
</ol>
|
||||||
|
<button id="dl" type="button">Download the data (JSON)</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<footer class="wrap">Built {{BUILT}}. <a href="https://git.aethercosmology.com/toby/cable-latency-survey">Code and data</a> (MIT; tracking data CC BY 4.0, SCAR) · <a href="https://git.aethercosmology.com/toby/cable-latency-survey/src/branch/main/CONTRIBUTING.md">Contribute</a> · Related: <a href="https://pingstats.aethercosmology.com">Cable Latency Survey</a> · <a href="https://fe-map.aethercosmology.com">The Best Flat Map</a> · <a href="https://iss-spoofing.aethercosmology.com">The Sync Test</a> · <a href="https://distance.aethercosmology.com">The Shape of Distance</a></footer>
|
||||||
|
<div id="tip" hidden></div>
|
||||||
|
|
||||||
|
<script>/*D3*/</script>
|
||||||
|
<script>
|
||||||
|
(() => {
|
||||||
|
"use strict";
|
||||||
|
const D = /*DATA*/null;
|
||||||
|
const RAD = Math.PI / 180, RE = 6371, MAPS = ["globe", "ae", "dualpole", "mercator"];
|
||||||
|
const MAPNAME = { globe: "Globe", ae: "North-pole AE", dualpole: "Dual-pole AE", mercator: "Mercator" };
|
||||||
|
const nf = new Intl.NumberFormat("en-US");
|
||||||
|
const reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||||
|
const C = { track: "#3ee6ff", bad: "#ff4d5e", colony: "#ffc94a", ocean: "#06101e", land: "#13243b", coast: "rgba(150,200,255,.24)",
|
||||||
|
grat: "rgba(120,180,255,.08)", rim: "rgba(120,180,255,.3)", ink: "#e8f0fb", faint: "#65789a" };
|
||||||
|
const $ = s => document.querySelector(s);
|
||||||
|
const colony = c => D.colony_fix[c] || c;
|
||||||
|
const spName = s => D.names[s] || s;
|
||||||
|
|
||||||
|
// selection
|
||||||
|
const S = { key: D.default, day: 0, playing: false, rate: 4, view: "fit", lim: D.limit.kmh, last: 0 };
|
||||||
|
let G = [], GMAX = 1;
|
||||||
|
const beyond = (t, m) => t.st[m].need !== null && t.st[m].need > S.lim;
|
||||||
|
function select(key) {
|
||||||
|
S.key = key;
|
||||||
|
const [sp, col, yr] = key.split("|");
|
||||||
|
G = D.tracks.filter(t => t.sp === sp && colony(t.colony) === colony(col) && t.year === yr);
|
||||||
|
GMAX = Math.max(1, ...G.map(t => t.d[t.d.length - 1]));
|
||||||
|
$("#day").max = GMAX; S.day = GMAX; $("#day").value = GMAX;
|
||||||
|
const t0 = G.map(t => t.start).sort()[0], t1 = G.map(t => t.end).sort().pop();
|
||||||
|
$("#span").textContent = `${t0} – ${t1}`;
|
||||||
|
$("#seltitle").textContent = `${spName(sp)}s · ${colony(col)} · ${yr}`;
|
||||||
|
fitAll(); table(); stop(); dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// group menu: species, then colony and season
|
||||||
|
(function menu() {
|
||||||
|
const sel = $("#grp"), bySp = new Map();
|
||||||
|
for (const [k, g] of Object.entries(D.groups)) { if (!bySp.has(g.sp)) bySp.set(g.sp, []); bySp.get(g.sp).push([k, g]); }
|
||||||
|
for (const sp of Object.keys(D.species)) {
|
||||||
|
const og = document.createElement("optgroup"); og.label = spName(sp);
|
||||||
|
for (const [k, g] of (bySp.get(sp) || []).sort((a, b) => a[1].colony.localeCompare(b[1].colony) || a[1].year.localeCompare(b[1].year))) {
|
||||||
|
const o = document.createElement("option"); o.value = k; o.textContent = `${g.colony}, ${g.year} (${g.n})`; og.appendChild(o);
|
||||||
|
}
|
||||||
|
sel.appendChild(og);
|
||||||
|
}
|
||||||
|
sel.value = D.default;
|
||||||
|
sel.onchange = () => select(sel.value);
|
||||||
|
})();
|
||||||
|
|
||||||
|
// panels
|
||||||
|
const LAND = { type: "MultiPolygon", coordinates: D.land };
|
||||||
|
const GRAT = d3.geoGraticule().step([30, 30])(), SPH = { type: "Sphere" };
|
||||||
|
const panels = [...document.querySelectorAll(".panel")].map(el => {
|
||||||
|
const key = el.dataset.key;
|
||||||
|
const proj = key === "globe" ? d3.geoOrthographic().clipAngle(90)
|
||||||
|
: key === "ae" ? d3.geoAzimuthalEquidistant().rotate([0, -90]).clipAngle(180 - 1e-3)
|
||||||
|
: key === "dualpole" ? d3.geoAzimuthalEquidistant().rotate([0, 0]).clipAngle(180 - 1e-3)
|
||||||
|
: d3.geoMercator();
|
||||||
|
proj.precision(0.3);
|
||||||
|
const cv = el.querySelector("canvas"), f = {};
|
||||||
|
el.querySelectorAll("[data-f]").forEach(d => (f[d.dataset.f] = d));
|
||||||
|
return { el, key, proj, cv, ctx: cv.getContext("2d"), f, W: 0, bg: null, xy: null };
|
||||||
|
});
|
||||||
|
let dpr = 1, dirty = true;
|
||||||
|
function center() { // mean direction of the selected positions
|
||||||
|
let x = 0, y = 0, z = 0;
|
||||||
|
for (const t of G) for (let i = 0; i < t.lat.length; i++) { const p = t.lat[i] * RAD, l = t.lon[i] * RAD; x += Math.cos(p) * Math.cos(l); y += Math.cos(p) * Math.sin(l); z += Math.sin(p); }
|
||||||
|
return [Math.atan2(y, x) / RAD, Math.atan2(z, Math.hypot(x, y)) / RAD];
|
||||||
|
}
|
||||||
|
function fit(p) {
|
||||||
|
const W = p.W, c = center(), pad = Math.max(18, W * 0.08);
|
||||||
|
if (p.key === "globe") p.proj.rotate([-c[0], -c[1]]);
|
||||||
|
if (p.key === "mercator") p.proj.rotate([-c[0], 0]);
|
||||||
|
if (S.view === "fit" && G.length) {
|
||||||
|
const pts = { type: "MultiPoint", coordinates: G.flatMap(t => t.lat.map((la, i) => [t.lon[i], la])) };
|
||||||
|
p.proj.fitExtent([[pad, pad], [W - pad, W - pad - 14]], pts);
|
||||||
|
if (p.key === "globe") p.proj.scale(Math.min(p.proj.scale(), W * 40));
|
||||||
|
} else {
|
||||||
|
const s = W / 2 - 3;
|
||||||
|
if (p.key === "globe") p.proj.scale(s).translate([W / 2, W / 2]);
|
||||||
|
else if (p.key === "mercator") p.proj.scale(W / (2 * Math.PI)).translate([W / 2, W / 2]);
|
||||||
|
else p.proj.scale(s / Math.PI).translate([W / 2, W / 2]);
|
||||||
|
}
|
||||||
|
p.bg = document.createElement("canvas"); p.bg.width = p.cv.width; p.bg.height = p.cv.height;
|
||||||
|
const g = p.bg.getContext("2d"); g.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||||
|
const path = d3.geoPath(p.proj, g);
|
||||||
|
g.save(); g.beginPath(); g.rect(0, 0, W, W); g.clip();
|
||||||
|
g.beginPath(); path(SPH); g.fillStyle = C.ocean; g.fill();
|
||||||
|
g.beginPath(); path(GRAT); g.strokeStyle = C.grat; g.lineWidth = 0.7; g.stroke();
|
||||||
|
g.beginPath(); path(LAND); g.fillStyle = C.land; g.fill(); g.strokeStyle = C.coast; g.lineWidth = 0.6; g.stroke();
|
||||||
|
g.beginPath(); path(SPH); g.strokeStyle = C.rim; g.lineWidth = 1; g.stroke();
|
||||||
|
g.restore();
|
||||||
|
scaleBar(g, p);
|
||||||
|
// projected daily positions; on the globe, the far side is hidden
|
||||||
|
const vis = p.key === "globe" ? ll => d3.geoDistance(ll, [c[0], c[1]]) < Math.PI / 2 - 1e-3 : () => true;
|
||||||
|
p.xy = G.map(t => t.lat.map((la, i) => { const ll = [t.lon[i], la]; return vis(ll) ? p.proj(ll) : null; }));
|
||||||
|
}
|
||||||
|
function scaleBar(g, p) { // map kilometers at the map's own scale (at the center for the globe)
|
||||||
|
const kmpx = RE / p.proj.scale(), want = p.W * 0.22 * kmpx;
|
||||||
|
const pow = Math.pow(10, Math.floor(Math.log10(want))), km = [1, 2, 5, 10].map(m => m * pow).filter(v => v <= want).pop() || pow;
|
||||||
|
const w = km / kmpx, x = 10, y = p.W - 12;
|
||||||
|
g.strokeStyle = "rgba(232,240,251,.75)"; g.lineWidth = 1.2;
|
||||||
|
g.beginPath(); g.moveTo(x, y - 4); g.lineTo(x, y); g.lineTo(x + w, y); g.lineTo(x + w, y - 4); g.stroke();
|
||||||
|
g.font = "500 11px JetBrains Mono, monospace"; g.fillStyle = "rgba(232,240,251,.8)"; g.textBaseline = "bottom";
|
||||||
|
g.fillText(`${nf.format(km)} km${p.key === "globe" ? "" : " (map)"}`, x + w + 6, y + 1);
|
||||||
|
}
|
||||||
|
function fitAll() { for (const p of panels) if (p.W) fit(p); }
|
||||||
|
function layout() {
|
||||||
|
dpr = Math.min(2, window.devicePixelRatio || 1);
|
||||||
|
for (const p of panels) {
|
||||||
|
const W = p.cv.clientWidth; if (!W) continue;
|
||||||
|
p.W = W; p.cv.width = Math.round(W * dpr); p.cv.height = Math.round(W * dpr);
|
||||||
|
}
|
||||||
|
fitAll(); dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// drawing
|
||||||
|
function drawPanel(p) {
|
||||||
|
if (!p.W || !p.bg) return;
|
||||||
|
const g = p.ctx, W = p.W;
|
||||||
|
g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, p.cv.width, p.cv.height); g.drawImage(p.bg, 0, 0);
|
||||||
|
g.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||||
|
g.save(); g.beginPath(); g.rect(0, 0, W, W); g.clip();
|
||||||
|
g.lineJoin = "round"; g.lineCap = "round";
|
||||||
|
const day = S.day, heads = [];
|
||||||
|
// colonies
|
||||||
|
const seen = new Set();
|
||||||
|
for (let k = 0; k < G.length; k++) {
|
||||||
|
const q = p.xy[k][0]; if (!q) continue; const id = Math.round(q[0] / 4) + "," + Math.round(q[1] / 4);
|
||||||
|
if (seen.has(id)) continue; seen.add(id);
|
||||||
|
g.beginPath(); g.arc(q[0], q[1], 4.5, 0, 7); g.strokeStyle = C.colony; g.lineWidth = 1.6; g.stroke();
|
||||||
|
}
|
||||||
|
for (let k = 0; k < G.length; k++) {
|
||||||
|
const t = G[k], xy = p.xy[k], bad = beyond(t, p.key), s = t.st[p.key];
|
||||||
|
g.strokeStyle = bad ? C.bad : C.track; g.globalAlpha = 0.75; g.lineWidth = 1.3;
|
||||||
|
g.beginPath(); let pen = false, last = null;
|
||||||
|
for (let i = 0; i < t.d.length; i++) {
|
||||||
|
let q = xy[i];
|
||||||
|
if (t.d[i] > day) { // partial step up to the day shown
|
||||||
|
if (i > 0 && xy[i - 1] && q && t.d[i - 1] <= day) { const f = (day - t.d[i - 1]) / (t.d[i] - t.d[i - 1]); q = [xy[i - 1][0] + f * (q[0] - xy[i - 1][0]), xy[i - 1][1] + f * (q[1] - xy[i - 1][1])]; if (pen) g.lineTo(q[0], q[1]); last = q; }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!q) { pen = false; continue; }
|
||||||
|
pen ? g.lineTo(q[0], q[1]) : g.moveTo(q[0], q[1]); pen = true; last = q;
|
||||||
|
}
|
||||||
|
g.stroke();
|
||||||
|
if (bad && s.i !== null && t.d[s.j] <= day && xy[s.i] && xy[s.j]) { // the fastest stretch, straight across the map
|
||||||
|
g.globalAlpha = 0.95; g.lineWidth = 3.4;
|
||||||
|
g.beginPath(); g.moveTo(xy[s.i][0], xy[s.i][1]); for (let i = s.i + 1; i <= s.j; i++) if (xy[i]) g.lineTo(xy[i][0], xy[i][1]); g.stroke();
|
||||||
|
}
|
||||||
|
if (last) heads.push([last, t.d[t.d.length - 1] <= day]);
|
||||||
|
}
|
||||||
|
g.globalAlpha = 1;
|
||||||
|
for (const [q, done] of heads) {
|
||||||
|
g.beginPath(); g.arc(q[0], q[1], done ? 2 : 3, 0, 7);
|
||||||
|
if (done) { g.strokeStyle = "rgba(255,255,255,.7)"; g.lineWidth = 1; g.stroke(); } else { g.fillStyle = "#fff"; g.fill(); }
|
||||||
|
}
|
||||||
|
g.restore();
|
||||||
|
}
|
||||||
|
function readouts() {
|
||||||
|
for (const p of panels) {
|
||||||
|
const v = G.filter(t => t.st[p.key].need !== null), lens = G.map(t => t.st[p.key].len).sort((a, b) => a - b);
|
||||||
|
const med = lens.length ? lens[lens.length >> 1] : 0;
|
||||||
|
p.f.len.textContent = `${nf.format(Math.round(med))} km`;
|
||||||
|
const k = v.filter(t => beyond(t, p.key)).length;
|
||||||
|
p.f.n.innerHTML = v.length ? `${k} of ${v.length}<span class="pill ${k ? "bad" : "ok"}">${k ? "beyond" : "within"}</span>` : "—";
|
||||||
|
const top = v.reduce((a, t) => (t.st[p.key].need > (a ? a.st[p.key].need : -1) ? t : a), null);
|
||||||
|
if (top) { const s = top.st[p.key], r = s.need / S.lim;
|
||||||
|
p.f.v.innerHTML = `${s.need.toFixed(1)} km/h · ${nf.format(Math.round(s.km))} km in ${Math.round(s.h)} h<span class="pill ${r > 1 ? "bad" : "ok"}">×${r.toFixed(Math.abs(r - 1) < 0.005 ? 3 : 2)} limit</span>`; }
|
||||||
|
else p.f.v.textContent = "no 3-day stretch";
|
||||||
|
}
|
||||||
|
const d = Math.min(GMAX, Math.floor(S.day));
|
||||||
|
$("#clock").textContent = `Day ${d} of ${GMAX}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tables
|
||||||
|
function table() {
|
||||||
|
const th = `<tr><th scope="col" style="text-align:left">Penguin</th><th scope="col" style="text-align:left">Tag</th><th scope="col">Tracked</th><th scope="col">Days</th><th scope="col">Length on the globe</th>${MAPS.map(m => `<th scope="col">${MAPNAME[m]}, km/h</th>`).join("")}</tr>`;
|
||||||
|
$("#animals thead").innerHTML = `<tr><th scope="col" colspan="5"></th><th scope="col" colspan="4" style="text-align:center">Fastest ${D.limit.window}-day stretch</th></tr>` + th;
|
||||||
|
$("#animals tbody").innerHTML = G.map(t => {
|
||||||
|
const cell = m => { const s = t.st[m]; return s.need === null ? `<td class="na">—</td>` : `<td class="${s.need > S.lim ? "bad" : ""}">${s.need.toFixed(1)}</td>`; };
|
||||||
|
const who = [{ M: "male", F: "female" }[t.sex], t.stage && t.stage.toLowerCase()].filter(Boolean).join(", ");
|
||||||
|
return `<tr><td class="l">${t.id}${who ? ` <span style="color:var(--faint)">${who}</span>` : ""}</td><td class="l">${t.dev || "—"}</td><td>${t.start}</td><td>${t.d[t.d.length - 1]}</td><td>${nf.format(Math.round(t.st.globe.len))} km</td>${MAPS.map(cell).join("")}</tr>`;
|
||||||
|
}).join("");
|
||||||
|
}
|
||||||
|
function speciesTable() {
|
||||||
|
const rows = Object.entries(D.species);
|
||||||
|
const all = D.tracks.filter(t => t.st.globe.need !== null);
|
||||||
|
const cnt = (v, m) => v.filter(t => beyond(t, m)).length;
|
||||||
|
$("#species thead").innerHTML = `<tr><th scope="col" style="text-align:left">Species</th><th scope="col">Tracks</th><th scope="col">Tested</th>${MAPS.map(m => `<th scope="col">${MAPNAME[m]}</th>`).join("")}</tr><tr><th scope="col" colspan="3"></th><th scope="col" colspan="4" style="text-align:center">Beyond ${S.lim.toFixed(1)} km/h · median fastest stretch, km/h</th></tr>`;
|
||||||
|
const line = (name, v, n) => `<tr><th scope="row">${name}</th><td>${nf.format(n)}</td><td>${nf.format(v.length)}</td>${MAPS.map(m => { const k = cnt(v, m), s = v.map(t => t.st[m].need).sort((a, b) => a - b); return `<td class="${k ? "bad" : ""}">${k} · ${s.length ? s[s.length >> 1].toFixed(1) : "—"}</td>`; }).join("")}</tr>`;
|
||||||
|
$("#species tbody").innerHTML = rows.map(([sp, s]) => line(s.name, all.filter(t => t.sp === sp), s.tracks)).join("") + line("All", all, D.tracks.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// tooltip: nearest daily position
|
||||||
|
const tip = $("#tip");
|
||||||
|
for (const p of panels) {
|
||||||
|
p.cv.addEventListener("pointermove", e => {
|
||||||
|
if (!p.xy) return;
|
||||||
|
const r = p.cv.getBoundingClientRect(), mx = e.clientX - r.left, my = e.clientY - r.top;
|
||||||
|
let best = null, bd = 12 * 12;
|
||||||
|
for (let k = 0; k < G.length; k++) for (let i = 0; i < p.xy[k].length; i++) { const q = p.xy[k][i]; if (!q || G[k].d[i] > S.day) continue; const d = (q[0] - mx) ** 2 + (q[1] - my) ** 2; if (d < bd) { bd = d; best = [k, i]; } }
|
||||||
|
if (!best) { tip.hidden = true; return; }
|
||||||
|
const t = G[best[0]], s = t.st[p.key];
|
||||||
|
tip.innerHTML = `<b>${spName(t.sp)} ${t.id}</b><span>${colony(t.colony)} · ${t.dev || "tag"} · ${t.start} to ${t.end}</span><span>Day ${t.d[best[1]]}: ${t.lat[best[1]].toFixed(2)}°, ${t.lon[best[1]].toFixed(2)}°</span><span>${MAPNAME[p.key]}: ${nf.format(Math.round(s.len))} km tracked${s.need !== null ? `; fastest ${D.limit.window}-day stretch ${s.need.toFixed(1)} km/h` : ""}</span>`;
|
||||||
|
tip.hidden = false; const tw = tip.getBoundingClientRect();
|
||||||
|
tip.style.left = Math.min(innerWidth - tw.width - 8, e.clientX + 14) + "px"; tip.style.top = Math.min(innerHeight - tw.height - 8, e.clientY + 14) + "px";
|
||||||
|
});
|
||||||
|
p.cv.addEventListener("pointerleave", () => (tip.hidden = true));
|
||||||
|
}
|
||||||
|
|
||||||
|
// controls
|
||||||
|
const playBtn = $("#play"), icon = $("#playicon");
|
||||||
|
function setPlay(on) { S.playing = on; icon.setAttribute("d", on ? "M2 1h3.5v12H2zM8.5 1H12v12H8.5z" : "M3 1.5v11l9-5.5z"); playBtn.setAttribute("aria-label", on ? "Pause" : "Play"); S.last = performance.now(); }
|
||||||
|
function stop() { setPlay(false); }
|
||||||
|
playBtn.onclick = () => { if (!S.playing && S.day >= GMAX) S.day = 0; setPlay(!S.playing); };
|
||||||
|
$("#rates").addEventListener("click", e => { const b = e.target.closest("button"); if (!b) return; S.rate = +b.dataset.rate; for (const x of $("#rates").children) x.setAttribute("aria-pressed", String(x === b)); });
|
||||||
|
$("#view").addEventListener("click", e => { const b = e.target.closest("button"); if (!b) return; S.view = b.dataset.v; for (const x of $("#view").children) x.setAttribute("aria-pressed", String(x === b)); fitAll(); dirty = true; });
|
||||||
|
$("#day").addEventListener("input", e => { S.day = +e.target.value; stop(); dirty = true; });
|
||||||
|
$("#lim").addEventListener("input", e => { S.lim = +e.target.value; $("#limv").textContent = `${S.lim.toFixed(1)} km/h`; table(); speciesTable(); dirty = true; });
|
||||||
|
$("#dl").addEventListener("click", () => {
|
||||||
|
const blob = new Blob([JSON.stringify({ tracks: D.tracks, species: D.species, total: D.total, limit: D.limit, source: "SCAR RAATD v1.5, doi:10.15468/uzmdpm, CC BY 4.0" })], { type: "application/json" });
|
||||||
|
const a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = "penguin_test_data.json"; document.body.appendChild(a); a.click(); a.remove(); setTimeout(() => URL.revokeObjectURL(a.href), 2000);
|
||||||
|
});
|
||||||
|
|
||||||
|
function frame(now) {
|
||||||
|
if (S.playing) {
|
||||||
|
S.day = Math.min(GMAX, S.day + (now - S.last) / 1000 * S.rate); S.last = now;
|
||||||
|
$("#day").value = S.day; if (S.day >= GMAX) stop(); dirty = true;
|
||||||
|
}
|
||||||
|
if (dirty) { for (const p of panels) drawPanel(p); readouts(); dirty = false; }
|
||||||
|
requestAnimationFrame(frame);
|
||||||
|
}
|
||||||
|
new ResizeObserver(() => layout()).observe($(".grid"));
|
||||||
|
select(D.default); speciesTable(); layout();
|
||||||
|
requestAnimationFrame(frame);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
// The Penguin Test (penguins/site/index.html): errors, overflow, controls clickable, panels and tables filled, at 8 viewports;
|
||||||
|
// then behaviour: the first selection, the globe and North-pole counts, the speed-limit slider, playback, colony switch, whole-map view.
|
||||||
|
// CH=<chromium> node penguins.mjs [url] (default: the built file; LIVE=1 for https://penguins.aethercosmology.com)
|
||||||
|
import { chromium } from 'playwright-core';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const url = process.argv[2] || (process.env.LIVE ? 'https://penguins.aethercosmology.com/' : 'file://' + path.join(here, '../penguins/site/index.html'));
|
||||||
|
const VP = [[1920, 1080], [1680, 1050], [1440, 900], [1280, 720], [1024, 768], [820, 1180], [390, 844], [360, 740]];
|
||||||
|
const b = await chromium.launch({ executablePath: process.env.CH });
|
||||||
|
let fails = 0;
|
||||||
|
const fail = (...a) => { fails++; console.log('FAIL', ...a); };
|
||||||
|
for (const [w, h] of VP) {
|
||||||
|
const p = await b.newPage({ viewport: { width: w, height: h } });
|
||||||
|
const errs = [];
|
||||||
|
p.on('pageerror', e => errs.push(e.message));
|
||||||
|
p.on('console', m => m.type() === 'error' && errs.push(m.text()));
|
||||||
|
await p.goto(url, { waitUntil: 'load' });
|
||||||
|
await p.waitForTimeout(1200);
|
||||||
|
const r = await p.evaluate(() => {
|
||||||
|
const out = { overflow: document.documentElement.scrollWidth - innerWidth, blocked: [], empty: [], clipped: [] };
|
||||||
|
for (const el of document.querySelectorAll('button, input, select, a')) {
|
||||||
|
el.scrollIntoView({ block: 'center' });
|
||||||
|
const b = el.getClientRects()[0];
|
||||||
|
if (!b || !b.width) continue;
|
||||||
|
const hit = document.elementFromPoint(b.left + b.width / 2, b.top + b.height / 2);
|
||||||
|
if (hit !== el && !el.contains(hit) && !(hit && hit.closest('label') && hit.closest('label') === el.closest('label')))
|
||||||
|
out.blocked.push((el.id || el.textContent.trim().slice(0, 20)) + ' <- ' + (hit && (hit.id || hit.className || hit.tagName)));
|
||||||
|
}
|
||||||
|
for (const c of document.querySelectorAll('.map canvas')) {
|
||||||
|
const g = c.getContext('2d'), d = g.getImageData(0, 0, c.width, c.height).data; let lit = 0;
|
||||||
|
for (let i = 0; i < d.length; i += 4 * 97) if (d[i] + d[i + 1] + d[i + 2] > 60) lit++;
|
||||||
|
if (!c.width || lit < 20) out.empty.push('canvas ' + c.closest('.panel').dataset.key);
|
||||||
|
}
|
||||||
|
for (const dd of document.querySelectorAll('.ro dd')) { if (dd.textContent.trim() === '—') out.empty.push('readout'); if (dd.scrollWidth > dd.clientWidth + 1) out.clipped.push(dd.textContent); }
|
||||||
|
if (document.querySelectorAll('#animals tbody tr').length < 1) out.empty.push('animals table');
|
||||||
|
if (document.querySelectorAll('#species tbody tr').length < 5) out.empty.push('species table');
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
return out;
|
||||||
|
});
|
||||||
|
if (errs.length) fail(w, h, 'errors', errs.slice(0, 3));
|
||||||
|
if (r.overflow > 0) fail(w, h, 'horizontal overflow', r.overflow);
|
||||||
|
if (r.blocked.length) fail(w, h, 'blocked', r.blocked.slice(0, 5));
|
||||||
|
if (r.empty.length) fail(w, h, 'empty', [...new Set(r.empty)]);
|
||||||
|
if (r.clipped.length) fail(w, h, 'clipped', r.clipped.slice(0, 4));
|
||||||
|
await p.screenshot({ path: path.join(here, `out/penguins_${w}x${h}.png`) });
|
||||||
|
await p.close();
|
||||||
|
}
|
||||||
|
// behaviour
|
||||||
|
const DATA = JSON.parse(fs.readFileSync(path.join(here, '../penguins/data/penguins.json'), 'utf8'));
|
||||||
|
const [FSP, FCOL, FYR] = DATA.default.split('|');
|
||||||
|
const FIRST = DATA.tracks.filter(t => t.sp === FSP && t.colony === FCOL && t.year === FYR);
|
||||||
|
const p = await b.newPage({ viewport: { width: 1440, height: 900 } });
|
||||||
|
const errs = []; p.on('pageerror', e => errs.push(e.message));
|
||||||
|
await p.goto(url, { waitUntil: 'load' });
|
||||||
|
await p.waitForTimeout(800);
|
||||||
|
const n = k => p.evaluate(k => document.querySelector(`.panel[data-key="${k}"] [data-f="n"]`).textContent, k);
|
||||||
|
const first = await p.evaluate(() => [document.getElementById('grp').selectedOptions[0].textContent, document.getElementById('clock').textContent]);
|
||||||
|
console.log('first selection:', first.join(' | '), '| globe', await n('globe'), '| AE', await n('ae'));
|
||||||
|
if (!/Pointe Géologie, Terre Adélie, 2005 \(11\)/.test(first[0])) fail('first selection is not the 2005 Pointe Géologie emperors', first[0]);
|
||||||
|
if (!/^0 of 11/.test(await n('globe'))) fail('globe should have no track beyond the limit', await n('globe'));
|
||||||
|
if (!/^[1-9]\d* of 11/.test(await n('ae'))) fail('North-pole AE should have tracks beyond the limit', await n('ae'));
|
||||||
|
if (!/Day (\d+) of \1$/.test(first[1])) fail('page should open with the full tracks drawn', first[1]);
|
||||||
|
// the slider: each readout must equal the count from the data at that limit
|
||||||
|
for (const v of [6, 11.9, 18, 24]) {
|
||||||
|
await p.evaluate(v => { const s = document.getElementById('lim'); s.value = v; s.dispatchEvent(new Event('input')); }, v);
|
||||||
|
await p.waitForTimeout(120);
|
||||||
|
const got = await p.evaluate(() => [...document.querySelectorAll('.panel')].map(x => parseInt(x.querySelector('[data-f="n"]').textContent)));
|
||||||
|
const want = ['globe', 'ae', 'dualpole', 'mercator'].map(m => FIRST.filter(t => t.st[m].need !== null && t.st[m].need > v).length);
|
||||||
|
console.log(`limit ${v} km/h: beyond`, got.join(' / '));
|
||||||
|
if (want && want.join() !== got.join()) fail('readout differs from the data at', v, got, want);
|
||||||
|
}
|
||||||
|
await p.evaluate(() => { const s = document.getElementById('lim'); s.value = s.defaultValue; s.dispatchEvent(new Event('input')); });
|
||||||
|
// playback
|
||||||
|
await p.click('#play'); await p.waitForTimeout(1500);
|
||||||
|
const playing = await p.evaluate(() => document.getElementById('clock').textContent);
|
||||||
|
console.log('playing:', playing);
|
||||||
|
if (!/^Day [0-9] of 80/.test(playing)) fail('play should restart from day 0 and advance', playing);
|
||||||
|
await p.click('#play');
|
||||||
|
// another colony and the whole-map view
|
||||||
|
const opt = await p.evaluate(() => { const o = [...document.querySelectorAll('#grp option')].find(o => /Cape Crozier/.test(o.textContent)); return o && o.value; });
|
||||||
|
if (opt) { await p.selectOption('#grp', opt); await p.waitForTimeout(400); console.log('Cape Crozier:', await p.evaluate(() => document.getElementById('grp').selectedOptions[0].textContent), '| AE', await n('ae'), '| globe', await n('globe')); }
|
||||||
|
else fail('no Cape Crozier option');
|
||||||
|
await p.click('#view button[data-v="all"]'); await p.waitForTimeout(400);
|
||||||
|
await p.locator('.grid').screenshot({ path: path.join(here, 'out/penguins_whole.png') });
|
||||||
|
if (errs.length) fail('errors', errs.slice(0, 3));
|
||||||
|
console.log(fails ? `penguins: ${fails} FAILS` : 'penguins OK');
|
||||||
|
await b.close();
|
||||||
|
process.exit(fails ? 1 : 0);
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// Link-preview image for The Penguin Test: the four panels for the first selection, 1200 x 630.
|
||||||
|
// CH=<chromium> node penguins_og.mjs -> ../penguins/site/og.png
|
||||||
|
import { chromium } from 'playwright-core';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import path from 'path';
|
||||||
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const b = await chromium.launch({ executablePath: process.env.CH });
|
||||||
|
const p = await b.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 });
|
||||||
|
await p.goto('file://' + path.join(here, '../penguins/site/index.html'));
|
||||||
|
await p.addStyleTag({ content: `.intro,.bar,.legend,.after,footer,.ro,.ph p{display:none!important}
|
||||||
|
.top{padding-block:22px 0}.sub{font-size:16px}.grid{grid-template-columns:repeat(4,minmax(0,1fr))!important;padding-block:16px 0}
|
||||||
|
.cap{font:500 17px/1.5 Inter,sans-serif;color:#9badc6;padding:14px 16px 0;max-width:1200px;margin:0 auto}.cap b{color:#ff4d5e;font-weight:600}.cap.big{font:600 21px/1.4 'Space Grotesk',Inter,sans-serif;color:#e8f0fb;padding-top:18px}` });
|
||||||
|
await p.evaluate(() => { const c = document.createElement('p'); c.className = 'cap';
|
||||||
|
const n = [...document.querySelectorAll('.panel')].map(x => x.querySelector('[data-f="n"]').textContent.match(/^\d+ of \d+/)[0]);
|
||||||
|
c.innerHTML = `Emperor penguins, Pointe Géologie, 2005 · beyond a penguin's speed: globe ${n[0]}, <b>North-pole AE ${n[1]}</b>`;
|
||||||
|
document.querySelector('.grid').after(c);
|
||||||
|
const t = document.createElement('p'); t.className = 'cap big';
|
||||||
|
const r = document.querySelector('.after p').textContent.match(/Of the ([\d,]+) tracks.*?North-pole AE map ([\d,]+) \((\d+%)\) do, on Mercator ([\d,]+) and on the dual-pole AE map ([\d,]+)/);
|
||||||
|
t.innerHTML = `All ${r[1]} tested tracks: <span style="color:#3dffa0">globe 0</span> beyond the limit · <b>North-pole AE ${r[2]} (${r[3]})</b> · Mercator ${r[4]} · dual-pole AE ${r[5]}`;
|
||||||
|
c.after(t); window.dispatchEvent(new Event('resize')); });
|
||||||
|
await p.waitForTimeout(900);
|
||||||
|
await p.screenshot({ path: path.join(here, '../penguins/site/og.png'), clip: { x: 0, y: 0, width: 1200, height: 630 } });
|
||||||
|
await b.close();
|
||||||
@@ -20,3 +20,4 @@ node mode.mjs | cut -c1-60 # cable / straight toggle chang
|
|||||||
node sync.mjs | tail -1 # The Sync Test (satellites/): 8 viewports, readouts, controls
|
node sync.mjs | tail -1 # The Sync Test (satellites/): 8 viewports, readouts, controls
|
||||||
[ "${LIVE:-0}" = 1 ] && node live.mjs # LIVE=1: the public site
|
[ "${LIVE:-0}" = 1 ] && node live.mjs # LIVE=1: the public site
|
||||||
node femap.mjs | tail -1 # The Best Flat Map (femap/): 8 viewports, live solve, 3D release
|
node femap.mjs | tail -1 # The Best Flat Map (femap/): 8 viewports, live solve, 3D release
|
||||||
|
node penguins.mjs | tail -1 # The Penguin Test (penguins/): 8 viewports, limit slider, playback
|
||||||
|
|||||||
Reference in New Issue
Block a user