Skip to content

Instantly share code, notes, and snippets.

View skuschel's full-sized avatar
💡
_

Stephan Kuschel skuschel

💡
_
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@skuschel
skuschel / .gitconfig
Last active March 31, 2021 11:11
.gitconfig
[log]
decorate = true
showSignature = true
[diff]
renames = copy
[alias]
lg = log --graph --no-show-signature \
--format='%C(auto)%h%d%Creset %s%Cgreen(%cr) %C(bold blue)<%an>%Creset'
ls = ls-files -t
fa = fetch --all
@skuschel
skuschel / atomicformfactor.py
Last active December 15, 2020 23:32
Download atomic form factors from henke and NIST directly within python
import functools
import requests
from io import StringIO
from bs4 import BeautifulSoup
from urllib.parse import urljoin
# Henke
def atomicformfactor_henke(element):
element = element.lower()
@skuschel
skuschel / evalwatch.py
Created February 4, 2020 00:01
watch a function while its beeing evaluated
#!/usr/bin/python3
# Stephan Kuschel, May 2019
import matplotlib.pyplot as plt
import numpy as np
def addcolorbar(ax, im, pos='right', size='5%', pad=0.05, orientation='vertical',
stub=False, max_ticks=None, label=None):
'''
@skuschel
skuschel / removeprinters.sh
Created May 16, 2019 02:21
CUPS remove all printers pointing to /dev/null
#!/bin/bash
# Stephan Kuschel, 2019
# Works the regex grabbing the printers requires works if computer is set to german. Change sed cmd
# accordingly if this is not the case.
lpstat -s | grep null | sed 's#Gerät für \(.*\): ///dev/null#\1#' | xargs -n1 lpadmin -x
@skuschel
skuschel / singlephotons.py
Last active February 26, 2019 21:21
Single photon counting
def findsinglephotons(image, thresupper, threslower, maxsize=2):
'''
identifies single photons in the image and returns the for each photon the integrated counts on the image
* a photon need to be above the thresupper in order to be found
* surrounding regions of a photon will be added as long as they are above the threslower value
* maxsize=2 controlls over how many pixels a photon may spread
Stephan Kuschel, 2019
https://gist.github.com/skuschel/4823d53067263507a04c07ff7f84255f
@skuschel
skuschel / pcov.py
Last active March 4, 2019 21:26
Partial Covariance
def pcov(data, I=None, corrcoef=False, rowvar=True):
'''
Partial covariance
Stephan Kuschel, 2019
https://gist.github.com/skuschel/9cd745c4b47ad579481b1ade6115250a
'''
import numpy as np
if I is None:
I = np.mean(data, axis=0 if rowvar else 1)
@skuschel
skuschel / epoch_exampledata.tar.xz
Last active March 6, 2018 17:19
epoch exampledata
This file has been truncated, but you can view the full file.
@skuschel
skuschel / install ipyparallel.ipynb
Created January 20, 2017 16:33
Installs ipyparallel in userspace and activates the profile on the "IPython Clusters" tab in jupyter.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@skuschel
skuschel / addcolorbar.py
Last active August 6, 2019 13:39
Matplotlib addcolorbar
def addcolorbar(ax, im, pos='right', size='5%', pad=0.05, orientation='vertical',
stub=False, max_ticks=None, label=None):
'''
add a colorbar to a matplotlib image.
ax -- the axis object the image is drawn in
im -- the image (return value of ax.imshow(...))
When changed, please update:
https://gist.github.com/skuschel/85f0645bd6e37509164510290435a85a