Skip to content

Instantly share code, notes, and snippets.

View ZGainsforth's full-sized avatar

Zack Gainsforth ZGainsforth

  • University of California at Berkeley
  • Los Angeles, CA, USA
View GitHub Profile
@ZGainsforth
ZGainsforth / ProcessEELSSpectra.ipynb
Last active July 23, 2018 21:00
Notebook with all functions needed for a variety of EELS processing with low loss deconvolution. Includes summing similar spectra.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / Compute compositions from unit cell.ipynb
Created November 9, 2018 22:41
Compute compositions of pyroxene from the unit cell measured by XRD.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / ManyElementsinChimeraX.cxc
Last active April 10, 2019 23:49
ChimeraX command file to load many mrc files in for RGB viewing
# Reds
open "../C_reconstruction_cropped.mrc"
volume voxelsize 1
view orient cofr false
volume median #1 binSize 3
close #1
volume #2 style surface color red
volume #2 projectionmode 3d
volume #2 hide
@ZGainsforth
ZGainsforth / ChimeraXRecordMovie.cxc
Created December 12, 2018 02:25
Record a movie in ChimeraX after loading RGB tomograph
# Make the window some standard size
windowsize 1000 1000
# Choose an orientation by going to the default, and then doing rotations.
view cofr false
turn y 90
turn x 180
# And record the movie.
movie record ; turn y 1 360 ; wait ; movie encode
@ZGainsforth
ZGainsforth / Trim Volumes.ipynb
Last active April 12, 2019 17:48
Trim tomography volumes from GENFIRE
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / ProcessImages.bash
Created January 26, 2019 20:00
Shell script to crop and adjust resolution of images in pipeline
#!/bin/bash
extension=jpeg
function docrop {
mogrify -crop $1 $2.$extension
rm $2-1.$extension
mv $2-0.$extension $2.$extension
}
@ZGainsforth
ZGainsforth / getdots.sh
Last active February 6, 2019 05:49
Shell script to bring down dot files (.vimrc, .zshrc) and diff them with the local ones.
#!/bin/bash
# For my macs.
VIMCOMMAND='mvimdiff -f'
# For unix.
# VIMCOMMAND=vimdiff
cd ~
# RED='\033[0;31m'
@ZGainsforth
ZGainsforth / PrintGENFIREStats.py
Last active February 9, 2019 09:40
Examine and tabulate the statistics from a GENFIRE EDS tomography reconstruction.
import numpy as np
from tabulate import tabulate
import genfire
print('------------------------------ START ------------------------------')
# List of elements to process. We handle Sum separately.
Elements = ['C', 'O', 'Mg', 'Al', 'Si', 'S', 'Ca', 'Fe', 'Ni', 'Sum']
@ZGainsforth
ZGainsforth / DoGenfire.py
Created April 12, 2019 02:29
Python script to run GENFIRE on a server
import genfire as gf
import sys, os, shutil
import argparse
# Parse command line arguments.
parser = argparse.ArgumentParser()
parser.add_argument("fileroot", help="There should be an aligned tomo stack named fileroot_aligned.npy in the directory and a the reconstruction will be named fileroot_reconstruction.mrc.")
parser.add_argument("-n", "--numIterations", help="Default number of GENFIRE iterations. See GENFIRE documentation. Default=100.", type=int, default=100, action="store")
parser.add_argument("-o", "--oversamplingRatio", help="How many times bigger to make the fourier space. Bigger is more accurate, but you may run out of memory. See GENFIRE documentation. Default=4.", type=int, default=4, action="store")
args = parser.parse_args()
@ZGainsforth
ZGainsforth / Decomposition on Ptycho map.ipynb
Last active November 15, 2019 01:26
ICA, NMF and PCA decomposition and spectrum extraction of a ptychographic map.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.