Skip to content

Instantly share code, notes, and snippets.

Thomas Aarholt thomasaarholt

  • University of Oxford
  • Oxford, UK
Block or report user

Report or block thomasaarholt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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"'
# 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 / .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 /
Last active Mar 11, 2019
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 /
Created Feb 26, 2019
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')
View profile_atomap
Timer unit: 1e-06 s
Total time: 0.265183 s
File: /mnt/c/Users/thomasaar/Documents/atomap/atomap/
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.
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
screen -aAxR -S x # Connect without disconnecting
screen -dRaA -S x # Connect and disconnect others
thomasaarholt /
Last active Mar 21, 2019
Remote Jupyter Notebook through ssh tunnel

Using Jupyter notebook remotely via a ssh tunnel.

Especially good for running on headless devices, such as supercomputers or clusters.


# remote_port should be value between 8888 and 9000
jupyter notebook --no-browser --port=remote_port

Locally, new terminal window

You can’t perform that action at this time.