Skip to content

Instantly share code, notes, and snippets.

View thomasaarholt's full-sized avatar

Thomas Aarholt thomasaarholt

View GitHub Profile
import numpy as np
machineTime = {
'm1': {
'p1':20,
'p2':np.nan,
'p3':70,
'p4':4,
},
@thomasaarholt
thomasaarholt / chromatic_aberration_simulation.py
Last active March 4, 2019 22:06
Calculate the standard deviation of the gaussian distribution in defocus caused by chromatic aberration in the STEM
import matplotlib.pyplot as plt
import numpy as np
import sympy as sp
sp.init_printing()
E0, dE, Cc = sp.symbols('E0, dE, C_c, ')
deltaZ_sigma = Cc*dE/E0#*2*sp.sqrt(2*sp.log(2))
zlp = 0.9
@thomasaarholt
thomasaarholt / .profile
Last active March 23, 2021 10:08
.profile used on Machine Learning Cluster
echo 'Hello Thomas - edit PATH using "profile"'
alias ls="ls --color"
alias cd..='cd ../' # Go back 1 directory level (for fast typers)
alias cd...='cd ../../'
alias ..='cd ../' # Go back 1 directory level
alias ...='cd ../../' # Go back 2 directory levels
alias .3='cd ../../../' # Go back 3 directory levels
alias .4='cd ../../../../' # Go back 4 directory levels
@thomasaarholt
thomasaarholt / .inputrc
Created February 27, 2019 21:21
Absolutely necessary .inputrc hotkeys for navigating in bash
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
@thomasaarholt
thomasaarholt / colorbar.py
Last active December 3, 2019 14:34
Add colorbar next to image
from mpl_toolkits.axes_grid1 import make_axes_locatable
def colorbar(mappable):
"mappable is img = plt.imshow()"
ax = mappable.axes
fig = ax.figure
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
cax.aname = 'colorbar'
return fig.colorbar(mappable, cax=cax)
@thomasaarholt
thomasaarholt / win2lin.py
Created February 26, 2019 08:54
Convert Windows filepath to Ubuntu on Windows filepath
from pathlib import Path
def win2lin(rpath: r"C:\Users..."):
path = rpath.replace("\\", "/").replace(":/", "/")
drive = path[0]
path = Path("/mnt/") / Path(drive.lower() + path[1:])
return path
### Example:
# >>> win2lin(r"C:\Users\myuser\Documents")
# PosixPath('/mnt/c/Users/myuser/Documents')
Timer unit: 1e-06 s
Total time: 0.265183 s
File: /mnt/c/Users/thomasaar/Documents/atomap/atomap/atom_finding_refining.py
Function: _make_model_from_atom_list at line 740
Line # Hits Time Per Hit % Time Line Contents
==============================================================
740 def _make_model_from_atom_list(
741 atom_list,
def border_elems(image_2d, pixels=1): # Input array : a, Edgewidth : W
n = image_2d.shape[0]
r = np.minimum(np.arange(n)[::-1], np.arange(n))
return image_2d[np.minimum(r[:,None],r)<pixels]
def remove_integrated_edge_cells(i_points, i_record, p_record,
pixels=1, inplace=False):
'''
Removes any cells that touch within a number of pixels of
the image border.
import numpy as np
import math
import copy
from tqdm import tqdm, trange
from scipy import interpolate
from scipy import ndimage
from scipy.spatial import cKDTree
import matplotlib.pyplot as plt
import hyperspy.api as hs
from hyperspy.signals import Signal1D, Signal2D
tmux attach