-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.py
59 lines (53 loc) · 2.89 KB
/
constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Libraries
from math import pi
import numpy as np
from properties import look
# Globals
h = 6.62607004e-34 # Planck's constant
c = 299792458 # speed of light (m/s)
T = 5778 # sun's Temperature (k)
k = 1.38064852e-23 # Boltzmann constant
n = 1.0002926 # IOR of air
N = 2.504e25 # number density of air (molecules/m^3)
Do = 2.687e20 # Dobson unit (molecules/m^2)
rayleigh_scale = 8000 # Rayleigh scale height (m)
mie_scale = 1200 # Mie scale height (m)
mie_G = 0.76 # aerosols anisotropy
sqr_G = mie_G * mie_G # quared mie_G
ozone_max = 300 * Do / 15e3 # Maximum number density of ozone molecules (m^-3)
earth_sun = 149.6e9 # average distance Earth-Sun (m)
sun_radius = 695500e3 # radius of Sun (m)
earth_radius = 6360e3 # radius of Earth (m)
atmosphere_radius = 6420e3 # radius of atmosphere (m)
num_wavelengths = 21 # number of wavelengths
wavelengths_step = (num_wavelengths - 1) * 10**-9 # step between wavelengths (m)
max_luminous_efficacy = 683 # maximum luminous efficacy
# illuminants
illuminant_D65 = np.array([[3.2404542, -1.5371385, -0.4985314],
[-0.9692660, 1.8760108, 0.0415560],
[0.0556434, -0.2040259, 1.0572252]])
illuminant_E = np.array([[2.3706743, -0.9000405, -0.4706338],
[-0.5138850, 1.4253036, 0.0885814],
[0.0052982, -0.0146949, 1.0093968]])
# wavelengths every 20nm
lam = np.arange(380., 781., 20) * 10**-9
# CIE color matching functions from 380 to 780nm in 20nm intervals
cmf = np.loadtxt('data/cie_xyz.csv', usecols=(1,2,3))
# blackbody radiation
sun = (2 * pi * h * c * c) / (lam**5 * (np.exp((h * c) / (k * T * lam)) - 1)) * 10**-9
# irradiance on top of atmosphere
irradiance = sun * ((sun_radius * sun_radius) / (earth_sun * earth_sun))
# Rayleigh scattering coefficient (m^-1)
rayleigh_coeff = ((8 * pi**3) * (n * n - 1)**2) / (3 * N * lam**4)
# Mie scattering coefficient (m^-1)
mie_coeff = 2e-5
# Ozone cross section (cm^2/molecule) to coefficient (m^-1)
ozone_cross = np.loadtxt('data/ozone_cross_section.csv', usecols=(1))
ozone_coeff = ozone_cross * 10**-4 * ozone_max
def read_filmic_look(path):
nums = []
with open(path) as filmic_file:
for line in filmic_file:
nums.append(float(line))
return nums
filmic_look = read_filmic_look("looks/" + look + ".txt")