USDA-ARS-NWRC / topocalc

Sky view and terrain configuration factors
Other
13 stars 8 forks source link

updated dozier 2022 equations #14

Closed brentwilder closed 2 months ago

brentwilder commented 2 months ago

These equations are more accurate than the 1990 method, as they also account for the slope obscuring the horizon. This change as I have typed up here should still work nicely with this current branch of parallelizing the code.

jomey commented 2 months ago

Thanks for getting this started @brentwilder

From a software design perspective - What do you think about this pseudo code:

def dozier_2022(...):
  # New logic

def dozier_and_frew_1992(..):
  # Old logic

def viewf(...)

    # old common code

    for angle in angles:
        # horizon angles
        hcos = horizon(angle, dem, spacing)
        azimuth = d2r(angle)

        if method == 'dozier_2022':
            dozier_2022()
        elif method == 'dozier_and_frew_1990':
            dozier_and_frew_1990()
        else:
            raise("Unknown sky view factor method given")

        ind = intgrnd > 0
        svf[ind] = svf[ind] + intgrnd[ind]

    # Compute final arrays
    svf = svf / len(angles)
    tcf = (1 + cos_slope)/2 - svf

    return svf, tcf

This keeps common components and has less duplicated lines.

brentwilder commented 2 months ago

@jomey ,yep I agree it makes sense too in case there is an updated method as well. Can be plugged in quite easily in this way. I believe everything is ready now!