def spectra_to_melanopic_irradiance(spectra, binwidth): # get melanopsin sensitivity sss = get_CIES026(asdf=True, binwidt=binwidth) mel = sss['Mel'] # aggregate to melanopic irradiance mi = spectra.groupby( by=['led', 'intensity'])['flux'].agg(lambda x: x.dot(mel.values.T)) return mi
def create_alphaopic_irradiances_table(self): '''Using the CIE026 spectral sensetivities, calculate alphaopic irradiances (S, M, L, Rhod and Melanopic) for every spectrum in `self.lkp`. Returns ------- pd.DataFrame Alphaopic irradiances. ''' sss = get_CIES026(asdf=True, binwidth=self.binwidth) sss = sss.fillna(0) return self.lkp.dot(sss)
red_led = 9 target_lux = 800 # find the required intensity setting of the blue led for 800 lux blue_intensity = ( cc.lux.loc[blue_led].sub(target_lux).abs().idxmin().values[0]) # find the intensity setting of the red led for 800 lux red_intensity = cc.match(match_led=blue_led, match_led_intensity=blue_intensity, target_led=red_led, match_type='irrad')[1] # plot stims fig, ax = plt.subplots() sss = get_CIES026(asdf=True, binwidth=1) ax.plot(cc.lkp.loc[(blue_led, blue_intensity)], c='blue') ax.plot(cc.lkp.loc[(red_led, red_intensity)], c='red') ax2 = ax.twinx() ax2.plot(sss['Mel'], ls='dashed', c='steelblue') ax2.set_ylabel('Melanopsin spectral sensitivity', c='steelblue') ax.set_xlabel('Wavelength (nm)') ax.set_ylabel('W/m2/nm') fig.savefig('./pipr_stims.png') # make video files blue_spec, red_spec = [0] * 10, [0] * 10 blue_spec[blue_led] = blue_intensity red_spec[red_led] = red_intensity
# In[4]: import sys sys.path.insert(0, '../../../PyPlr') import numpy as np import pandas as pd from pyplr.CIE import get_CIES026 # # Spectral sensitivities # In[5]: _, sss = get_CIES026(asdf=True) #sss = sss[::5] # downsample to 5nm bins sss.plot() # # Spectral mesurements (STLAB) # In[18]: stlspec = pd.read_csv( '/Users/jtm/OneDrive - Nexus365/spectrometer_data/stlab_led_intensity_spectra_08-17-20-14-31.csv' ) stlspec # In[19]: stlinfo = pd.read_csv(