def figures(): '''Draw some thin film plots.''' # simple patch plot thickness_nm_list = xrange(0, 1000, 10) illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 9.50) thinfilm_patch_plot(1.500, 1.003, 1.500, thickness_nm_list, illuminant, 'ThinFilm Patch Plot', 'ThinFilm-Patch') # plot the colors of films vs thickness. # we scale the illuminant to get a better range of color. #thickness_nm_list = xrange (0, 1000, 2) # faster thickness_nm_list = xrange(0, 1000, 1) # nicer # gap in glass/plastic illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 4.50) thinfilm_color_vs_thickness_plot( 1.500, 1.003, 1.500, thickness_nm_list, illuminant, 'Thin Film - Gap In Glass/Plastic (n = 1.50)\nIlluminant D65', 'ThinFilm-GlassGap') # soap bubble illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 9.50) thinfilm_color_vs_thickness_plot( 1.003, 1.33, 1.003, thickness_nm_list, illuminant, 'Thin Film - Soap Bubble (n = 1.33)\nIlluminant D65', 'ThinFilm-SoapBubble') # oil slick on water illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 15.00) thinfilm_color_vs_thickness_plot( 1.003, 1.44, 1.33, thickness_nm_list, illuminant, 'Thin Film - Oil Slick (n = 1.44) on Water (n = 1.33)\nIlluminant D65', 'ThinFilm-OilSlick') # large index of refraction bubble illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 3.33) thinfilm_color_vs_thickness_plot( 1.003, 1.60, 1.003, thickness_nm_list, illuminant, 'Thin Film - Large Index (n = 1.60) Bubble\nIlluminant D65', 'ThinFilm-LargeBubble') # plot the spectrum of the refection for a couple of thicknesses - using constant illuminant for cleaner plot illuminant = illuminants.get_constant_illuminant() illuminants.scale_illuminant(illuminant, 9.50) thinfilm_spectrum_plot( 1.003, 1.33, 1.003, 400.0, illuminant, 'Thin Film Interference Spectrum - 400 nm thick\nConstant Illuminant', 'ThinFilm-Spectrum-400nm') thinfilm_spectrum_plot( 1.003, 1.33, 1.003, 500.0, illuminant, 'Thin Film Interference Spectrum - 500 nm thick\nConstant Illuminant', 'ThinFilm-Spectrum-500nm')
def figures(): '''Draw some plots of Rayleigh scattering.''' # patch plots for some illuminants rayleigh_patch_plot([(illuminants.get_blackbody_illuminant( blackbody.SUN_TEMPERATURE), 'Sun')], 'Rayleigh Scattering by the Sun', 'Rayleigh-PatchSun') rayleigh_patch_plot( [(illuminants.get_illuminant_D65(), 'D65'), (illuminants.get_blackbody_illuminant(2000.0), '2000 K'), (illuminants.get_blackbody_illuminant(3500.0), '3500 K'), (illuminants.get_blackbody_illuminant( blackbody.SUN_TEMPERATURE), 'Sun'), (illuminants.get_blackbody_illuminant(6500.0), '6500 K'), (illuminants.get_blackbody_illuminant(15000.0), '15000 K')], 'Rayleigh Scattering by Various Illuminants', 'Rayleigh-PatchVarious') # color vs illuminant temperature T_list = range(1200, 16000, 50) # must be integers for range() rayleigh_color_vs_illuminant_temperature_plot( T_list, 'Rayleigh Scattering Sky Colors', 'Rayleigh-SkyColors') # spectra for several illuminants T_list = [ 2000.0, 3000.0, blackbody.SUN_TEMPERATURE, 6500.0, 11000.0, 15000.0 ] for T in T_list: rayleigh_spectrum_plot(illuminants.get_blackbody_illuminant(T), 'Rayleigh Scattering\nIlluminant %g K' % (T), 'Rayleigh-Spectrum-%gK' % (T))
def figures (): '''Draw some plots of Rayleigh scattering.''' # patch plots for some illuminants rayleigh_patch_plot ( [(illuminants.get_blackbody_illuminant (blackbody.SUN_TEMPERATURE), 'Sun')], 'Rayleigh Scattering by the Sun', 'Rayleigh-PatchSun') rayleigh_patch_plot ( [(illuminants.get_illuminant_D65 (), 'D65'), (illuminants.get_blackbody_illuminant (2000.0), '2000 K'), (illuminants.get_blackbody_illuminant (3500.0), '3500 K'), (illuminants.get_blackbody_illuminant (blackbody.SUN_TEMPERATURE), 'Sun'), (illuminants.get_blackbody_illuminant (6500.0), '6500 K'), (illuminants.get_blackbody_illuminant (15000.0), '15000 K')], 'Rayleigh Scattering by Various Illuminants', 'Rayleigh-PatchVarious') # color vs illuminant temperature T_list = range (1200, 16000, 50) # must be integers for range() rayleigh_color_vs_illuminant_temperature_plot (T_list, 'Rayleigh Scattering Sky Colors', 'Rayleigh-SkyColors') # spectra for several illuminants T_list = [2000.0, 3000.0, blackbody.SUN_TEMPERATURE, 6500.0, 11000.0, 15000.0] for T in T_list: rayleigh_spectrum_plot ( illuminants.get_blackbody_illuminant (T), 'Rayleigh Scattering\nIlluminant %g K' % (T), 'Rayleigh-Spectrum-%gK' % (T))
def figures (): '''Draw some plots of Rayleigh scattering.''' # Patch plots for some illuminants. rayleigh_patch_plot ( [(illuminants.get_blackbody_illuminant (blackbody.SUN_TEMPERATURE), 'Sun')], 'Rayleigh Scattering by the Sun', 'Rayleigh-PatchSun') rayleigh_patch_plot ( [(illuminants.get_illuminant_D65 (), 'D65'), (illuminants.get_blackbody_illuminant (2000.0), '2000 K'), (illuminants.get_blackbody_illuminant (3500.0), '3500 K'), (illuminants.get_blackbody_illuminant (blackbody.SUN_TEMPERATURE), 'Sun'), (illuminants.get_blackbody_illuminant (6500.0), '6500 K'), (illuminants.get_blackbody_illuminant (15000.0), '15000 K')], 'Rayleigh Scattering by Various Illuminants', 'Rayleigh-PatchVarious') # Scattered color vs blackbody illuminant temperature. T_list = numpy.linspace(1200.0, 16000.0, 300) rayleigh_color_vs_illuminant_temperature_plot ( T_list, 'Rayleigh Scattering Sky Colors', 'Rayleigh-SkyColors') # Spectra for several illuminants. T_list = [2000.0, 3000.0, blackbody.SUN_TEMPERATURE, 6500.0, 11000.0, 15000.0] for T in T_list: T_label = '%dK' % (round(T)) rayleigh_spectrum_plot ( illuminants.get_blackbody_illuminant (T), 'Rayleigh Scattering\nIlluminant %g K' % (T), 'Rayleigh-Spectrum-%s' % (T_label))
def test (): '''Mainly call some functions.''' for i in xrange (0, 100): wl_nm = 1000.0 * random.random() rayleigh.rayleigh_scattering (wl_nm) rayleigh.rayleigh_scattering_spectrum() illum = illuminants.get_illuminant_D65() rayleigh.rayleigh_illuminated_spectrum (illum) rayleigh.rayleigh_illuminated_color (illum) print 'test_rayleigh.test() passed.' # didnt exception
def test (): '''Mainly call some functions.''' for i in range(0, 100): wl_nm = 1000.0 * random.random() rayleigh.rayleigh_scattering (wl_nm) rayleigh.rayleigh_scattering_spectrum() illum = illuminants.get_illuminant_D65() rayleigh.rayleigh_illuminated_spectrum (illum) rayleigh.rayleigh_illuminated_color (illum) print('test_rayleigh.test() passed.') # didnt exception
def test_coverage_1(self, verbose=False): ''' A coverage test of illuminants. ''' D65 = illuminants.get_illuminant_D65() if verbose: print ('Illuminant D65') print (str (D65)) A = illuminants.get_illuminant_A() if verbose: print ('Illuminant A') print (str (A)) const = illuminants.get_constant_illuminant() if verbose: print ('Constant Illuminant') print (str (const))
def test_coverage(self): ''' A coverage test of thin film scattering. ''' illuminant = illuminants.get_illuminant_D65() for j in range(20): n1 = 5.0 * random.random() n2 = 5.0 * random.random() n3 = 5.0 * random.random() thickness_nm = 10000.0 * random.random() film = thinfilm.thin_film(n1, n2, n3, thickness_nm) for k in range(20): wl_nm = 1000.0 * random.random() film.get_interference_reflection_coefficient(wl_nm) film.reflection_spectrum() film.illuminated_spectrum(illuminant) film.illuminated_color(illuminant)
def test_scattering(self, verbose=False): ''' Test of scattering calculations. ''' # Coverage test of rayleigh_scattering_spectrum(). rayleigh.rayleigh_scattering_spectrum() illum = illuminants.get_illuminant_D65() spect = rayleigh.rayleigh_illuminated_spectrum(illum) # Both color calculations should give the same result. xyz1 = ciexyz.xyz_from_spectrum(spect) xyz2 = rayleigh.rayleigh_illuminated_color(illum) atol = 1.0e-16 ok = numpy.allclose(xyz1, xyz2, atol=atol) self.assertTrue(ok) msg = 'D65 Rayleigh scattered xyz: %s, %s' % (str(xyz1), str(xyz2)) if verbose: print(msg)
def test_scattering(self, verbose=False): ''' Test of scattering calculations. ''' # Coverage test of rayleigh_scattering_spectrum(). rayleigh.rayleigh_scattering_spectrum() illum = illuminants.get_illuminant_D65() spect = rayleigh.rayleigh_illuminated_spectrum (illum) # Both color calculations should give the same result. xyz1 = ciexyz.xyz_from_spectrum (spect) xyz2 = rayleigh.rayleigh_illuminated_color (illum) atol = 1.0e-16 ok = numpy.allclose(xyz1, xyz2, atol=atol) self.assertTrue(ok) msg = 'D65 Rayleigh scattered xyz: %s, %s' % (str(xyz1), str(xyz2)) if verbose: print (msg)
def test_coverage(self): ''' A coverage test of thin film scattering. ''' illuminant = illuminants.get_illuminant_D65() for j in range (20): n1 = 5.0 * random.random() n2 = 5.0 * random.random() n3 = 5.0 * random.random() thickness_nm = 10000.0 * random.random() film = thinfilm.thin_film (n1, n2, n3, thickness_nm) for k in range (20): wl_nm = 1000.0 * random.random() film.get_interference_reflection_coefficient (wl_nm) film.reflection_spectrum () film.illuminated_spectrum (illuminant) film.illuminated_color (illuminant)
def test(): '''Module test. Mainly call some functions.''' illuminant = illuminants.get_illuminant_D65() for j in xrange(0, 100): n1 = 5.0 * random.random() n2 = 5.0 * random.random() n3 = 5.0 * random.random() thickness_nm = 10000.0 * random.random() film = thinfilm.thin_film(n1, n2, n3, thickness_nm) for k in xrange(0, 100): wl_nm = 1000.0 * random.random() film.get_interference_reflection_coefficient(wl_nm) film.reflection_spectrum() film.illuminated_spectrum(illuminant) film.illuminated_color(illuminant) print('test_thinfilm.test() passed.') # no exceptions
def test (): '''Module test. Mainly call some functions.''' illuminant = illuminants.get_illuminant_D65() for j in xrange (0, 100): n1 = 5.0 * random.random() n2 = 5.0 * random.random() n3 = 5.0 * random.random() thickness_nm = 10000.0 * random.random() film = thinfilm.thin_film (n1, n2, n3, thickness_nm) for k in xrange (0, 100): wl_nm = 1000.0 * random.random() film.get_interference_reflection_coefficient (wl_nm) film.reflection_spectrum () film.illuminated_spectrum (illuminant) film.illuminated_color (illuminant) print 'test_thinfilm.test() passed.' # no exceptions
def test (verbose=0): '''Mainly call some functions.''' D65 = illuminants.get_illuminant_D65() if verbose >= 1: print 'Illuminant D65' print str (D65) A = illuminants.get_illuminant_A() if verbose >= 1: print 'Illuminant A' print str (A) const = illuminants.get_constant_illuminant() if verbose >= 1: print 'Constant Illuminant' print str (const) T_list = [0.0, 1.0, 100.0, 1000.0, 5778.0, 10000.0, 100000.0] for T in T_list: bb = illuminants.get_blackbody_illuminant (T) if verbose >= 1: print 'Blackbody Illuminant : %g K' % (T) print str (bb) print 'test_illuminants.test() passed.'
def test(verbose=0): '''Mainly call some functions.''' D65 = illuminants.get_illuminant_D65() if verbose >= 1: print('Illuminant D65') print(str(D65)) A = illuminants.get_illuminant_A() if verbose >= 1: print('Illuminant A') print(str(A)) const = illuminants.get_constant_illuminant() if verbose >= 1: print('Constant Illuminant') print(str(const)) T_list = [0.0, 1.0, 100.0, 1000.0, 5778.0, 10000.0, 100000.0] for T in T_list: bb = illuminants.get_blackbody_illuminant(T) if verbose >= 1: print('Blackbody Illuminant : %g K' % T) print(str(bb)) print('test_illuminants.test() passed.')
def figures(): '''Draw some thin film plots.''' # Simple patch plot. This is not all that interesting. thickness_nm_list = numpy.linspace(0.0, 750.0, 36) illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 9.50) thinfilm_patch_plot(1.500, 1.003, 1.500, thickness_nm_list, illuminant, 'ThinFilm Patch Plot', 'ThinFilm-Patch') # Plot the colors of films vs thickness. # Scale the illuminant to get a better range of color. thickness_nm_list = numpy.linspace(0.0, 1000.0, 800) # Gap in glass/plastic. illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 4.50) thinfilm_color_vs_thickness_plot( 1.500, 1.003, 1.500, thickness_nm_list, illuminant, 'Thin Film - Gap In Glass/Plastic (n = 1.50)\nIlluminant D65', 'ThinFilm-GlassGap') # Soap bubble. illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 9.50) thinfilm_color_vs_thickness_plot( 1.003, 1.33, 1.003, thickness_nm_list, illuminant, 'Thin Film - Soap Bubble (n = 1.33)\nIlluminant D65', 'ThinFilm-SoapBubble') # Oil slick on water. illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 15.00) thinfilm_color_vs_thickness_plot( 1.003, 1.44, 1.33, thickness_nm_list, illuminant, 'Thin Film - Oil Slick (n = 1.44) on Water (n = 1.33)\nIlluminant D65', 'ThinFilm-OilSlick') # Large index of refraction bubble. # This has the brightest colors, but is a bit of an artificial example. illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 3.33) thinfilm_color_vs_thickness_plot( 1.003, 1.60, 1.003, thickness_nm_list, illuminant, 'Thin Film - Large Index (n = 1.60) Bubble\nIlluminant D65', 'ThinFilm-LargeBubble') # A very thick film to test the aliasing limits. # You have to go to very large thicknesses to get much aliasing. thickness_nm_list = numpy.linspace(0.0, 200000.0, 800) illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant(illuminant, 9.50) thinfilm_color_vs_thickness_plot( 1.003, 1.33, 1.003, thickness_nm_list, illuminant, 'Not-so-thin Film - Soap Bubble (n = 1.33)\nIlluminant D65', 'ThinFilm-Thick') # Plot the spectrum of the refection for a couple of thicknesses. # Use a constant illuminant for a cleaner plot. # FIXME: Should this really be using an illuminant? illuminant = illuminants.get_constant_illuminant() illuminants.scale_illuminant(illuminant, 9.50) thinfilm_spectrum_plot( 1.003, 1.33, 1.003, 400.0, illuminant, 'Thin Film Interference Spectrum - 400 nm thick\nConstant Illuminant', 'ThinFilm-Spectrum-400nm') thinfilm_spectrum_plot( 1.003, 1.33, 1.003, 500.0, illuminant, 'Thin Film Interference Spectrum - 500 nm thick\nConstant Illuminant', 'ThinFilm-Spectrum-500nm')
def figures (): '''Draw some thin film plots.''' # Simple patch plot. This is not all that interesting. thickness_nm_list = numpy.linspace(0.0, 750.0, 36) illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant (illuminant, 9.50) thinfilm_patch_plot (1.500, 1.003, 1.500, thickness_nm_list, illuminant, 'ThinFilm Patch Plot', 'ThinFilm-Patch') # Plot the colors of films vs thickness. # Scale the illuminant to get a better range of color. thickness_nm_list = numpy.linspace(0.0, 1000.0, 800) # Gap in glass/plastic. illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant (illuminant, 4.50) thinfilm_color_vs_thickness_plot ( 1.500, 1.003, 1.500, thickness_nm_list, illuminant, 'Thin Film - Gap In Glass/Plastic (n = 1.50)\nIlluminant D65', 'ThinFilm-GlassGap') # Soap bubble. illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant (illuminant, 9.50) thinfilm_color_vs_thickness_plot ( 1.003, 1.33, 1.003, thickness_nm_list, illuminant, 'Thin Film - Soap Bubble (n = 1.33)\nIlluminant D65', 'ThinFilm-SoapBubble') # Oil slick on water. illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant (illuminant, 15.00) thinfilm_color_vs_thickness_plot ( 1.003, 1.44, 1.33, thickness_nm_list, illuminant, 'Thin Film - Oil Slick (n = 1.44) on Water (n = 1.33)\nIlluminant D65', 'ThinFilm-OilSlick') # Large index of refraction bubble. # This has the brightest colors, but is a bit of an artificial example. illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant (illuminant, 3.33) thinfilm_color_vs_thickness_plot ( 1.003, 1.60, 1.003, thickness_nm_list, illuminant, 'Thin Film - Large Index (n = 1.60) Bubble\nIlluminant D65', 'ThinFilm-LargeBubble') # A very thick film to test the aliasing limits. # You have to go to very large thicknesses to get much aliasing. thickness_nm_list = numpy.linspace(0.0, 200000.0, 800) illuminant = illuminants.get_illuminant_D65() illuminants.scale_illuminant (illuminant, 9.50) thinfilm_color_vs_thickness_plot ( 1.003, 1.33, 1.003, thickness_nm_list, illuminant, 'Not-so-thin Film - Soap Bubble (n = 1.33)\nIlluminant D65', 'ThinFilm-Thick') # Plot the spectrum of the refection for a couple of thicknesses. # Use a constant illuminant for a cleaner plot. # FIXME: Should this really be using an illuminant? illuminant = illuminants.get_constant_illuminant() illuminants.scale_illuminant (illuminant, 9.50) thinfilm_spectrum_plot (1.003, 1.33, 1.003, 400.0, illuminant, 'Thin Film Interference Spectrum - 400 nm thick\nConstant Illuminant', 'ThinFilm-Spectrum-400nm') thinfilm_spectrum_plot (1.003, 1.33, 1.003, 500.0, illuminant, 'Thin Film Interference Spectrum - 500 nm thick\nConstant Illuminant', 'ThinFilm-Spectrum-500nm')