This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
def figure(figsize=None): | |
'Temporary workaround for traditional figure behaviour with the ipympl widget backend' | |
fig = plt.figure() | |
if figsize: | |
w, h = figsize | |
else: | |
w, h = plt.rcParams['figure.figsize'] | |
fig.canvas.layout.height = str(h) + 'in' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(/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 $< |