Skip to content

Instantly share code, notes, and snippets.

View AndrewILWilliams's full-sized avatar

Andrew Williams AndrewILWilliams

View GitHub Profile
@kathoef
kathoef / xarray-v0.16.2-correlation.ipynb
Created January 13, 2021 17:58
low xarray.corr() performance on big datasets
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thabbott
thabbott / plot_3d_cloud_field.py
Created January 5, 2021 16:04
Animate cloud water isosurfaces using matplotlib
"""
Make movie of 3D cloud fields
"""
import xarray as xr
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.colors import LightSource
from skimage import measure
from scipy.interpolate import interp1d
from scipy.ndimage import gaussian_filter
@aaronspring
aaronspring / bootstrap_threshold_parallel.ipynb
Created December 28, 2019 16:40
bootstrap threshold in parallel with dask
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rabernat
rabernat / xarray_anomaly_calculations.ipynb
Created November 27, 2019 16:34
Xarray Anomaly Calculations
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pandas as pd
from matplotlib import pyplot as plt
import numpy as np
%matplotlib inline
url = 'https://storage.googleapis.com/pangeo-cmip6/pangeo-cmip6-zarr-consolidated-stores.csv'
df = pd.read_csv(url)
run_count = df[df.activity_id == 'CMIP'].groupby(['experiment_id', 'source_id']).zstore.count()
rcu = run_count.unstack(level=-1)
@scottyhq
scottyhq / xarray-temporal-fit.ipynb
Created December 4, 2018 23:44
polynomial fit with xarray in time
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrksr
mrksr / Partial_GPR_Test.ipynb
Last active June 12, 2020 14:45
gpflow-predict-partial
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@darothen
darothen / cubed_sphere.py
Last active August 9, 2025 11:05
Cubed Sphere Mesh Generation and Plotting
from itertools import product
import numpy as np
INV_SQRT_3 = 1.0 / np.sqrt(3.0)
ASIN_INV_SQRT_3 = np.arcsin(INV_SQRT_3)
def gaussian_bell(xs, ys, xc=0., yc=0., xsigma=1., ysigma=1.):
""" Compute a 2D Gaussian with asymmetric standard deviations and
@darothen
darothen / cartopy_wrap_example.ipynb
Last active April 25, 2023 11:55
Example of adding cyclic points to DataArrays for plotting with Cartopy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import xarray as xr
import numpy as np
# create an example dataset
da = xr.DataArray(np.random.rand(10,30,40), dims=['time', 'lat', 'lon'])
# define a function to compute a linear trend of a timeseries
def linear_trend(x):
pf = np.polyfit(x.time, x, 1)
# we need to return a dataarray or else xarray's groupby won't be happy