Skip to content

Instantly share code, notes, and snippets.

View tlambert03's full-sized avatar

Talley Lambert tlambert03

View GitHub Profile
@tlambert03
tlambert03 / benchscope.py
Last active March 24, 2025 13:22
benchscope
# /// script
# requires-python = "==3.12"
# dependencies = [
# "pymmcore-plus",
# "pymmcore-widgets",
# "ndv[vispy,pyqt]",
# ]
# ///
import numpy as np
from pymmcore_plus import CMMCorePlus
@tlambert03
tlambert03 / zarr_bench.py
Last active February 26, 2025 19:19
benchmarking acquire-zarr and tensorstore
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "acquire-zarr",
# "zarr",
# "rich",
# "tensorstore",
# ]
# ///
#!/usr/bin/env python3
@tlambert03
tlambert03 / exampleqt.py
Created November 10, 2024 16:55
Shared script for uv run
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "pyqt6",
# ]
# ///
import sys
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QGridLayout
app = QApplication(sys.argv)
@tlambert03
tlambert03 / hello.py
Created November 10, 2024 16:20
example PyQt6 hello for uv testing
import sys
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QGridLayout
app = QApplication(sys.argv)
widget = QWidget()
grid = QGridLayout()
text_label = QLabel()
text_label.setText("Hello World!")
grid.addWidget(text_label)
@tlambert03
tlambert03 / indexing.py
Last active May 9, 2024 19:48
indexing
# %%
import numpy as np
# example of a 1-dimensional index:
N = 10
index = np.logspace(0, 1, 10) # i.e. what would be a single coord in xarray
data = np.random.rand(N)
print(data)
print(index)
@tlambert03
tlambert03 / gui_apis.py
Last active February 25, 2024 22:57
gui apis
‎‎​
@tlambert03
tlambert03 / mmti2.py
Last active January 22, 2024 18:10
Install Ti2
# https://bit.ly/4b9xkgI
# run with:
# powershell -Command "(New-Object Net.WebClient).DownloadString('https://bit.ly/4b9xkgI') | python"
# you may wish to change "python" to a specific version/env of python, e.g.
# powershell -Command "(New-Object Net.WebClient).DownloadString('https://bit.ly/4b9xkgI') | C:\Users\User\miniforge3\envs\mm\python.exe"
# or without powershell, if you have curl
# curl -L -o install_mm.py https://bit.ly/4b9xkgI && python install_mm.py && del install_mm.py
import urllib.request
@tlambert03
tlambert03 / photobleach.py
Last active December 20, 2023 21:19
Photobleaching calculations
import math
import pint
AVOGADRO = pint.Quantity("6.02214076e23 /mol")
PLANCK = pint.Quantity("6.62607015e-34 J*s")
C = pint.Quantity("299792458 m/s")
def _ensure_quantity(value: str | float | pint.Quantity, units: str) -> pint.Quantity:
quant = pint.Quantity(value)
@tlambert03
tlambert03 / build_mm.sh
Last active July 6, 2023 17:24
This script will download micro-manager and build just the DemoCamera. Can be used on apple silicon (with home-brew installed)
#!/bin/bash
# output to the current directory if no argument is given
if [[ $# -eq 0 ]]; then
OUTPUT=$(pwd)
else
OUTPUT=$1
fi
packages=("autoconf" "automake" "libtool" "boost")
from turtle import position
from typing import Sequence
import scipy.special
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import patches
from matplotlib.animation import FuncAnimation
import warnings
from scipy.fft import fft, fftshift, ifftshift, fftfreq