<jupyter_start><jupyter_text>Beautiful Photometry* [GitHub]()A set of tools to compute lighting photometric data and generate beautiful graphics. This is a work in progress.It is based on the Colour Science library ([GitHub](https://github.com/colour-science/colour)) ([Docs](https://www.colour-science.org/)).<jupyter_code># First, some boilerplate code just to run this notebook

# displays plots in this notebook
%matplotlib inline 

# Since we are in the ./examples folder, add the root folder (../) to the path
import sys
sys.path.append('../')

# Colour Science Library
import colour  
from src.spectrum import import_spd

# Get the SPDs
incandescent = import_spd('../CSVs/incandescent.csv', 'Incandescent', normalize=True)
halogen = import_spd('../CSVs/halogen.csv', 'Halogen', normalize=True)
led2700 = import_spd('../CSVs/led2700.csv', '2700 K LED', normalize=True)

# Print the CRI
incandescent_cri = colour.colour_rendering_index(incandescent)
halogen_cri = colour.colour_rendering_index(halogen)
led2700_cri = colour.colour_rendering_index(led2700)

print('Incandescent CRI:', incandescent_cri)
print('Halogen CRI:', halogen_cri)
print('2700 K LED CRI:', led2700_cri)
from src.plot import plot_spectrum, plot_multi_spectrum

plot_spectrum(incandescent, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True)
plot_spectrum(halogen, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/halogen.png')
plot_spectrum(led2700, hideyaxis=True)

plot_multi_spectrum([incandescent, halogen, led2700], melanopic_curve=True, hideyaxis=True)
# Get the SPDs
daylight = import_spd('../CSVs/daylight.csv', 'Daylight', normalize=True)
night = import_spd('../CSVs/moonlight.csv', 'Night', normalize=True)
candle = import_spd('../CSVs/candle.csv', 'Fire', normalize=True)

plot_spectrum(daylight, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/daylight.png')
plot_spectrum(night, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/night.png')
plot_spectrum(candle, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/candle.png')
# Bedtime Bulb Comparison

bedtimebulb = import_spd('../CSVs/bedtime_bulb.csv', 'Bedtime Bulb', normalize=True)
bedtimebulbweighted = import_spd('../CSVs/bedtime_bulb.csv', 'Bedtime Bulb', normalize=True, weight=350/650)

soraa = import_spd('../CSVs/soraa.csv', 'Soraa Healthy', normalize=True)
soraaweighted = import_spd('../CSVs/soraa.csv', 'Soraa Healthy', normalize=True, weight=600/650)

lsg = import_spd('../CSVs/lsg.csv', 'LSG Goodnight', normalize=True)
lsgweighted = lsg

plot_spectrum(bedtimebulb, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/Bedtime Bulb Spectrum.png')
plot_spectrum(soraa, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True)
plot_spectrum(lsg, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True)
plot_multi_spectrum([bedtimebulbweighted, soraaweighted, lsgweighted], melanopic_curve=True, hideyaxis=True, filename='../out/Low Blue Comparison.png')
bedtimebulbweighted = import_spd('../CSVs/bedtime_bulb.csv', 'Bedtime Bulb', normalize=True, weight=350/800)
halogenweighted = import_spd('../CSVs/halogen.csv', 'Halogen 650 lm', normalize=True, weight=650/800)
incandescent = import_spd('../CSVs/incandescent.csv', 'Incandescent 800 lm', normalize=True)
led2700 = import_spd('../CSVs/led2700.csv', 'LED 2700K 800 lm', normalize=True)

plot_multi_spectrum([bedtimebulbweighted, incandescent, halogenweighted, led2700], melanopic_curve=True, hideyaxis=True, filename='../out/Traditional Source Comparison.png')
# Melanopic Ratio
from src.human_circadian import melanopic_ratio, melanopic_response, melanopic_lumens, melanopic_photopic_ratio
from src.human_visual import scotopic_photopic_ratio

print('melanopic response')
print(melanopic_response(bedtimebulb))
print(melanopic_response(incandescent))
print(melanopic_response(halogen))
print(melanopic_response(led2700))

print('melanopic ratio')
print(melanopic_ratio(bedtimebulb))
print(melanopic_ratio(incandescent))
print(melanopic_ratio(halogen))
print(melanopic_ratio(led2700))

print('melanopic lumens')
print(melanopic_lumens(bedtimebulb, 350))
print(melanopic_lumens(incandescent, 800))
print(melanopic_lumens(halogen, 650))
print(melanopic_lumens(led2700, 800))

print('s/p ratio')
print(scotopic_photopic_ratio(bedtimebulb))
print(scotopic_photopic_ratio(incandescent))
print(scotopic_photopic_ratio(halogen))
print(scotopic_photopic_ratio(led2700))

print('m/p ratio')
print(melanopic_photopic_ratio(bedtimebulb))
print(melanopic_photopic_ratio(incandescent))
print(melanopic_photopic_ratio(halogen))
print(melanopic_photopic_ratio(led2700))
# Indoor vs. Outdoor light
daylight = import_spd('../CSVs/daylight.csv', 'Daylight', normalize=True) # ~10,000 lux
night = import_spd('../CSVs/moonlight.csv', 'Outdoor Night', normalize=True, weight=0.32/10000) # 0.32 lux
indoor = import_spd('../CSVs/halogen.csv', 'Indoor Recommended', normalize=True, weight=500/10000) # 500 lux, indoor halogen
plot_multi_spectrum([daylight, night, indoor], melanopic_curve=True, hideyaxis=True, filename='../out/Indoor vs Outdoor.png')
# Interior vs. nighttime light
night = import_spd('../CSVs/moonlight.csv', 'Outdoor Night', normalize=True, weight=0.32/500) # 0.32 lux
indoor = import_spd('../CSVs/halogen.csv', 'Indoor Recommended', normalize=True) # 500 lux, indoor halogen
bedtimebulbweighted = import_spd('../CSVs/bedtime_bulb.csv', 'Bedtime Bulb', normalize=True, weight=100/500) # 100 lux
plot_multi_spectrum([night, indoor, bedtimebulbweighted], melanopic_curve=True, hideyaxis=True, filename='../out/Indoor Comparison.png')
plot_multi_spectrum([night, indoor], melanopic_curve=True, hideyaxis=True, filename='../out/Indoor Comparison no BB.png')
# GE Align PM vs BB
gealignpm = import_spd('../CSVs/GE_Align_PM.csv', 'GE Align PM', normalize=True)
plot_multi_spectrum([bedtimebulb, gealignpm], melanopic_curve=True, hideyaxis=True)
# S/P/M
from src.human_circadian import get_melanopic_curve
from src.human_visual import get_scotopic_curve, get_photopic_curve
plot_multi_spectrum([get_melanopic_curve(), get_scotopic_curve(), get_photopic_curve()], hideyaxis=True)


from src.human_visual import get_l_cone_curve, get_m_cone_curve, get_s_cone_curve
plot_multi_spectrum([get_l_cone_curve(), get_m_cone_curve(), get_s_cone_curve()], hideyaxis=True)
## Blue blockers article
# sunlight vs indoor 2700K LED
daylight = import_spd('../CSVs/daylight.csv', 'Daylight', normalize=True) # ~10,000 lux
indoor = import_spd('../CSVs/led2700.csv', 'LED 2700K', normalize=True, weight=500/10000) # 500 lux, indoor halogen
plot_multi_spectrum([daylight, indoor], melanopic_curve=True, hideyaxis=True, filename='../out/Daylight vs 2700K.png')
# 2700K LED
plot_spectrum(led2700, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/LED 2700K.png')
# moonlight vs 2700K LED
indoor = import_spd('../CSVs/led2700.csv', 'LED 2700K', normalize=True) # 500 lux, indoor halogen
night = import_spd('../CSVs/moonlight.csv', 'Outdoor Night', normalize=True, weight=0.32/500) # 0.32 lux
plot_multi_spectrum([indoor, night], melanopic_curve=True, hideyaxis=True, filename='../out/Moonlight vs 2700K.png')
# Orange glasses
uvex = import_spd('../CSVs/filters/uvex_sct_orange.csv', 'Uvex', normalize=True)
plot_spectrum(uvex, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/Uvex SCT Orange.png')
# Yellow glasses
gammaray = import_spd('../CSVs/filters/gamma_ray_computer_yellow.csv', 'Gamma Ray', normalize=True)
plot_spectrum(gammaray, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/Gamma Ray Yellow.png')
# Clear glasses
blutech = import_spd('../CSVs/filters/blutech_clear.csv', 'Blutech', normalize=True)
plot_spectrum(blutech, hideyaxis=True, melanopic_curve=True, melanopic_stimulus=True, filename='../out/Blutech Clear.png')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13621594601349662, 'fraction_numerical': 0.029617595601099726, 'mean_word_length': 7.9519015659955254, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '488849', 'license': 'MIT', 'n_tokens_mistral': 3205, 'n_tokens_neox': 2770, 'n_words': 522, 'path': 'examples/beautiful_photometry.ipynb', 'repo_name': 'yeutterg/beautiful-photometry', 'size': '8002'}