Advertisement
TolentinoCotesta

CIE1931 correction table

Apr 26th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. STEP_NUM = 100        
  2. MAX_OUTPUT = 9990
  3. INT_TYPE = 'unsigned int'
  4. TABLE_NAME = 'cie_table'
  5. TRIAC_DELAY = 10
  6.  
  7. def cie1931(L):
  8.     L = L*100.0
  9.     if L <= 8:
  10.         return (L/902.3)
  11.     else:
  12.         return ((L+16.0)/116.0)**3
  13.  
  14. x = range(0,int(STEP_NUM+1))
  15. y = [round(cie1931(float(L)/STEP_NUM)*MAX_OUTPUT) for L in x]
  16.  
  17.  
  18. f = open('cie1931.h', 'w')
  19. textOut = '// CIE1931 correction table\n'
  20. textOut += '// Automatically generated\n'
  21.  
  22. textOut += '%s %s[%d] = {\n' % (INT_TYPE, TABLE_NAME, STEP_NUM+1)
  23. textOut += '\t'
  24. for i, L in enumerate(reversed(y)):
  25.     val = MAX_OUTPUT - L
  26.     textOut += '%d, ' % int(val)
  27.     if i % 10 == 9:
  28.         textOut += '\n\t'
  29.  
  30. textOut += '\n};\n\n'
  31. print(textOut)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement