diff --git a/src/etc/data/comp/optics/FELH0400_Transmission.csv b/src/etc/data/comp/optics/FELH0400_Transmission.csv index 1ce2e22..ed4412e 100644 --- a/src/etc/data/comp/optics/FELH0400_Transmission.csv +++ b/src/etc/data/comp/optics/FELH0400_Transmission.csv @@ -1,5 +1,5 @@ -# ThorLabs 400nm longpass cutoff filter -#Wavelength [nm], Transmission[%] +# ThorLabs 400nm longpass cutoff filter +Wavelength [nm], Transmission[%] 200,0.000301121 201,0.000290997 202,0.000323028 @@ -2001,792 +2001,3 @@ 2198,86.537942 2199,86.260615 2200,85.980188 -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, diff --git a/src/etc/data/comp/optics/GG495.csv b/src/etc/data/comp/optics/GG495.csv index d20ad57..f56aec2 100644 --- a/src/etc/data/comp/optics/GG495.csv +++ b/src/etc/data/comp/optics/GG495.csv @@ -1,7 +1,7 @@ # 495 nm Longpass Colored Glass Filter (GG495) # Data from Item # FGL495, FGL495S & FGL495M at ThorLabs # Measurements Made at Normal Incidence -# Wavelength (nm),% Transmission +Wavelength [nm],Transmission [%] 200,0.004609 205,0.004537 210,0.002461 diff --git a/src/etc/data/comp/optics/ZnSe_transmission.csv b/src/etc/data/comp/optics/ZnSe_transmission.csv new file mode 100644 index 0000000..bfb6183 --- /dev/null +++ b/src/etc/data/comp/optics/ZnSe_transmission.csv @@ -0,0 +1,36 @@ +# mks Newport Zinc Selenide transmission +Wavelength [um],Transmission [%] +0.6,0.0 +0.6081687269541172,19.961876223817697 +0.6095113398357764,39.96180205304694 +0.6135569886416508,56.40894796178721 +0.6412228975909252,59.96009612531893 +0.6730983854737077,62.45846436836171 +0.7034490765931198,64.16750726873553 +0.7548823095958328,65.74408117249155 +0.8029620298356647,66.92621491722542 +0.8578792858399883,67.84504242568089 +0.9085033459734396,68.36942977511421 +1.0188898367380812,69.4182044739809 +1.310103738650206,69.93606479558534 +1.6624090987919442,70.19121224707766 +1.9744173372848584,70.71174271643031 +2.494340656883339,71.88809114104313 +2.859785911130845,72.14665044799145 +3.9985708589639644,72.53011333293776 +5.051514527652158,72.39067228386637 +9.081787511201638,72.37094285883818 +10.051382519486713,72.10437310864533 +10.551041410192004,71.31326766747759 +10.833974188481402,70.12816709191242 +11.124493986280852,64.99569809529459 +11.173665785947971,62.89028659585829 +11.42280425426651,61.31059751972941 +11.729113898771699,60.12549694416423 +11.885335298152315,57.361894024802695 +11.990637155995715,49.861597341719566 +12.150341813324605,39.9927312644633 +12.312173595112412,29.729128345101756 +12.586697294847184,19.5968076900255 +12.810716893122944,9.727793271227668 +13,0.0 diff --git a/src/etc/utils.py b/src/etc/utils.py index 5839566..46302e4 100644 --- a/src/etc/utils.py +++ b/src/etc/utils.py @@ -68,8 +68,11 @@ def read_element( source = "LCO iLab format" header, wavelengths, throughput = read_lco_filter_csv(file_path) else: + final_wave_units = "nm" + if wave_units != u.nm: + final_wave_units = wave_units header, wavelengths, throughput = specio.read_ascii_spec( - file_path, wave_unit="nm", flux_unit="%", format="csv", comment="#" + file_path, wave_unit=final_wave_units, flux_unit="%", format="csv", comment="#" ) source = "CSV file" elif "http://svo" in filename.lower(): diff --git a/tests/etc/data/test_optic_microns.csv b/tests/etc/data/test_optic_microns.csv new file mode 100644 index 0000000..bf2dd27 --- /dev/null +++ b/tests/etc/data/test_optic_microns.csv @@ -0,0 +1,6 @@ +# mks Newport Zinc Selenide transmission +Wavelength [um],Transmission [%] +0.6,0.0 +0.608,20.0 +0.610,40.0 +13.0,0.0 diff --git a/tests/etc/data/test_optic_nm.csv b/tests/etc/data/test_optic_nm.csv new file mode 100644 index 0000000..76a40d2 --- /dev/null +++ b/tests/etc/data/test_optic_nm.csv @@ -0,0 +1,5 @@ +# ThorLabs 400nm longpass cutoff filter +Wavelength [nm], Transmission[%] +200,0.000301121 +201,0.000290997 +2200,85.98 diff --git a/tests/etc/test_utils.py b/tests/etc/test_utils.py index 104fcc4..bc00876 100644 --- a/tests/etc/test_utils.py +++ b/tests/etc/test_utils.py @@ -66,6 +66,50 @@ def test_read_element_angstroms(self): assert_quantity_allclose(element.waveset[0], 3200 * u.AA) assert_quantity_allclose(element(element.waveset[0]), 0.306, rtol=1e-3) + def test_read_optic(self): + test_fp = files("tests.etc.data").joinpath("test_optic_nm.csv").as_posix() + + element = read_element(test_fp) + + assert_quantity_allclose(element.waveset[0], 200 * u.nm) + assert_quantity_allclose(element(element.waveset[0]), 0.000301121 * u.percent) + assert_quantity_allclose(element.waveset[-1], 2200 * u.nm) + assert_quantity_allclose(element(element.waveset[-1]), 85.98 * u.percent) + + def test_read_optic_passed_waveunit(self): + test_fp = files("tests.etc.data").joinpath("test_optic_nm.csv").as_posix() + + element = read_element(test_fp, wave_units=u.nm) + + assert_quantity_allclose(element.waveset[0], 200 * u.nm) + assert_quantity_allclose(element(element.waveset[0]), 0.000301121 * u.percent) + assert_quantity_allclose(element.waveset[-1], 2200 * u.nm) + assert_quantity_allclose(element(element.waveset[-1]), 85.98 * u.percent) + + def test_read_optic_microns(self): + test_fp = files("tests.etc.data").joinpath("test_optic_microns.csv").as_posix() + + element = read_element(test_fp) + + assert_quantity_allclose(element.waveset[0], 6 * u.AA) + assert_quantity_allclose(element(element.waveset[0]), 0.0) + assert_quantity_allclose(element.waveset[1], 6.08 * u.AA) + assert_quantity_allclose(element(element.waveset[1]), 20 * u.percent) + assert_quantity_allclose(element.waveset[-1], 130 * u.AA) + assert_quantity_allclose(element(element.waveset[0]), 0.0) + + def test_read_optic_microns_passed_waveunit(self): + test_fp = files("tests.etc.data").joinpath("test_optic_microns.csv").as_posix() + + element = read_element(test_fp, wave_units=u.micron) + + assert_quantity_allclose(element.waveset[0], 0.6 * u.micron) + assert_quantity_allclose(element(element.waveset[0]), 0.0) + assert_quantity_allclose(element.waveset[1], 0.608 * u.micron) + assert_quantity_allclose(element(element.waveset[1]), 20 * u.percent) + assert_quantity_allclose(element.waveset[-1], 13 * u.micron) + assert_quantity_allclose(element(element.waveset[0]), 0.0) + def test_read_element_as_sourcespectrum(self): test_fp = files("tests.etc.data").joinpath("test_radiance.dat").as_posix()