Difference between revisions of "Human body surface area"

From Pynomo
Jump to: navigation, search
(New page: {{Infobox_general | name = AHuman body surface area | image = 150px | Field1a =author | Field1b =Leif Roschier }} == Theory and background == This approach of const...)
 
(Source code)
Line 39: Line 39:
 
<source lang=python>
 
<source lang=python>
 
"""
 
"""
     ex_amortized_loan.py
+
     ex_dubois.py
  
     Amortized loan calculator
+
     Body Surface Area (BSA) according to
 +
    Du Bois & Du Bois, Arch Intern Med 1916;17:863:
  
     Copyright (C) 2007-2008  Leif Roschier
+
    Body Surface Area = 0.007184* (Weight(kg)**0.425)*(Height(cm)**0.725)
 +
 
 +
     Copyright (C) 2007-2008  Leif Roschier
  
 
     This program is free software: you can redistribute it and/or modify
 
     This program is free software: you can redistribute it and/or modify
Line 60: Line 63:
 
from nomographer import *
 
from nomographer import *
  
# Type 5 grid
+
# BSA (m2)
def f1(x,u):
+
BSA_params={
    return log(log(x/(x-u/(100.0*12.0)))/log(1+u/(100.0*12.0)))
+
        'u_min':0.5,
 +
        'u_max':3.0,
 +
        'function':lambda u:-log(u/0.007184),
 +
        'title':r'BSA (m$^2$)',
 +
        'tick_levels':3,
 +
        'tick_side':'left',
 +
        'tick_text_levels':2,
 +
                }
  
block_1_params={
+
weight_params={
            'width':10.0,
+
        'tag':'mass',
          'height':5.0,
+
        'u_min':15.0,
          'block_type':'type_5',
+
         'u_max':200.0,
          'u_func':lambda u:log(u*12.0),
+
         'function':lambda u:log(u**0.425),
          'v_func':f1,
+
         'title':r'm (kg)',
          'u_values':[10.0,15.0,20.0,25.0,30.0,40.0,50.0,60.0],
+
         'tick_levels':3,
          'v_values':[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],
+
          'wd_tag':'A',
+
          'u_title':'years',
+
          'v_title':r'interest rate \%',
+
            }
+
 
+
# this is non-obvious trick to find bottom edge coordinates of the grid in order
+
# to align it with N nomogram
+
block1_dummy=Nomo_Block_Type_5(mirror_x=False)
+
block1_dummy.define_block(block_1_params)
+
block1_dummy.set_block()
+
 
+
# Let's define the N-nomogram
+
N_params_3={
+
        'u_min':block1_dummy.grid_box.params_wd['u_min'],
+
         'u_max':block1_dummy.grid_box.params_wd['u_max'],
+
         'function':lambda u:u,
+
         'title':'',
+
        'tag':'A',
+
        'tick_side':'right',
+
         'tick_levels':2,
+
 
         'tick_text_levels':2,
 
         'tick_text_levels':2,
         'reference':False,
+
         'scale_type':'linear',
        'tick_levels':0,
+
         'title_x_shift':0.8,
         'tick_text_levels':0,
+
        'title_draw_center':True
+
 
                 }
 
                 }
N_params_2={
+
 
         'u_min':30.0,
+
height_params={
         'u_max':1000.0,
+
        'tag':'height',
         'function':lambda u:u,
+
         'u_min':75.0,
         'title':'Loan',
+
         'u_max':220.0,
        'tag':'none',
+
         'function':lambda u:log(u**0.725),
        'tick_side':'left',
+
         'title':r'h (cm)',
 
         'tick_levels':3,
 
         'tick_levels':3,
 
         'tick_text_levels':2,
 
         'tick_text_levels':2,
         'title_draw_center':True
+
         'tick_side':'left',
 +
        'title_x_shift':-0.8,
 
                 }
 
                 }
N_params_1={
+
 
        'u_min':0.2,
+
block_1_params={
        'u_max':3.0,
+
            'block_type':'type_1',
        'function':lambda u:u,
+
            'width':10.0,
         'title':'monthly payment',
+
            'height':10.0,
         'tag':'none',
+
            'f2_params':BSA_params,
         'tick_side':'right',
+
            'f1_params':weight_params,
 +
            'f3_params':height_params}
 +
 
 +
weight_params_lbs={
 +
         'tag':'mass',
 +
         'u_min':15.0*2.2,
 +
        'u_max':200.0*2.2,
 +
         'function':lambda u:log(u**0.425),
 +
        'title':r'm (lbs)',
 
         'tick_levels':3,
 
         'tick_levels':3,
 +
        'align_func':lambda u:u/2.2,
 
         'tick_text_levels':2,
 
         'tick_text_levels':2,
         'title_draw_center':True
+
         'tick_side':'left',
 +
        'scale_type':'linear',
 +
        'title_x_shift':-0.8,
 
                 }
 
                 }
  
 
block_2_params={
 
block_2_params={
            'block_type':'type_2',
+
                'block_type':'type_8',
            'width':10.0,
+
                'f_params':weight_params_lbs
            'height':20.0,
+
                }
            'f1_params':N_params_1,
+
 
            'f2_params':N_params_2,
+
height_params_inch={
            'f3_params':N_params_3,
+
        'tag':'height',
            }
+
        'u_min':75.0/2.54,
 +
        'u_max':220.0/2.54,
 +
        'function':lambda u:log(u**0.725),
 +
        'title':r'h (inch)',
 +
        'tick_levels':4,
 +
        'align_func':lambda u:u*2.54,
 +
        'tick_text_levels':3,
 +
        'tick_side':'right',
 +
        'scale_type':'linear',
 +
        'title_x_shift':0.8,
 +
                }
 +
 
 +
