Skip to content

Instantly share code, notes, and snippets.

@amoodie
Created May 11, 2025 17:09
Show Gist options
  • Save amoodie/3ba1b3e2867ca0913e25c1527ea1d15f to your computer and use it in GitHub Desktop.
Save amoodie/3ba1b3e2867ca0913e25c1527ea1d15f to your computer and use it in GitHub Desktop.
# my answer
from tqdm import tqdm
subaerial = np.zeros(golfcube.shape[0])
topset = np.zeros(golfcube.shape[0])
for T in tqdm(range(golfcube.shape[0])):
# do it with just pixels above sea level
Land_A = golfcube['eta'][T,:,:] > golfcube.meta['H_SL'][T]
Land_C = np.count_nonzero(Land_A)
subaerial[T] = Land_C * golfcube.meta["dx"] * golfcube.meta["dx"]
# do it with Opening Angle method
lm = spl.mask.LandMask(
golfcube['eta'][T, :, :],
elevation_threshold=golfcube.meta['H_SL'][T])
topset[T] = np.sum(lm.mask) * golfcube.meta["dx"] * golfcube.meta["dx"]
fig, ax = plt.subplots()
ax.plot(golfcube.t, subaerial / 1e6, label="subaerial")
ax.plot(golfcube.t, topset / 1e6, label="topset")
ax.set_ylabel("area [km$^2$]")
ax.set_xlabel("time [elapsed seconds]")
ax.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment