moved arri luts into subdir
[OpenColorIO-Configs.git] / aces / luts / arri / logc800.py
1 #!/usr/bin/env python
2
3 import math
4
5 """
6
7 // ARRI ALEXA IDT for ALEXA logC files
8 //  with camera EI set to 800
9 // Written by v3_IDT_maker.py v0.06 on Thursday 01 March 2012 by alex
10
11 float
12 normalizedLogCToRelativeExposure(float x) {
13         if (x > 0.149659)
14                 return (pow(10,(x - 0.385537) / 0.247189) - 0.052272) / 5.555556;
15         else
16                 return (x - 0.092809) / 5.367650;
17 }
18
19 """
20
21 def logCToLinear(x):
22         if (x > 0.149659):
23                 return (math.pow(10.0,(x - 0.385537) / 0.247189) - 0.052272) / 5.555556
24         else:
25                 return (x - 0.092809) / 5.367650
26
27 def WriteSPI1D(filename, fromMin, fromMax, data):
28     f = file(filename,'w')
29     f.write("Version 1\n")
30     f.write("From %s %s\n" % (fromMin, fromMax))
31     f.write("Length %d\n" % len(data))
32     f.write("Components 1\n")
33     f.write("{\n")
34     for value in data:
35         f.write("        %s\n" % value)
36     f.write("}\n")
37     f.close()
38
39 def Fit(value, fromMin, fromMax, toMin, toMax):
40     if fromMin == fromMax:
41         raise ValueError("fromMin == fromMax")
42     return (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin
43
44 NUM_SAMPLES = 2**14
45 RANGE = (-0.125, 1.125)
46 data = []
47 for i in xrange(NUM_SAMPLES):
48     x = i/(NUM_SAMPLES-1.0)
49     x = Fit(x, 0.0, 1.0, RANGE[0], RANGE[1])
50     data.append(logCToLinear(x))
51 WriteSPI1D('logc800.spi1d', RANGE[0], RANGE[1], data)