#!/usr/local/bin/python
# Function to calculate the quadratic mean diameter 
# from basal area and tree per acre
# by David R. Larsen, October 11, 2012
# Creative Commons,  http://creativecommons.org/licenses/by-nc/3.0/us/

import math

def qmd( ba, tpa, unittype="imperial"):
    if( unittype == "imperial" ):
       value = math.sqrt( (ba/tpa)/0.005454154 )	
       return value
    elif( unittype == "metric"):
       value = math.sqrt( (ba/tpa)/0.00007854 )
       return value
    else:
       print( "Unknown unittype, options are imperial or metric")
       return 

print( "qmd =", qmd(80.0, 200.0))
print( "qmd =", qmd(80.0, 200.0, "imperial"))
print( "qmd =", qmd(18.3, 494.1, "metric"))
print( "qmd =", qmd(1.0, 1.0, "cunits"))
d3566b4d1c81bb2d89e6ef42d5958efd37d2e918
<mask token>

<mask token>


def qmd(ba, tpa, unittype='imperial'):
    if unittype == 'imperial':
        value = math.sqrt(ba / tpa / 0.005454154)
        return value
    elif unittype == 'metric':
        value = math.sqrt(ba / tpa / 7.854e-05)
        return value
    else:
        print('Unknown unittype, options are imperial or metric')
        return


<mask token>

<mask token>


def qmd(ba, tpa, unittype='imperial'):
    if unittype == 'imperial':
        value = math.sqrt(ba / tpa / 0.005454154)
        return value
    elif unittype == 'metric':
        value = math.sqrt(ba / tpa / 7.854e-05)
        return value
    else:
        print('Unknown unittype, options are imperial or metric')
        return


print('qmd =', qmd(80.0, 200.0))
print('qmd =', qmd(80.0, 200.0, 'imperial'))
print('qmd =', qmd(18.3, 494.1, 'metric'))
print('qmd =', qmd(1.0, 1.0, 'cunits'))

import math


def qmd(ba, tpa, unittype='imperial'):
    if unittype == 'imperial':
        value = math.sqrt(ba / tpa / 0.005454154)
        return value
    elif unittype == 'metric':
        value = math.sqrt(ba / tpa / 7.854e-05)
        return value
    else:
        print('Unknown unittype, options are imperial or metric')
        return


print('qmd =', qmd(80.0, 200.0))
print('qmd =', qmd(80.0, 200.0, 'imperial'))
print('qmd =', qmd(18.3, 494.1, 'metric'))
print('qmd =', qmd(1.0, 1.0, 'cunits'))

#!/usr/local/bin/python
# Function to calculate the quadratic mean diameter 
# from basal area and tree per acre
# by David R. Larsen, October 11, 2012
# Creative Commons,  http://creativecommons.org/licenses/by-nc/3.0/us/

import math

def qmd( ba, tpa, unittype="imperial"):
    if( unittype == "imperial" ):
       value = math.sqrt( (ba/tpa)/0.005454154 )	
       return value
    elif( unittype == "metric"):
       value = math.sqrt( (ba/tpa)/0.00007854 )
       return value
    else:
       print( "Unknown unittype, options are imperial or metric")
       return 

print( "qmd =", qmd(80.0, 200.0))
print( "qmd =", qmd(80.0, 200.0, "imperial"))
print( "qmd =", qmd(18.3, 494.1, "metric"))
print( "qmd =", qmd(1.0, 1.0, "cunits"))