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
from ipywidgets.widgets import HBox, VBox | |
import matplotlib.pyplot as plt | |
def plot(s, orientation='horizontal'): | |
""" | |
Plot hyperspy signals horizontally using the %matplotlib widget interface. | |
Can also plot vertically using orientation='vertical' | |
""" | |
# if 1D signal, just plot normal |
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
--------------------------------------------------------------------------- | |
AttributeError Traceback (most recent call last) | |
~\.conda\envs\py5\lib\site-packages\matplotlib\backend_bases.py in _wait_cursor_for_draw_cm(self) | |
2772 try: | |
-> 2773 self.set_cursor(cursors.WAIT) | |
2774 yield | |
~\.conda\envs\py5\lib\site-packages\matplotlib\backends\backend_webagg_core.py in set_cursor(self, cursor) | |
380 if cursor != self.cursor: | |
--> 381 self.canvas.send_event("cursor", cursor=cursor) |
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 | |
# get electropy from thomasaarholt github | |
from electropy.units import eV_to_wavelength | |
# get colour by pip install colour-science | |
from colour.utilities import first_item, normalise_maximum | |
from colour.plotting import filter_cmfs, XYZ_to_plotting_colourspace, COLOUR_STYLE_CONSTANTS | |
from colour.colorimetry import wavelength_to_XYZ, ILLUMINANTS |
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
''' | |
Python script to load any format supported by hyperspy directly into GMS | |
Must be copied and pasted into Gatan DigitalMicrograph (aka Gatan Microscopy Suite) version 3.4+ | |
Call by `load_img(filepath)` at the bottom of the script. Can not be called outside of GMS. | |
Does not automatically convert the data type to EELS or EDS | |
Written by Thomas Aarholt, see https://gist.github.com/thomasaarholt/fccf06d56ff84cf76345b44dae30871e for newer versions | |
Feedback and forks are very welcome. | |
MUST: First import of hyperspy (or scipy) must NOT be run with "Execute on background thread" checked. One | |
can then swap to background thread and rerun. | |
v. 0.3: Added delete statements to ensure python objects don't stay in memory. |
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 keras.backend as K | |
import tensorflow as tf | |
from keras.layers import Layer | |
from keras.layers import Conv2D | |
"""Not tested, I'll play around with GANs soon with it.""" | |
class CoordConv2D(Layer): | |
def __init__(self, channel, kernel, padding='valid', activation=None, **kwargs): |
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
(tensor)/shared/users/thomasaar/2020Feb: python | |
Python 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 22:33:48) | |
[GCC 7.3.0] on linux | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import tensorflow as tf | |
2020-02-10 16:54:19.147934: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.1/lib64:/usr/local/cuda-10.1/lib64:/shared/users/thomasaar/py37/lib:/shared/users/thomasaar/compiled/fftw/lib:/shared/users/thomasaar/compiled/prismatic/lib: | |
2020-02-10 16:54:19.149366: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.1/lib64:/usr/local/cuda-10.1/lib64:/shared/users/thomasaar/py37/lib:/shared/users/th |
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
# Content of script run in GMS | |
import sys | |
sys.path.append(r"C:\Users\thomasaar\Documents\GMS Scripts") | |
import thomas | |
from importlib import reload | |
reload(thomas) | |
thomas.helloworld() | |
# Content of thomas.py in GMS Scripts folder |
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
# In Velox, choose a dataset and select all elements in the periodic table (This is a little tedious) | |
# From the Velox Menu, go "EDS" -> "Export Quantification Details..." | |
# This exports two files, one called "... Lines" and one called "... Composition". We want the former. | |
import pandas as pd | |
df = pd.read_csv(r"exported_eds_quant-Lines.csv") | |
DF = df.iloc[1:] # There was a single blank line in my dataset, so I get rid of it | |
DF.loc[:,'K-factor'] = DF['K-factor'].astype(float) # String to float on the k-factors | |
# Two functions that we map across the dataset to split the header into separate elements and line | |
def splitelement(entry): |
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 | |
fig = plt.figure() | |
ax1 = fig.add_subplot(111) | |
ax2 = ax1.twiny() | |
X = np.linspace(1,1000,1000) | |
Y = np.cos(X/200) |
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 is_notebook(): | |
try: | |
from IPython import get_ipython | |
if "IPKernelApp" not in get_ipython().config: # pragma: no cover | |
raise ImportError("console") | |
return False | |
if "VSCODE_PID" in os.environ: # pragma: no cover | |
raise ImportError("vscode") | |
return False |