def getTforE(self,angle=None,energy=None): if (energy is None): energy=self.linac.getXrayeV() if (angle is None): if (self.angle is None): self.angle=self.get_angle() angle=self.angle r = xsf.mirror_reflectivity("Si",angle=angle,energy=energy/1e3) # r**2 because 2 mirrors return float(r*r) return r*r
def test_refl(): # Note: io always works on unicode (python 2.x and 3.x), so tag the input # as unicode. The alternative is to import StringIO from six, but only # if six is already required for some other reason. from io import StringIO # http://henke.lbl.gov/optical_constants/mirror2.html data2 = StringIO(u"""\ #SiO2 Rho=2.2, Sig=3.nm, P=1., 2.deg # Photon Energy (eV), Reflectivity 30.0000 0.900114 42.6000 0.894588 60.4919 0.888959 85.8984 0.867922 121.976 0.724582 173.205 0.742043 245.951 0.752193 349.250 0.752260 495.934 0.717134 704.226 0.392855 1000.00 5.563799E-02""") data3 = StringIO(u"""\ #SiO2 Rho=2.2, Sig=3.nm, P=1., 3.deg # Photon Energy (eV), Reflectivity 30.0000 0.853800 42.6000 0.845758 60.4919 0.837342 85.8984 0.806430 121.976 0.611468 173.205 0.630653 245.951 0.633574 349.250 0.604126 495.934 0.317861 704.226 2.655170E-02 1000.00 1.240138E-03""") e, R2 = numpy.loadtxt(data2).T e, R3 = numpy.loadtxt(data3).T R = mirror_reflectivity(energy=e * 1e-3, angle=[2, 3], compound='SiO2', density=2.2, roughness=30) assert numpy.max(abs((R - numpy.vstack([R2, R3])) / R)) < 1e-4
def test_refl(): # Note: io always works on unicode (python 2.x and 3.x), so tag the input # as unicode. The alternative is to import StringIO from six, but only # if six is already required for some other reason. from io import StringIO # http://henke.lbl.gov/optical_constants/mirror2.html data2=StringIO(u"""\ #SiO2 Rho=2.2, Sig=3.nm, P=1., 2.deg # Photon Energy (eV), Reflectivity 30.0000 0.900114 42.6000 0.894588 60.4919 0.888959 85.8984 0.867922 121.976 0.724582 173.205 0.742043 245.951 0.752193 349.250 0.752260 495.934 0.717134 704.226 0.392855 1000.00 5.563799E-02""") data3=StringIO(u"""\ #SiO2 Rho=2.2, Sig=3.nm, P=1., 3.deg # Photon Energy (eV), Reflectivity 30.0000 0.853800 42.6000 0.845758 60.4919 0.837342 85.8984 0.806430 121.976 0.611468 173.205 0.630653 245.951 0.633574 349.250 0.604126 495.934 0.317861 704.226 2.655170E-02 1000.00 1.240138E-03""") e,R2 = numpy.loadtxt(data2).T e,R3 = numpy.loadtxt(data3).T R = mirror_reflectivity(energy=e*1e-3,angle=[2,3],compound='SiO2',density=2.2, roughness=30) assert numpy.max(abs((R-numpy.vstack([R2,R3]))/R)) < 1e-4
def test_refl(): from StringIO import StringIO # http://henke.lbl.gov/optical_constants/mirror2.html data2=StringIO("""\ #SiO2 Rho=2.2, Sig=3.nm, P=1., 2.deg # Photon Energy (eV), Reflectivity 30.0000 0.900114 42.6000 0.894588 60.4919 0.888959 85.8984 0.867922 121.976 0.724582 173.205 0.742043 245.951 0.752193 349.250 0.752260 495.934 0.717134 704.226 0.392855 1000.00 5.563799E-02""") data3=StringIO("""\ #SiO2 Rho=2.2, Sig=3.nm, P=1., 3.deg # Photon Energy (eV), Reflectivity 30.0000 0.853800 42.6000 0.845758 60.4919 0.837342 85.8984 0.806430 121.976 0.611468 173.205 0.630653 245.951 0.633574 349.250 0.604126 495.934 0.317861 704.226 2.655170E-02 1000.00 1.240138E-03""") e,R2 = numpy.loadtxt(data2).T e,R3 = numpy.loadtxt(data3).T R = mirror_reflectivity(energy=e*1e-3,angle=[2,3],compound='SiO2',density=2.2, roughness=30) assert numpy.max(abs((R-numpy.vstack([R2,R3]))/R)) < 1e-4
def getReflectivityList(self, incidentAngle, evList): self.incidentAngle = incidentAngle self.keVList = evList / 1000. self.reflectivity = xsf.mirror_reflectivity(compound = self.material, density = self.density ,\ energy = self.keVList, roughness = self.roughness, angle = self.incidentAngle) return self.reflectivity[0]
def getOneReflectivity(self, incidentAngle, eV): self.incidentAngle = [incidentAngle] self.keV = [eV] / 1000. self.oneReflectivity = xsf.mirror_reflectivity(compound = self.material, density = self.density ,\ energy = self.keV, roughness = self.roughness, angle = self.incidentAngle) return reflectivity[0][0]