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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
def load_gist(gist_id): | |
"""read gist source code""" | |
from json import load | |
from urllib.request import urlopen | |
gist_api = urlopen("https://api.github.com/gists/" + gist_id) |
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
""" | |
Example python code to adapt a jupyter notebook template and convert it to html | |
Uses nbformat and nbconvert | |
See also: papermill | |
""" | |
import os | |
import shutil | |
import nbformat |
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
""" | |
Create element-edge enum | |
X-Ray absorption edges are taken from the X-ray Data Booklet | |
https://xdb.lbl.gov/Section1/Sec_1-1.html | |
These are convieniently stored in Dans_Diffraction with other atomic data | |
$ pip install Dans_Diffraction | |
For refrences, see: https://github.com/DanPorter/Dans_Diffraction/tree/master/Dans_Diffraction/data |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
""" | |
Example of HdfMap code | |
GitHub repo: https://github.com/DiamondLightSource/hdfmap | |
Docs: https://diamondlightsource.github.io/hdfmap/ | |
installation: | |
$ python -m pip install hdfmap | |
Dan Porter 2024 |
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
""" | |
Find ExternalLink files in NeXus file | |
By Dan Porter | |
9 / 10/ 2024 | |
""" | |
import os | |
import h5py |
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
""" | |
Find NeXus files with external links | |
By Dan Porter | |
9 / 10/ 2024 | |
""" | |
import os | |
import h5py |
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 Dans_Diffraction as dif | |
xtl = Crystal('filename.cif') | |
# rotate the crystal basis | |
xtl.Cell.orientation.rotate_6circle(mu=5) # rotate about x-axis, in degrees | |
# get return the lab-frame q-vector for a single reflection: | |
q = xtl.Cell.calculateQ([0, 0, 2]) | |
# or, generate the entire reciprocal lattice | |
all_hkl = xtl.Scatter.get_hkl(energy_kev=8) # there are lots of other arguments for this! |
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
# module load python/3 | |
# or pip install babelscan | |
import sys | |
sys.path.insert(0, '/dls_sw/i16/software/python/babelscan') | |
from babelscan import file_loader, FolderMonitor | |
# Load scan object | |
scan = file_loader('/dls/i16/data/2021/mm29566-1/12345.nxs') | |
print(scan) |
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
# module load python/3 | |
# or pip install h5py (h5py is often included in common python distrobutions) | |
import h5py | |
with h5py.File('example_nexus/794932.nxs', 'r') as nx: | |
print(nx['entry1']['measurement'].keys()) | |
dataset = nx['entry1/measurement/eta'] |
NewerOlder