Created
August 14, 2023 13:07
-
-
Save DanPorter/e9893bee55c691290aa5d370894e9fb8 to your computer and use it in GitHub Desktop.
Read I16 Dat Files in Python using Py16
This file contains 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 copy "py16progs.py" from https://github.com/DanPorter/Py16 | |
import sys,os | |
import numpy as np | |
import matplotlib.pyplot as plt # Plotting | |
from mpl_toolkits.mplot3d import Axes3D # 3D plotting | |
# Load Py16progs | |
sys.path.insert(0,'/dls_sw/i16/software/python/Py16/Py16progs.py') # location of Py16progs | |
import Py16progs as dp | |
"-----Set Directories and parameters----" | |
# Current Directory of this file - if you need it | |
cf=os.path.dirname(__file__) | |
# Directory to load data from ***CHANGE THIS*** | |
dp.filedir = '/dls/i16/data/2015/cm12169-2' | |
# Directory to save files to ***CHANGE THIS*** | |
dp.savedir='/home/i16user/Desktop' | |
# Update default save location for exported plots | |
plt.rcParams["savefig.directory"] = dp.savedir | |
# Experiment Parameters (feel free to ignore or remove unless you want to change them) | |
dp.exp_ring_current = 300.0 # Average ring current for normalisation | |
dp.exp_monitor = 800.0 # Average monitor current for normalisation | |
dp.normby = 'rc' # ring current ('rc'), monitor ('ic1') or none ('none') | |
dp.pil_centre = [110, 242] # Find the current value in /dls_sw/i16/software/gda/config/scripts/localStation.py (search for "ci=") | |
dp.peakregion=[7,153,186,332] # 'nroi_peak' will search for peaks within this area of the detector [min_y,min_x,max_y,max_x] | |
dp.exp_title = '' # exp_title will appear in plot titles | |
"---------------------------------------" | |
"------------Analysis Stuff-------------" | |
"---------------------------------------" | |
### Single Scan ### | |
d = dp.readscan(123456) | |
eta_array = d.eta | |
initial_eta_value = d.metadata.eta | |
scan_command = d.metadata.cmd | |
x,y,dy,varx,vary,ttl,d = dp.getdata(scn,vary='roi1_sum') | |
plt.figure() | |
plt.plot(x, y) | |
dp.labels(ttl, varx, vary) | |
### Multiple Scans ### | |
scans = range(512404,512664,5) + [512665,512666] | |
# Multi-scan plots | |
help(dp.plotscan) # See the function documentation! | |
dp.plotscan(scans) | |
dp.plotscans3D(scans) | |
dp.plotscansSURF(scans) | |
# Automatic Peak Fitting & Integration | |
fit,err = dp.fit_scans(scans,vary='roi1_sum',depvar='Ta',peaktest=1,fit_type='pVoight',plot=['all','int'],saveFIT=None,savePLOT=None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment