Skip to content

Instantly share code, notes, and snippets.

View stefsmeets's full-sized avatar

Stef Smeets stefsmeets

  • Netherlands eScience Center
  • Amsterdam, NL
View GitHub Profile
@stefsmeets
stefsmeets / covbadge.svg
Last active July 18, 2024 14:10
gemdat coverage badge
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefsmeets
stefsmeets / covbadge.svg
Last active June 18, 2024 13:49
unraphael coverage badge
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefsmeets
stefsmeets / watershed_pbc.py
Created August 30, 2023 10:12
Watershed with periodic boundary conditions
from skimage.segmentation import _watershed, _watershed_cy
from skimage.morphology._util import (_validate_connectivity,
_offsets_to_raveled_neighbors)
def watershed_pbc(image, markers=None, connectivity=1, offset=None, mask=None,
compactness=0, watershed_line=False):
"""https://github.com/scikit-image/scikit-image/blob/main/skimage/segmentation/_watershed.py"""
image, markers, mask = _watershed._validate_inputs(image, markers, mask, connectivity)
connectivity, offset = _watershed._validate_connectivity(image.ndim, connectivity,
@stefsmeets
stefsmeets / streamlit_webview.py
Last active October 7, 2022 14:24
Run streamlit in its own webview
import atexit
import subprocess as sp
import os
from PySide2 import QtCore, QtWebEngineWidgets, QtWidgets
def kill_server(p):
if os.name == 'nt':
# p.kill is not adequate
sp.call(['taskkill', '/F', '/T', '/PID', str(p.pid)])
import numpy as np
from scipy.stats import norm
import matplotlib.pyplot as plt
import streamlit as st
st.title('Normal distribution')
mu_in = st.slider('Mean', value=5, min_value=-10, max_value=10)
std_in = st.slider('Standard deviation', value=5.0, min_value=0.0, max_value=10.0)
size = st.slider('Number of samples', value=100, max_value=500)
import numpy as np
from scipy.stats import norm
import matplotlib.pyplot as plt
mu_in = 5
std_in = 5.0
size = 100
def norm_dist(mu, std, size=100):
"""Generate normal distribution."""
@stefsmeets
stefsmeets / Run recipe single diagnostic.ipynb
Created January 27, 2021 13:16
Run recipe single diagnostic
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefsmeets
stefsmeets / Run recipe get output.ipynb
Last active January 22, 2021 14:46
Get recipe output from notebook API
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefsmeets
stefsmeets / Run recipe.ipynb
Last active January 6, 2021 11:32
run recipe in a notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefsmeets
stefsmeets / find and list recipes in notebook.ipynb
Last active December 16, 2020 14:40
List ESMValTool recipes in a notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.