{"id":1908,"date":"2018-08-09T07:51:25","date_gmt":"2018-08-09T15:51:25","guid":{"rendered":"http:\/\/antoine.wojdyla.fr\/blog\/?p=1908"},"modified":"2018-08-22T12:38:18","modified_gmt":"2018-08-22T20:38:18","slug":"how-to-retrieve-and-handle-x-ray-data","status":"publish","type":"post","link":"http:\/\/antoine.wojdyla.fr\/blog\/2018\/08\/09\/how-to-retrieve-and-handle-x-ray-data\/","title":{"rendered":"How to retrieve and handle x-ray data"},"content":{"rendered":"<p>A bit wonky, but here&#8217;s where you can get x-ray data, how to use it in python, and some common conversion.<\/p>Here are two important database to know:<\/p><a href=\"http:\/\/henke.lbl.gov\/optical_constants\/\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'http:\/\/henke.lbl.gov\/optical_constants\/', 'CXRO database']);\" >CXRO database<\/a><\/p><a href=\"https:\/\/physics.nist.gov\/PhysRefData\/XrayTrans\/Html\/search.html\" onclick=\"_gaq.push(['_trackEvent', 'outbound-article', 'https:\/\/physics.nist.gov\/PhysRefData\/XrayTrans\/Html\/search.html', 'NIST database']);\" >NIST database<\/a><\/p><!--more--><\/p>And here&#8217;s how to get all the K-edge for heavy elements: https:\/\/physics.nist.gov\/cgi-bin\/XrayTrans\/search.pl?download=column&element=All&trans=Kedge&lower=100&upper=10000&units=eV<\/p>(feel free to edit the URL to get different energy ranges)<\/p>To import fundamental constants in python, you can user scipy.constants<\/p><code>import scipy.constants as constant<br \/>\neV = constant.eV<br \/>\nh = constant.h<br \/>\nc = constant.c<br \/>\nhBar = constant.hbar<br \/>\nme = constant m_e #mass of an electron<br \/>\nNA = constant.N_A<\/code><\/p>(and here are many other constants: https:\/\/docs.scipy.org\/doc\/scipy\/reference\/constants.html)<\/p>Besides, instead of using CXRO website, you can use <strong>xrt<\/strong> (developed by K Klementiev at Max IV) to pull out some data.<\/p>For example, if you need to get the absorption coefficient for gold (&#8216;Au&#8217;) between 10eV and 20keV, you can do this:<br \/>\n<code><br \/>\npip install xrt<br \/>\npip install<br \/>\n<\/code><br \/>\nThen here&#8217;s how to retrieve the absorbtion coefficient for gold:<br \/>\n<code><br \/>\nimport xrt.backends.raycing.materials as rm<br \/>\nimport matplotlib.pyplot as plt<br \/>\nimport numpy as np<br \/>\nimport periodictable<br \/>\n#<br \/>\n# see https:\/\/xrt.readthedocs.io\/raycing.html#module-xrt.backends.raycing.materials<br \/>\nmat = rm.Material(<strong>'Au'<\/strong>,table='Henke',rho=<strong>periodictable.Au.density<\/strong>)<br \/>\n#<br \/>\nE = np.logspace(1, 4 + np.log10(2), 501) #1e1 to 2e4<br \/>\nmu = mat.get_absorption_coefficient(E)<br \/>\n#<br \/>\nplt.loglog(E, mu)<br \/>\nplt.xlabel('Energy [EV]')<br \/>\nplt.xlabel('linear absorption coefficient [cm-1]')<br \/>\nplt.gca().set_xlim(E[0], E[-1])<br \/>\nplt.show()<br \/>\n<\/code><br \/>\nHere are some conversions useful for back of the envelope calculations:<\/p>\n<p style=\"padding-left: 30px;\">angle[deg] = 180\/pi angle[rad] ~ 57*angle[rad]<br \/>\nE[eV] = hc\/e * 1\/ \u03bb[m] ~ 1239\/\u03bb[nm]<br \/>\nFWHM = 2.35 * stdev<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A bit wonky, but here&#8217;s where you can get x-ray data, how to use it in python, and some common conversion.Here are two important database to know:CXRO databaseNIST database<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,16,5],"tags":[],"class_list":["post-1908","post","type-post","status-publish","format-standard","hentry","category-english","category-resources","category-science-life"],"_links":{"self":[{"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/posts\/1908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/comments?post=1908"}],"version-history":[{"count":7,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/posts\/1908\/revisions"}],"predecessor-version":[{"id":1945,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/posts\/1908\/revisions\/1945"}],"wp:attachment":[{"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/media?parent=1908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/categories?post=1908"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/antoine.wojdyla.fr\/blog\/wp-json\/wp\/v2\/tags?post=1908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}