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 / samf_ red_chisq.py
Last active Dec 7, 2016
red_chisq issue with SAMFire
View samf_ red_chisq.py
SAM = m.create_samfire()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-21-edd4774a10cd> in <module>()
----> 1 SAM = m.create_samfire()
/Users/thomas/Dropbox/0_Git/GitHub/hyperspy_aar/hyperspy/model.py in create_samfire(self, workers, setup, **kwargs)
1780 from hyperspy.samfire import Samfire
1781 return Samfire(self, workers=workers,
-> 1782 setup=setup, **kwargs)
@thomasaarholt
thomasaarholt / Fit_Zr_good.py
Last active Jan 17, 2017
Good, slow fitting of the zirconium L white lines
View Fit_Zr_good.py
def fit_Zr_L(sZr, ll=None):
"Fits the Zr L lines, return a hyperspy model. Input is a Zr spectrum image, and optionally, the accompanying low loss SI."
print("Will produce 10 progress bars")
mZr = sZr.create_model(ll = ll, GOS="Hartree-Slater", auto_add_edges=False)
# Fit Background
mZr.fit_component(mZr["PowerLaw"], bounded=True, signal_range=[2150.,2210.], fit_independent=True, only_current=True)
mZr.assign_current_values_to_all()
mZr.fit_component(mZr["PowerLaw"], bounded=True, signal_range=[2150.,2210.], fit_independent=True, only_current=False)
@thomasaarholt
thomasaarholt / Fit_Zr_fast.py
Created Jan 17, 2017
Fast but poor fitting of the zirconium L white lines
View Fit_Zr_fast.py
m = Zr.create_model(ll, GOS="Hartree-Slater")
Zr_L3_white = hs.model.components1D.Gaussian()
Zr_L3_white.name = "Zr L3 White Line"
Zr_L3_white.centre.bmin = 2218.0
Zr_L3_white.centre.bmax = 2240.0
Zr_L3_white.sigma.bmax=3
Zr_L3_white.A.bmin = 0
Zr_L2_white = hs.model.components1D.Gaussian()
View L-BFGS-B_grad_error.py
>>> m.fit(fitter="L-BFGS-B", bounded=True, grad=True)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-118-e2c35f346c6e> in <module>()
50
51 #m.fit(fitter="leastsq", bounded=True, grad=True)
---> 52 m.fit(fitter="L-BFGS-B", bounded=True, grad=True)
53
54
View Hyperspy install error
(C:\ProgramData\Miniconda3) C:\Users\thomasaar>pip install -e M:\pc\Dokumenter\GitHub\hyperspy
Obtaining file:///M:/pc/Dokumenter/GitHub/hyperspy
Complete output from command python setup.py egg_info:
test_compilers.c
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "M:\pc\Dokumenter\GitHub\hyperspy\setup.py", line 295, in <module>
with update_version_when_dev() as version:
File "M:\pc\Dokumenter\GitHub\hyperspy\setup.py", line 273, in __enter__
@thomasaarholt
thomasaarholt / fail.py
Created Apr 8, 2017
Bug when installing hyperspy from loca repo
View fail.py
PS C:\Users\thomasaar\Downloads\hyperspy> pip install -e ./
Obtaining file:///C:/Users/thomasaar/Downloads/hyperspy
Complete output from command python setup.py egg_info:
test_compilers.c
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\thomasaar\Downloads\hyperspy\setup.py", line 294, in <module>
with update_version_when_dev() as version:
File "C:\Users\thomasaar\Downloads\hyperspy\setup.py", line 272, in __enter__
stdout=subprocess.PIPE)
@thomasaarholt
thomasaarholt / spikesbug.py
Created Apr 8, 2017
Spikes removal error
View spikesbug.py
# When stepping through the signal looking for spikes, suddenly:
Exception occurred in traits notification handler for object: <hyperspy.signal_tools.SpikesRemoval object at 0x12835e048>, trait: ss_right_value, old value: nan, new value: 0.0
Traceback (most recent call last):
File "/Users/thomas/miniconda3/envs/hs/lib/python3.5/site-packages/traits/trait_notifiers.py", line 340, in __call__
self.handler( *args )
File "/Users/thomas/hyperspy/hyperspy/signal_tools.py", line 968, in _ss_right_value_changed
self.span_selector_changed()
File "/Users/thomas/hyperspy/hyperspy/signal_tools.py", line 1047, in span_selector_changed
self.interpolated_line.update()
@thomasaarholt
thomasaarholt / spikesbug2.py
Created Apr 8, 2017
"Remove spikes" at start, error
View spikesbug2.py
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/thomas/hyperspy/hyperspy/gui_ipywidgets/tools.py in on_remove_clicked(b)
416
417 def on_remove_clicked(b):
--> 418 obj.apply()
419 remove.on_click(on_remove_clicked)
420 labeled_spline_order = labelme("Spline order", spline_order)
/Users/thomas/hyperspy/hyperspy/signal_tools.py in apply(self)
@thomasaarholt
thomasaarholt / Line2DROI_aar.py
Created Apr 27, 2017
Hyperspy automatic Line2DROI
View Line2DROI_aar.py
def create_Line_on_DF(s, lineROI=[], hide=False):
"""
Plots a hyperspy signal and draws an interactive ROI on it on the top left tenth of the image.
Can take a list of [x1, y1, x2, y2, linewidth] to set a known intial ROI.
Returns a tuple of (roi, roi_signal). Use hide=True to not show the plot.
Please report bugs/improvements to thomasaarholt@gmail.com
"""
import hyperspy.api as hs
if s.axes_manager.navigation_dimension < 2:
@thomasaarholt
thomasaarholt / selectfile.py
Created Jun 1, 2017 — forked from DrDub/selectfile.py
A file selection class build for ipywidgets without any extra dependencies.
View selectfile.py
import os
import ipywidgets as widgets
class FileBrowser(object):
def __init__(self):
self.path = os.getcwd()
self._update_files()
You can’t perform that action at this time.