Skip to content

Instantly share code, notes, and snippets.

@cavedave
Last active July 25, 2025 07:56
Show Gist options
  • Save cavedave/a11fa410a471b4fb50b656e76e3edbe0 to your computer and use it in GitHub Desktop.
Save cavedave/a11fa410a471b4fb50b656e76e3edbe0 to your computer and use it in GitHub Desktop.
staircase.ipynb
# 1) find every record‐breaking year ≥ 1980
post80 = ts.where(ts.index >= 1980)
current_max = -np.inf
record_years = []
record_values = []
for yr, val in post80.items():
if np.isnan(val):
continue
if val >= current_max:
current_max = val
record_years.append(yr)
record_values.append(val)
# 2) build ALL steps
all_steps = [(s, e, y) for s, e, y in zip(record_years, record_years[1:], record_values)]
# 3) filter to only multi‑year “flat” periods (>=3 yr)
steps = [(s, e, y) for (s, e, y) in all_steps if (e - s) >= 3]
# 4) pre‑compute limits & frame list
xmin, xmax = ts.index.min(), ts.index.max()
ymin, ymax = ts.min() - 0.1, ts.max() + 0.1
frame_files = []
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cavedave
Copy link
Author

staircase_hadcrut5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment