Skip to content

Commit

Permalink
rename some things to fit python conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
philiplinden committed Oct 25, 2023
1 parent 29b783e commit 47ab1cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions repro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import numpy as np
from pprint import pprint

from .simulator import Hapke, get_sample_grid
from .simulator import hapke, get_sample_grid


if __name__ == "__main__":
WLS = get_sample_grid()
Refl = np.array([np.random.randn() * x for x in WLS])
R = Hapke(Refl, WLS)
R = hapke(Refl, WLS)
pprint(WLS)
pprint(Refl)
pprint(R)
Expand Down
11 changes: 6 additions & 5 deletions repro/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def backscattering(h, g):
return 1 / (1 + (1 / h) * np.tan(g / 2))


def R(SSA, P, mu, mu0, B):
def bidirectional_reflectance(SSA, P, mu, mu0, B):
"""Bidirectional reflectance, see Equation 1.
R = (ω/4) (μ₀ / (μ + μ₀)) {(1 + B)P + H(ω)H₀(ω) - 1}
Expand Down Expand Up @@ -95,7 +95,7 @@ def R(SSA, P, mu, mu0, B):
_type_: _description_
"""

def Hfunc(SSA, mu, mu0):
def h_func(SSA, mu, mu0):
"""Ambartsumian-Chandrasekhar H functions.
Computed using the approximation from equation 8.57 from Hapke (2012).
Expand All @@ -120,7 +120,7 @@ def Hfunc(SSA, mu, mu0):
H0 = (1 - SSA * mu * h5) ** -1
return H, H0

H, H0 = Hfunc(SSA, mu, mu0)
H, H0 = h_func(SSA, mu, mu0)

r1 = SSA / 4
r2 = mu0 / (mu0 + mu)
Expand All @@ -129,7 +129,7 @@ def Hfunc(SSA, mu, mu0):
return r1 * r2 * (r3 + r4 - 1)


def Hapke(
def hapke(
Refl,
WLS,
P=0.15,
Expand Down Expand Up @@ -171,7 +171,8 @@ def Hapke(
w = []
for m, x in zip(Refl, WLS):
w0 = 0.5 # initial guess, ω₀
y = partial(R, P=P, mu=mu, mu0=mu0, B=B) # turn R() into the form y=f(x)
# turn bidrectional_reflectance() into the form y=f(x)
y = partial(bidirectional_reflectance, P=P, mu=mu, mu0=mu0, B=B)
OLS = partial(
ordinary_least_squares, y=y, yx=m
) # turn least squares into the form y=f(x)
Expand Down

0 comments on commit 47ab1cb

Please sign in to comment.