block_3_params={
 +
                'block_type':'type_8',
 +
                'f_params':height_params_inch
 +
                }
 +
 
  
 
main_params={
 
main_params={
               'filename':'amortized_loan.pdf',
+
               'filename':'ex_dubois.pdf',
 
               'paper_height':20.0,
 
               'paper_height':20.0,
               'paper_width':20.0,
+
               'paper_width':15.0,
               'block_params':[block_1_params,block_2_params],
+
               'block_params':[block_1_params,block_2_params,block_3_params],
 
               'transformations':[('rotate',0.01),('scale paper',)],
 
               'transformations':[('rotate',0.01),('scale paper',)],
                'title_str':r'Amortized loan calculator    \copyright    Leif Roschier 2008',
+
              'title_str':r'Du Bois \& Du Bois: $BSA = 0.007184 m^{0.425} h^{0.725}$'
                'title_x': 17,
+
                'title_y': 21,
+
                'title_box_width': 5
+
 
               }
 
               }
 
Nomographer(main_params)
 
Nomographer(main_params)
 
</source>
 
</source>

Revision as of 19:20, 29 August 2008

AHuman body surface area
Ex dubois.png
author Leif Roschier

Theory and background

This approach of constructing an amortized loan calculator is similar to one in Ref. [1]

Equation for amortized loan [2] is:

[math] \frac{a}{A} = \frac{\frac{p}{100\times 12}}{1-\frac{1}{(1-\frac{p}{100\times 12})^{12n}}}, [/math]

where [math]A[/math] is the amount of loan, [math]a[/math] is monthly payment amount, [math]p[/math] interest rate per year (monthly interest rate is taken as [math]p/12[/math])[3] and [math]n[/math] is number of years for payment.


References

  1. d'Ocagne: Traite nomographie, 1899
  2. http://en.wikipedia.org/w/index.php?title=Amortization_calculator&oldid=220083943
  3. http://en.wikipedia.org/wiki/Annual_percentage_rate#Does_not_represent_the_total_cost_of_borrowing

Construction of the nomograph

Generated nomograph

Amortized loan calculator
Nomo test1.png
Generated portable document file (pdf): amortized_loan.pdf

Source code

"""
    ex_dubois.py
 
    Body Surface Area (BSA) according to
    Du Bois & Du Bois, Arch Intern Med 1916;17:863:
 
    Body Surface Area = 0.007184* (Weight(kg)**0.425)*(Height(cm)**0.725)
 
    Copyright (C) 2007-2008  Leif Roschier
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
from nomographer import *
 
# BSA (m2)
BSA_params={
        'u_min':0.5,
        'u_max':3.0,
        'function':lambda u:-log(u/0.007184),
        'title':r'BSA (m$^2$)',
        'tick_levels':3,
        'tick_side':'left',
        'tick_text_levels':2,
                }
 
weight_params={
        'tag':'mass',
        'u_min':15.0,
        'u_max':200.0,
        'function':lambda u:log(u**0.425),
        'title':r'm (kg)',
        'tick_levels':3,
        'tick_text_levels':2,
        'scale_type':'linear',
        'title_x_shift':0.8,
                }
 
height_params={
        'tag':'height',
        'u_min':75.0,
        'u_max':220.0,
        'function':lambda u:log(u**0.725),
        'title':r'h (cm)',
        'tick_levels':3,
        'tick_text_levels':2,
        'tick_side':'left',
        'title_x_shift':-0.8,
                }
 
block_1_params={
             'block_type':'type_1',
             'width':10.0,
             'height':10.0,
             'f2_params':BSA_params,
             'f1_params':weight_params,
             'f3_params':height_params}
 
weight_params_lbs={
        'tag':'mass',
        'u_min':15.0*2.2,
        'u_max':200.0*2.2,
        'function':lambda u:log(u**0.425),
        'title':r'm (lbs)',
        'tick_levels':3,
        'align_func':lambda u:u/2.2,
        'tick_text_levels':2,
        'tick_side':'left',
        'scale_type':'linear',
        'title_x_shift':-0.8,
                }
 
block_2_params={
                 'block_type':'type_8',
                 'f_params':weight_params_lbs
                 }
 
height_params_inch={
        'tag':'height',
        'u_min':75.0/2.54,
        'u_max':220.0/2.54,
        'function':lambda u:log(u**0.725),
        'title':r'h (inch)',
        'tick_levels':4,
        'align_func':lambda u:u*2.54,
        'tick_text_levels':3,
        'tick_side':'right',
        'scale_type':'linear',
        'title_x_shift':0.8,
                }
 
block_3_params={
                 'block_type':'type_8',
                 'f_params':height_params_inch
                 }
 
 
main_params={
              'filename':'ex_dubois.pdf',
              'paper_height':20.0,
              'paper_width':15.0,
              'block_params':[block_1_params,block_2_params,block_3_params],
              'transformations':[('rotate',0.01),('scale paper',)],
              'title_str':r'Du Bois \& Du Bois:  $BSA = 0.007184 m^{0.425} h^{0.725}$'
              }
Nomographer(main_params)