Skip to content

Instantly share code, notes, and snippets.

View ianhi's full-sized avatar

Ian Hunt-Isaak ianhi

View GitHub Profile
@ianhi
ianhi / gist:9074722002adfb3a0685110cfc0ec1a9
Last active June 11, 2026 15:43
Sharded write in Zarr performance based on write size
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python3
"""
Arraylake repository test with configurable FD limits and concurrent requests.
Usage: ar.py [--fd-limit N] [--max-concurrent N] [--repo REPO_NAME]
"""
from arraylake import Client
import time
import resource
@ianhi
ianhi / zarr_upstream_checker.py
Last active August 22, 2025 16:15
Xarray Zarr Upstream test reporter
#!/usr/bin/env -S uv run
"""
Zarr Upstream Compatibility Checker
This script checks the most recent upstream-dev CI workflow run for xarray
and reports on Zarr compatibility status and version information.
Usage:
uv run zarr_upstream_checker.py
@ianhi
ianhi / rendered.md
Last active July 31, 2025 22:46
xarray-badge-test
{
"label": "",
"message": "Xarray",
"logoSvg": "<svg xml:space=\"preserve\" style=\"max-height: 500px\" viewBox=\"24 57.6 553.2 493.2\" y=\"0px\" x=\"0px\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\" id=\"Layer_1\" version=\"1.1\" width=\"553.2\" height=\"493.2\"><style type=\"text/css\">.st0{fill:#216C89;}.st1{fill:#4993AA;}.st2{fill:#0F4565;}.st3{fill:#6BE8E8;}.st4{fill:#9DEEF4;}.st5{fill:#4ACFDD;}.st6{fill:#E38017;}.st7{fill:#16AFB5;}</style><g><g><polygon points=\"266.62,546.18 356.1,454.54 356.1,271.27 266.62,362.9\" class=\"st0\"/><polygon points=\"356.1,271.45 114.48,271.45 25,362.9 266.62,362.9\" class=\"st1\"/><rect height=\"183.27\" width=\"241.62\" class=\"st2\" y=\"362.9\" x=\"25\"/></g><g><polygon points=\"266.62,328.73 356.1,237.1 356.1,53.82 266.62,145.46\" class=\"st3\"/><polygon points=\"356.1,54 114.48,54 25,145.46 266.62,145.46\" class=\"st4\"/><rect height=\"183.27\" width=\"241.62\" class=\"st5\" y=\"145.46\" x=\"25\"/></g><polygon points=\"467.
@ianhi
ianhi / tile.py
Last active May 15, 2025 14:38
Xarray Tile Accessor
from typing import overload
import mercantile
import xarray as xr
@xr.register_dataset_accessor("tile")
@xr.register_dataarray_accessor("tile")
class TileAccessor:
def __init__(self, xarray_obj):
@ianhi
ianhi / compare.py
Created October 12, 2022 19:10
Image Comparison Using matplotlib
import matplotlib.pyplot as plt
from mpl_draggable_line import DraggableVLine
def compare_images(img1, img2, ax=None):
img1 = np.asanyarray(img1)
img2 = np.asanyarray(img2)
if not np.all(img1.shape == img2.shape):
raise ValueError("Image shapes must match!")
if ax is None:
ax = plt.gca()
@ianhi
ianhi / interactive_segment.py
Created May 28, 2021 04:14
interactively explore watershed segmentation parameters
%matplotlib widget
from functools import lru_cache
import matplotlib.pyplot as plt
import numpy as np
from mpl_interactions import ipyplot as iplt
from scipy import ndimage as ndi
from skimage.data import binary_blobs
from skimage.feature import peak_local_max
@ianhi
ianhi / jlab.sh
Created December 11, 2020 20:06
setting up jupyterlab environments
jlab-env-basic()
{
conda create -n $1 -c conda-forge python mamba -y
conda activate $1
mamba install -c conda-forge jupyterlab nodejs -y
}
jlab-env-full()
{
conda create -n $1 -c conda-forge python=3.8 mamba -y
conda activate $1
@ianhi
ianhi / imshow_panhandler.py
Last active October 14, 2020 19:44
add right click drag to pan to matplotlib imshow. Now available via https://github.com/ianhi/mpl-interactions
class panhandler:
"""
enable click to pan image.
button determines which button will be used (default right click)
Left: 1
Middle: 2
Right: 3
"""
def __init__(self, fig, button=3):
self.fig = fig
@ianhi
ianhi / imshow_zoom.py
Last active October 14, 2020 19:45 — forked from tacaswell/simp_zoom.py
factory for adding zoom callback to matplotlib imshow - now available via https://github.com/ianhi/mpl-interactions
import matplotlib.pyplot as plt
def zoom_factory(ax,base_scale = 1.1):
"""
parameters
----------
ax : matplotlib axes object
axis on which to implement scroll to zoom
base_scale : float
how much zoom on each tick of scroll wheel