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
thomasaarholt / zigzag.py
Created Aug 6, 2019
Zigzag scanning hyperspy example
View zigzag.py
import hyperspy.api as hs
import numpy as np
import matplotlib.pyplot as plt
def Gauss2D(X, Y, A=1, cx=0, cy=0, sx=1, sy=1):
return A*np.exp(-( ((X - cx)**2)/(2*sx**2) + ((Y - cy)**2)/(2*sy**2)))
def Gauss(x, A=1, c=0, s=1):
return A*np.exp(-((x - c)**2)/(2*s**2))
@thomasaarholt
thomasaarholt / gaussian_filter_tensorflow.py
Last active Jul 12, 2019
Gaussian filter of 2D image in Tensorflow 2.0 on GPU
View gaussian_filter_tensorflow.py
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import tensorflow_probability as tfp
from time import time
def toImage(tensor):
return tensor.reshape(tensor.shape[:2])
def gaussian_kernel(size: int,
@thomasaarholt
thomasaarholt / gaussian.py
Last active Jul 11, 2019
Fastest found method of generating a gaussian kernel of size n x nand standard deviation std.
View gaussian.py
import numpy as np
from scipy import signal
def gaussian_kernel(n, std, normalised=False):
'''
Generates a n x n matrix with a centered gaussian
of standard deviation std centered on it. If normalised,
its volume equals 1.'''
gaussian1D = signal.gaussian(n, std)
gaussian2D = np.outer(gaussian1D, gaussian1D)
@thomasaarholt
thomasaarholt / odemis_acq.py
Last active Jul 4, 2019
Rough approximation of our approach to odemis SI acquisition
View odemis_acq.py
def approx_acquisition_method():
self.spect.data.synchronizedOn(self.escan.newPosition)
startt = time.time()
self.spect.data.subscribe(self.receive_spect_point)
sed_data = self.sed.data.get()
# wait the last point is fully acquired
self.acq_complete.wait()
@thomasaarholt
thomasaarholt / autoscale.py
Last active Jul 1, 2019
Matplotlib autoscale
View autoscale.py
def autoscale(ax=None, axis='y', margin=0.1):
'''Autoscales the x or y axis of a given matplotlib ax object
to fit the margins set by manually limits of the other axis,
with margins in fraction of the width of the plot
Defaults to current axes object if not specified.
'''
import matplotlib.pyplot as plt
import numpy as np
if ax is None:
View quantum_espresso_compilation
(/shared/users/thomasaar/py37) /shared/users/thomasaar/downloads/q-e-gpu-qe-gpu-6.4.1a1: ./configure --with-cuda=/opt/pgi/linux86-64/2018/cuda/9.2/bin --with-cuda-runtime=9.2 --with-cuda-cc=7.5 --enable-openmp --with-scalapack=no --prefix=/shared/users/thomasaar/compiled/q-e-gpu
checking build system type... x86_64-pc-linux-gnu
checking ARCH... x86_64
checking setting AR... ... /shared/users/thomasaar/py37/bin/x86_64-conda_cos6-linux-gnu-ar
checking setting ARFLAGS... ... ruv
checking whether the Fortran compiler works... yes
checking for Fortran compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
View henrik.py
import numpy as np
x = np.array([500, 500, 500, 1000, 1000, 1000, 1500])
y = np.array([1,2,3,4,5,6,7])
data = np.stack([x,y]).T
means = []
stds = []
for xi in np.unique(data[:,0]):
@thomasaarholt
thomasaarholt / velox_dcfi.py
Last active Jun 17, 2019
Get DCFI shifts from a velox STEM file, then apply them to all the raw signals in the dataset.
View velox_dcfi.py
# Script should be applied to a single Velox emd file, where the file contains a single DCFI dataset
# that has been applied to the detector signal that one wishes to apply to the other detector signals
# A good example is using DCFI on a DF image, and then applying this correction to HAADF, BF and ABF.
import hyperspy.api as hs
import json
import h5py
import numpy as np
def get_nonDCFI_signals(list_of_signals):
@thomasaarholt
thomasaarholt / gist:5fc33ed59c846bbf64999a17324b1432
Created Jun 15, 2019
make.inc.in from attempted compiling of quantum espresso GPU version
View gist:5fc33ed59c846bbf64999a17324b1432
(/shared/users/thomasaar/py37) /shared/users/thomasaar/downloads/q-e-gpu/install: more make.inc.in
# @configure_input@
# compilation rules
.SUFFIXES :
.SUFFIXES : .o .c .f .f90
# most fortran compilers can directly preprocess c-like directives: use
# $(MPIF90) $(F90FLAGS) -c $<
View opt2.py
import numpy as np
machineTime = {
'm1': {
'p1':20,
'p2':np.nan,
'p3':70,
'p4':4,
},
You can’t perform that action at this time.