Skip to content

Instantly share code, notes, and snippets.

View adcroft's full-sized avatar

Alistair Adcroft adcroft

View GitHub Profile
@adcroft
adcroft / Animate_iceberg_shelf.ipynb
Created March 17, 2017 13:51
Animate icebergs breaking away from an iceshelf
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adcroft
adcroft / tracer_mixing.ipynb
Created March 9, 2017 21:43
Isopycnal mixing test
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adcroft
adcroft / Cheat sheet for using a Mosaic grid with MOM6 output.ipynb
Last active November 18, 2025 15:55
Cheat sheet for using a Mosaic grid with MOM6 output
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adcroft
adcroft / Understanding native output data from MOM6.ipynb
Last active January 24, 2025 19:57
Understanding native output data from MOM6.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adcroft
adcroft / Visualizing and animating sea-surface height in the double-gyre example.ipynb
Last active February 24, 2017 21:33
Visualizing and animating sea-surface height in the double-gyre example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adcroft
adcroft / Convert CCS grid to Mosaic.ipynb
Last active September 12, 2016 20:18
Extracts data from a ROMS regional grid file and creates a [slightly approximated] mosaic grid spec file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adcroft
adcroft / demo_tarfile2netcdf.ipynb
Last active August 29, 2015 14:10
Reading a small netcdf variable directly from a tar file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adcroft
adcroft / dens_write_eos.py
Created May 12, 2014 15:07
Density of sea-water using Wright et al. 1997, equation of state
def dens_wright_eos(T, S, p):
"""
Equation of state for sea water given by Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740.
Units: T[degC],S[PSU],p[Pa]
Returns density [kg m-3]
"""
a0 = 7.057924e-4; a1 = 3.480336e-7; a2 = -1.112733e-7
b0 = 5.790749e8; b1 = 3.516535e6; b2 = -4.002714e4; b3 = 2.084372e2; b4 = 5.944068e5; b5 = -9.643486e3
c0 = 1.704853e5; c1 = 7.904722e2; c2 = -7.984422; c3 = 5.140652e-2; c4 = -2.302158e2; c5 = -3.079464
@adcroft
adcroft / demo_animate_relative_vortcitiy.py
Last active August 29, 2015 14:00
Animate surface relative vorticity on blue marble earth
import netCDF4
import matplotlib.pyplot as plt
import numpy
from mpl_toolkits.basemap import Basemap
import math
lon = netCDF4.Dataset('/archive/gold/datasets/MOM6z_SIS_025/siena/mosaic.unpacked/ocean_hgrid.nc').variables['x'][1::2,1::2]
lat = netCDF4.Dataset('/archive/gold/datasets/MOM6z_SIS_025/siena/mosaic.unpacked/ocean_hgrid.nc').variables['y'][1::2,1::2]
dx = netCDF4.Dataset('/archive/gold/datasets/MOM6z_SIS_025/siena/mosaic.unpacked/ocean_hgrid.nc').variables['dx'][:]
dx = dx[1::2,1::2]+numpy.roll(dx,-1,axis=-1)[1::2,1::2]
@adcroft
adcroft / demo_animate_ssh_blue_marble.py
Last active August 29, 2015 14:00
Animated SSH on blue marble
import netCDF4
import matplotlib.pyplot as plt
import numpy
from mpl_toolkits.basemap import Basemap
lon = netCDF4.Dataset('/archive/gold/datasets/MOM6z_SIS_025/siena/mosaic.unpacked/ocean_hgrid.nc').variables['x'][::2,::2]
lat = netCDF4.Dataset('/archive/gold/datasets/MOM6z_SIS_025/siena/mosaic.unpacked/ocean_hgrid.nc').variables['y'][::2,::2]
dailyFiles = '/archive/aja/awg/tikal_201403/CM4_c192L48_am4a1_2000/gfdl.ncrc2-intel-prod-openmp/history/unpack/000[3456]0101.ocean_daily.nc'
ssh = netCDF4.MFDataset(dailyFiles).variables['ssh']