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
| # -*- coding: utf-8 -*- | |
| from matplotlib import * | |
| use('Qt4Agg') | |
| from matplotlib.pyplot import * | |
| from numpy import * | |
| def PlotRFFT(x, y): | |
| ### PlotRFFT(x, y): plots the FFT of y assuming y is real. Generates one plot with two subfigures: abscissa = frequency and abscissa = period. | |
| f = fft.rfft(y)/len(y)*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
| def BinImage(img, binsize): | |
| imgbin = zeros(array(img.shape)/binsize) | |
| for i in range(binsize): | |
| for j in range(binsize): | |
| imgbin += img[i::binsize, j::binsize] | |
| return imgbin |
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 imshowz(image, ax=None, *args, **kwargs): | |
| """ wrapper for matplotlib imshow that displays the value under the cursor position | |
| Wrapper for pyplot.imshow that sets up a custom mouseover display formatter | |
| so that mouse motions over the image are labeled in the status bar with | |
| pixel numerical value as well as X and Y coords. | |
| Why this behavior isn't the matplotlib default, I have no idea... | |
| """ | |
| if ax is None: ax = plt.gca() |
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 fullprint(*args, **kwargs): | |
| from pprint import pprint | |
| import numpy | |
| opt = numpy.get_printoptions() | |
| numpy.set_printoptions(threshold='nan') | |
| pprint(*args, **kwargs) | |
| numpy.set_printoptions(**opt) |
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
| #-*- coding: utf-8 -*- | |
| # Written by Zack Gainsforth 2015 | |
| # Using the constants from | |
| # | |
| # Low-Energy X-ray Interaction Coefficients: | |
| # Photoabsorption, Scattering, and Reflection | |
| # E = 30-30,000 eV, Z = 1-92 | |
| # | |
| # B. L. Henke, E. M. Gullikson, and J. C. Davis |
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
| # Created 2014, Zack Gainsforth import matplotlib matplotlib.use('Qt4Agg') import matplotlib.pyplot as plt import numpy as np #import QuickPlot import re from StringIO import StringIO import glob import os def GetalphaMELTSSection(FileName, SectionName): # Read the alphaMELTS file that has all the output. try: with open (FileName, 'r') as myfile: data=myfile.read() except: print 'Failed to open ' + FileName + '. Skipping.' return DataLines = StringIO(data) reout = re.compile(r'%s.*?(?:\n\n|\Z)' % (SectionName), re.S) # reout = re.compile(r'%s.*?%s' % (SectionName, stop), re.S) try: SectionStr = reout.search(data).group(0) except: # It is possible that this MELTS computation didn't produce this mineral. If so, just bail. return None # Convert it into a numpy array. SectionData = np.genfromtxt(StringIO(SectionStr), skip_header=1, skip_footer=0, names=True) return SectionData def ListalphaMELTSSections(Fi |
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
| # Created 2015, Zack Gainsforth | |
| import matplotlib | |
| matplotlib.use('Qt4Agg') | |
| import matplotlib.pyplot as plt | |
| from matplotlib.image import imsave | |
| import numpy as np | |
| import sys | |
| import math | |
| import os | |
| from numba import jit |
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
| # Created 2015, Zack Gainsforth | |
| import matplotlib | |
| matplotlib.use('Qt4Agg') | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import wx | |
| import pandas as pd | |
| import sys, os | |
| if 'app' not in locals(): |
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
| # coding: utf-8 | |
| import h5py | |
| h5py.File('stack.emd', 'r') | |
| f = h5py.File('stack.emd', 'r') | |
| f[0] | |
| f['data'] | |
| f['data'][0] | |
| f['data'][1] | |
| f['data'] |
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 multiprocessing import Pool | |
| import numpy as np | |
| n = 1000000 | |
| x = 5 | |
| y = 5 | |
| z = 100 | |
| def f(x): | |
| #print x.shape |