diff --git a/app.py b/app.py index 91fbb5e..ec8cb3e 100644 --- a/app.py +++ b/app.py @@ -124,7 +124,7 @@ class renderedImageZoom: t_frame = tkinter.Frame(self.aerosol_window) text_t = tkinter.Text(t_frame,height=1,width=10) submit_t_button = tkinter.Button(t_frame,text="set temperature", - command=lambda: [self.set_temp(text_t.get("1.0","end-1c")),t_label.config(text=str(sorted([-270,int(value),100])[1])+" C")]) + command=lambda: [self.set_temp(text_t.get("1.0","end-1c")),t_label.config(text=str(sorted([-270,int(text_t.get("1.0","end-1c")),100])[1])+" C")]) #submit_t_button = tkinter.Button(t_frame,text="set temperature",command=lambda: [print("what"),t_label.config(text="bruh")]) t_label = tkinter.Label(t_frame,text="5 C") text_t.pack(side=tkinter.LEFT) @@ -147,7 +147,7 @@ class renderedImageZoom: s_frame = tkinter.Frame(self.aerosol_window) text_s = tkinter.Text(s_frame,height=1,width=10) submit_s_button = tkinter.Button(s_frame,text="set direction of the sun",command=lambda: [self.set_sun(text_s.get("1.0","end-1c")), - sun_dir_label.config(text=str(sorted([0,int(text_t.get("1.0","end-1c")),90])[1])+" degrees")]) + sun_dir_label.config(text=str(sorted([0,int(text_s.get("1.0","end-1c")),90])[1])+" degrees")]) sun_dir_label = tkinter.Label(s_frame,text="90 degrees") text_s.pack(side=tkinter.LEFT) sun_dir_label.pack(side=tkinter.RIGHT) @@ -257,7 +257,13 @@ class renderedImageZoom: slice = self.image[:][low:high] red = 0 for line in slice: - red += sum([p[0]/(p[0]+p[1]+p[2]) for p in line]) + for pixel in line: + if sum(pixel) == 0: + print(pixel) + red += 0 + else: + print(pixel) + red += pixel[0]/sum(pixel) red = red / (100*(high-low)) return "{} is the pixel average".format(red) diff --git a/skydome.py b/skydome.py index 2708737..93463ff 100644 --- a/skydome.py +++ b/skydome.py @@ -76,9 +76,12 @@ wavelengths = Vec3(0.68, 0.55, 0.44) # These are the wavelengths in um @cython.cfunc def refraction_calculator(T:cython.int, P:cython.int) -> tuple[Vec3, Vec3]: alpha:cython.float = 0.00367 # in inverse Celsius - t_s:cython.int = T # degrees Celsius - p_s:cython.int = P # mmHg - + #t_s:cython.int = T # degrees Celsius + #p_s:cython.int = P # mmHg + t_s:cython.int = 25 # Temperature in degrees Celsius + p_s:cython.int = 760 # Pressure in mmHg + + n_s_values = [] # for debugging / comparing to the internet values n_values = [] n_s:cython.double @@ -112,12 +115,12 @@ def beta(n_values:Vec3): # Example usage, normal is 25, 750 -T:cython.int = 5 # Temperature in degrees Celsius -P:cython.int = 760 # Pressure in mmHg -n_s_values:Vec3 -n_values:cython.double -n_s_values, n_values = refraction_calculator(T, P) -beta_values = beta(n_values) +#t_s:cython.int = 25 # Temperature in degrees Celsius +#p_s:cython.int = 760 # Pressure in mmHg +#n_s_values:Vec3 +#n_values:cython.double +#n_s_values, n_values = refraction_calculator(T, P) +#beta_values = beta(n_values) #print("n_s values:", refraction_calculator_result.v) #print("n values:", n_values.v) @@ -138,7 +141,7 @@ It also varies according to temperature """ -betaR = Vec3(*beta_values.v) # Keeps it as a Vec3 +#betaR = Vec3(*beta_values.v) # Keeps it as a Vec3 #betaR = Vec3(3.8e-6, 13.5e-6, 33.1e-6) # R, G, B (the smaller the value, the less it will scatter during the day) in m-1 @@ -180,7 +183,7 @@ Hm:cython.int = 1200 # The direction will change for each pixel @cython.cfunc -def computeIncidentLight(direction:Vec3,betaM,g,observerEarthRadius,sunDir) -> tuple[float,float,float]: +def computeIncidentLight(direction:Vec3,betaM,betaR,g,observerEarthRadius,sunDir) -> tuple[float,float,float]: tmin:cython.float=0 tmax:cython.float=kInfinity @@ -298,6 +301,10 @@ def renderSkydome(filename,betaM,g,altitude,T,P,sunDir): observerEarthRadius = earthRadius + altitude start_time = time.time() # Start timing + n_s_values, n_values = refraction_calculator(T, P) + beta_values = beta(n_values) + betaR = Vec3(*beta_values.v) # Keeps it as a Vec3 + j:cython.int i:cython.int x:cython.float @@ -316,7 +323,7 @@ def renderSkydome(filename,betaM,g,altitude,T,P,sunDir): theta = math.acos(1 - z2) # This changes for each pixel direction = Vec3(math.sin(theta) * math.cos(phi), math.cos(theta), math.sin(theta) * math.sin(phi)) - color = computeIncidentLight(direction,betaM,g,observerEarthRadius,sunDir) + color = computeIncidentLight(direction,betaM,betaR,g,observerEarthRadius,sunDir) #color = computeIncidentLight(direction) @@ -375,7 +382,7 @@ def renderFromCamera(filename,betaM,g,altitude,T,P,sunDir): #This changes for each pixel, it is the direction we are looking in direction = Vec3(rayx, rayy, -1).normalize() - color = computeIncidentLight(direction,betaM,g,observerEarthRadius,sunDir) + color = computeIncidentLight(direction,betaM,betaR,g,observerEarthRadius,sunDir) #image[y, x] = np.array(color) image[y][x] = np.clip(color, 0, 1)