Go to file
Marco Cammarata 527f88b50c improved calculations (calcSpectraForRefAndSample) and plotting (showSpectra and showAbs) 2016-12-01 11:16:46 +01:00
.ipynb_checkpoints first git.ipr commit 2016-05-12 15:02:42 +02:00
mcutils trying to get the gauss convolution to work again... 2016-12-01 11:15:17 +01:00
mecl3616_init_pars first git.ipr commit 2016-05-12 15:02:42 +02:00
mecl3616_init_pars_bak first git.ipr commit 2016-05-12 15:02:42 +02:00
mecl3616_init_pars_old first git.ipr commit 2016-05-12 15:02:42 +02:00
online first git.ipr commit 2016-05-12 15:02:42 +02:00
xppl3716_init_pars first git.ipr commit 2016-05-12 15:02:42 +02:00
xppl3716_init_pars_old first git.ipr commit 2016-05-12 15:02:42 +02:00
.gitignore first git.ipr commit 2016-05-12 15:02:42 +02:00
HOW-TO.html first git.ipr commit 2016-05-12 15:02:42 +02:00
HOW-TO.ipynb first git.ipr commit 2016-05-12 15:02:42 +02:00
NOTES.txt first git.ipr commit 2016-05-12 15:02:42 +02:00
README.md update instructions 2016-11-22 13:06:51 +01:00
alignment.py various improvements (i.e. i forgot ...) 2016-12-01 11:14:42 +01:00
make_little_data.py first git.ipr commit 2016-05-12 15:02:42 +02:00
x3py_config various changes 2016-11-23 17:16:39 +01:00
xanes_analyzeRun.py various improvements (i.e. i forgot ...) 2016-12-01 11:14:42 +01:00
xppl37_calibration.py new quick-and-dirty script for calculating energy calibration 2016-11-30 17:48:05 +01:00
xppl37_spectra.py improved calculations (calcSpectraForRefAndSample) and plotting (showSpectra and showAbs) 2016-12-01 11:16:46 +01:00
xppl37_theta_scan.py main functions for producing plots 2016-11-25 11:05:19 +01:00

README.md

dispersiveXanes

# INSTALL THE STUFF
# 1. go to psexport (and not pslogin or psana)
# 2. Go in a folder where you will install the things (cd ~/my_folder)
# 3. git clone https://github.com/marcocamma/x3py.git
# 4. git clone https://git.ipr.univ-rennes1.fr/mcammara/dispersiveXanes.git
# 5. if you want to update go to the right folder (for example cd ~/my_folder/dispersiveXanes) and type git pull.

# BEFORE GETTING STARTED
# 1. if at LCLS load the anaconda session
# source ~marcoc/setups/ana-marco3k-setup.sh
# 2. go in the right folder (cd ~/my_folder/dispersiveXanes)
# → THIS IS IMPORTANT: change the experiment name in xanes_analyzeRun (line ~22)

# GET STARTED
# 1. start ipython (ipython3)
# 2. tell python to use look for modules in the folder
# 3. import sys; sys.path.insert(0,"~/my_folder")

# there are two files:
# 1. alignment.py        (deals with images)
# 2. xanes_analyzeRun.py (deals with run and images reading)

%matplotlib nbagg
import matplotlib
import matplotlib.pylab as plt
matplotlib.style.use("ggplot")
import pprint
import numpy as np
np.warnings.simplefilter('ignore')

import xanes_analyzeRun
import alignment

#Doing first alignment on "hole"

# define starting parameters for analysis; passed directly to iminuit so things like
# limits, or fix_scalex=True, etc. can be used
pars = dict( scalex = 0.6, intensity = 0.1, iblur1=2,fix_iblur1 = False )
# default parameters can be found in alignment.g_fit_default_kw
# you can have a look by uncommenting the following line:
# pprint.pprint(alignment.g_fit_default_kw)

# define the run object
#### NOTE : for mec run swapx=True,swapy=False
r = xanes_analyzeRun.AnalyzeRun(190,initAlign=pars,swapx=True,swapy=False)

# data are d.spec1 and d.spec2 (spec1 is the one **upbeam**)
# align one shot

# show = True: show only output; showInit=True: show also starting parameters
r0fit=r.doShot(shot=0,calib=0,showInit=True,doFit=True)

# save as default transformation for run (used when reloading without initAlign keywork)
r.saveTransform();

# do more shots without fitting (using last r.initAlign)
# the return value is a list with lots of stuff for each shot
res = r.doShots(slice(100),doFit=False)
print(list(res.keys()))

print(list(res["parameters"].keys()))

alignment.plotRatios(res["ratio"])
ref = np.nanmedian(res["ratio"],axis=0)
trash = plt.xlim(400,600)
trash = plt.ylim(0,2)


# analyze another run using previous alignment

rShot = xanes_analyzeRun.AnalyzeRun(192,initAlign="mecl3616_init_pars/run0190_transform.npy",swapx=True,swapy=False)

out = rShot.doShots(slice(0,5))
ratios = out["ratio"]
plt.figure()
for i,r in enumerate(ratios):
  plt.plot(r/ref,label="Shot %d"%i)
trash = plt.ylim(0,1)
trash = plt.legend(loc=2)

# save results in hdf file for Andy's happiness
rShot.save(overwrite=True)