Skip to content

Instantly share code, notes, and snippets.

Thomas Aarholt thomasaarholt

  • University of Oxford
  • Oxford, UK
View GitHub Profile
View opt2.py
import numpy as np
machineTime = {
'm1': {
'p1':20,
'p2':np.nan,
'p3':70,
'p4':4,
},
@thomasaarholt
thomasaarholt / chromatic_aberration_simulation.py
Last active Mar 4, 2019
Calculate the standard deviation of the gaussian distribution in defocus caused by chromatic aberration in the STEM
View chromatic_aberration_simulation.py
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
Created Feb 27, 2019
.profile used on Machine Learning Cluster
View .profile
GNU nano 2.5.3 File: /shared/users/thomasaar/.profile
PS1='$(pwd): '
echo 'Hello Thomas - edit PATH using "profile"'
echo "YOU ARE NOT IN HOME - YOU ARE ON SHARED"
# This is a comment
echo 'Enabling environment for pyprismatic'
export CPLUS_INCLUDE_PATH=/usr/local/cuda-10.0/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=$HOME/fftw_gcc5_build/lib64:/usr/local/cuda-10.0/lib64:$HOME/prismatic_gcc5/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$HOME/fftw_gcc5_build/lib64:/usr/local/cuda-10.0/lib64:$HOME/prismatic_gcc5/lib:$LIBRARY_PATH
@thomasaarholt
thomasaarholt / .inputrc
Created Feb 27, 2019
Absolutely necessary .inputrc hotkeys for navigating in bash
View .inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
@thomasaarholt
thomasaarholt / colorbar.py
Last active Mar 11, 2019
Add colorbar next to image
View colorbar.py
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 Feb 26, 2019
Convert Windows filepath to Ubuntu on Windows filepath
View win2lin.py
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')
View profile_atomap
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,
View remove_voronoi_edge_cells
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.
View test.py
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
You can’t perform that action at this time.