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.spatial.transform import Rotation | |
import pylab as plt | |
from dxtbx.model import Crystal | |
from dxtbx.model.beam import BeamFactory | |
from scitbx.matrix import sqr | |
from simtbx import nanoBragg | |
from simtbx.nanoBragg.sim_data import Amatrix_dials2nanoBragg, SimData |
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 scipy import constants | |
import psana | |
import os | |
os.environ['PS_SRV_NODES']='1' | |
exp="mfx100861624" | |
run=14 | |
tag="test3" |
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 mpi4py import MPI | |
import h5py | |
import numpy as np | |
COMM = MPI.COMM_WORLD | |
nimg = COMM.size | |
with h5py.File("test.h5", "w", driver="mpio", comm=COMM) as h: | |
dset = h.create_dataset("data", shape=(nimg,512,512), dtype=np.float32) | |
for i in range(nimg): |
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
# After running dials.stills_process, convert the integrated.refls to an rs dataframe, and dump as an MTZ | |
from argparse import ArgumentParser | |
parser = ArgumentParser() | |
parser.add_argument("dirname", type=str, help="diffBragg.stills_process output folder with integrated.refls") | |
parser.add_argument("mtz", type=str, help="output mtz name") | |
parser.add_argument("--max", default=2500, type=int, help="max number of refls in a shot (default 2500)") | |
parser.add_argument("--ucell", default=None, nargs=6, type=float, help="unit cell params (default will be average experiment crystal)") | |
parser.add_argument("--symbol",type=str, default=None) | |
parser.add_argument("--batchFromFilename", action="store_true", help="get the batch ID from the filenames assuming it ends in the standard e.g. #####.cbf or #####.mccd ") |
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 argparse | |
par = argparse.ArgumentParser() | |
par.add_argument("input", help="input mtz from carelsss (*xval*.mtz)", type=str) | |
par.add_argument("output", default=None, help="output ASCII shelx file (FORMAT 3I4,2F8.2 for h,k,l,F,SigF).", type=str) | |
par.add_argument("--scale", type=float, default=1000, help="scale the F,SigF from Careless by this factor (needed for when careless SigFs are too small for F8.2 format)") | |
args = par.parse_args() | |
import numpy as np | |
import reciprocalspaceship as rs |
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
""" | |
Generate pseudo laue stills, saves as CBFs | |
Unless --noWaveImg flag is passed, an HDF5 file will be written containing the per-pixel wavelengths | |
Need to get 3 files first: | |
wget https://raw.githubusercontent.com/dermen/e080_laue/master/air.stol | |
wget https://raw.githubusercontent.com/dermen/e080_laue/master/from_vukica.lam | |
iotbx.fetch_pdb 7lvc | |
""" | |
#@profile |
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
# Compares the cost of renting vs owning a home | |
# Example usage: python own_vs_rent.py --price 3400000 --extra 500 --apr 0.0675 --nyears 10 --down 0.2 --growth 0.02 | |
def main(args): | |
PRICE = args.price #350000 # home value (sales price) | |
TAX_RATE = args.tax # annual tax rate (estimate for Pflugerville, Texas) | |
DOWNPAYMENT = PRICE*args.down # downpayment amount | |
LOAN = PRICE-DOWNPAYMENT # loan amount | |
YEARS = args.term # loan term (years) |
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 os | |
from dxtbx.model.beam import BeamFactory | |
from dxtbx.model.crystal import CrystalFactory | |
from dxtbx.model.detector import DetectorFactory, Detector, Panel | |
from simtbx.diffBragg import utils as db_utils | |
from simtbx.modeling import forward_models | |
from simtbx.nanoBragg import utils as nb_utils | |
# simulate this PDB (will be downloaded to current folder if doesnt exist | |
pdb_file = "4bs7.pdb" |
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 os | |
import sys | |
from scipy.spatial.transform import Rotation | |
import numpy as np | |
from iotbx import pdb as iotbx_pdb | |
from simtbx.nanoBragg import nanoBragg | |
from scitbx.matrix import sqr | |
from dxtbx.model import Crystal |
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 pylab import * | |
def get_color(r,g,b): | |
return r/255.,g/255.,b/255. | |
def get_patches(tvals_start, tvals_stop, rank, tcolors): | |
patches = [] | |
for i_t, (t1,t2) in enumerate(zip(tvals_start, tvals_stop)): | |
xy = np.array([(t1,rank-0.5), (t1, rank+0.5), (t2, rank+0.5), (t2, rank-0.5)]) | |
patch = mpl.patches.Polygon(xy=xy, color=tcolors[i_t], closed=True) #, ec='k', lw=0.5) |