def test_convert_freq_eV_nparray(self): eV_calc = sm.convert_photon_unit( "freq", "eV", np.array([100.0, 2000.0]) * sm.Units.THz) eV_predict = np.array([0.4135659, 8.271318]) ratio = eV_calc / eV_predict npt.assert_array_almost_equal(ratio, np.array([1.0, 1.0]), decimal=5)
def test_create_nk_from_csv_expected_nk_eV_upperbound(self): dir_path = os.path.dirname(os.path.realpath(__file__)) filename_full = os.path.join(dir_path,"TestCSVFile_comma_eV.csv") index_function = sm.create_nk_from_csv(filename_full, independent_unit_str="eV", lines_to_skip = 1) ratio =index_function(sm.convert_photon_unit("eV","wl",6.0))/(2.0+0.0j) self.assertAlmostEqual(ratio,1.0,places=5)
def test_load_eV_nk_file_nolineskip(self): dir_path = os.path.dirname(os.path.realpath(__file__)) filename_full_n = os.path.join(dir_path,"TestCSV2Files_n.csv") filename_full_k = os.path.join(dir_path,"TestCSV2Files_k.csv") index_fcn = sm.generate_index_from_2csv(filename_full_n, filename_full_k, photon_var="eV", index_var="nk", delimiter = ",", skip_first_line = False) ratio = (index_fcn(sm.convert_photon_unit("eV","wl",1.5))/ (1.9917355371900825-0.7960199004975141j)) self.assertAlmostEqual(ratio,1.0,places=5)
def test_SOPRA_eV_nk_file(self): dir_path = os.path.dirname(os.path.realpath(__file__)) filename_full = os.path.join(dir_path,"Test_SOPRA_Al2O3.nk") index_fcn = sm.generate_index_from_SOPRA_nk(filename_full) ratio = index_fcn(sm.convert_photon_unit("eV","wl",1.525))/(1.68233414703812-0.0420244851757776j) self.assertAlmostEqual(ratio,1.0,places=5)
def test_convert_eV_wl_1eV_is_1dot24um(self): wavelength_calc = sm.convert_photon_unit("eV", "wl", 1.0) wavelength_predict = 1.23984 * sm.Units.um ratio = wavelength_calc / wavelength_predict self.assertAlmostEqual(ratio, 1.0, places=5)
def test_convert_freq_eV_is_reversable(self): freq_start = 500.0 * sm.Units.THz eV_first = sm.convert_photon_unit("freq", "eV", freq_start) freq_next = sm.convert_photon_unit("eV", "freq", eV_first) ratio = freq_next / freq_start self.assertAlmostEqual(ratio, 1.0, places=5)
def test_convert_freq_eV_100THz_is_0dot413(self): eV_calc = sm.convert_photon_unit("freq", "eV", 100.0 * sm.Units.THz) eV_predict = 0.4135659 ratio = eV_calc / eV_predict self.assertAlmostEqual(ratio, 1.0, places=5)
def test_convert_wl_freq_is_reversable(self): wavelength_start = 1.5 * sm.Units.um freq_first = sm.convert_photon_unit("wl", "freq", wavelength_start) wavelength_next = sm.convert_photon_unit("freq", "wl", freq_first) ratio = wavelength_next / wavelength_start self.assertAlmostEqual(ratio, 1.0, places=5)
def test_convert_wl_freq_nparray(self): freq_calc = sm.convert_photon_unit("wl", "freq", np.array([1.0, 0.5]) * sm.Units.um) freq_predict = np.array([299.793, 599.586]) * sm.Units.THz ratio = freq_calc / freq_predict npt.assert_array_almost_equal(ratio, np.array([1.0, 1.0]), decimal=5)
def test_convert_wl_freq_1um_is_300THz(self): freq_calc = sm.convert_photon_unit("wl", "freq", 1.0 * sm.Units.um) freq_predict = 299.793 * sm.Units.THz ratio = freq_calc / freq_predict self.assertAlmostEqual(ratio, 1.0, places=5)
def test_convert_eV_wl_is_reversable(self): eV_start = 1.5 wavelength_first = sm.convert_photon_unit("eV", "wl", eV_start) eV_next = sm.convert_photon_unit("wl", "eV", wavelength_first) ratio = eV_next / eV_start self.assertAlmostEqual(ratio, 1.0, places=5)
def test_convert_eV_wl_nparray(self): wavelength_calc = sm.convert_photon_unit("eV", "wl", np.array([1.0, 1.5])) wavelength_predict = np.array([1.23984, 0.82656108]) * sm.Units.um ratio = wavelength_calc / wavelength_predict npt.assert_array_almost_equal(ratio, np.array([1.0, 1.0]), decimal=5)