Difference between revisions of "Example:compound nomograph 1"

From Pynomo
Jump to: navigation, search
(Parameters for type 1)
(Simple example)
Line 21: Line 21:
 
== Simple example ==
 
== Simple example ==
 
{{Infobox_nomogram1
 
{{Infobox_nomogram1
| name        = Simple example: Type 1  
+
| name        = Compound nomograph: example 1  
| image =  [[Image:Ex type1 nomo 1.png|600px]]
+
| image =  [[Image:Ex compound nomo 1.png|600px]]
| file = [http://nomography.org/wiki/images/a/ac/Ex_type1_nomo_1.pdf Ex_type1_nomo_1.pdf]
+
| file = [[Image:Ex compund nomo 1.pdf]]
 
}}
 
}}
 
==== Source code of simple compound nomograph example ====
 
==== Source code of simple compound nomograph example ====

Revision as of 19:53, 28 August 2008

Compound nomograph example 1

In this example we construct compound nomograph of equation

[math]\frac{A+B}{E}=\frac{F}{CD} \,[/math]

just as an example. The equation is split into three equations that each are blocks:

[math]A+B=R_1 \,\,\,\,\,\,\,[/math] (type 1)

[math]CD=R_2 \,\,\,\,\,\,\,[/math] (type 2)

[math]\frac{R_1}{E}= \frac{F}{R_2} \,\,\,\,\,\,\,[/math] (type 4)

It is iterative process in practice with PyNomo to construct compound nomograps. One should generate nomographs and correct for example block mirroring and axis tick sides, levels and title positions. The following is an example of result after some ten iterations. Note the 'tag' key that defines how blocks aling with respect to each other. User has to take care that aligned scalings are really equal between blocks. Best practice may be to print in early iterations the scalings and check they are equal.

Simple example

Compound nomograph: example 1
Ex compound nomo 1.png
Generated portable document file (pdf): File:Ex compund nomo 1.pdf

Source code of simple compound nomograph example

"""
    ex_compound_nomo_1.py
 
    Compound nomograph: (A+B)/E=F/(CD)
 
    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 *
 
# type 1
A_params={
        'u_min':0.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$A$',
        'tick_levels':2,
        'tick_text_levels':1,
                }
 
B_params={
        'u_min':0.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$B$',
        'tick_levels':2,
        'tick_text_levels':1,
                }
 
R1a_params={
        'u_min':0.0,
        'u_max':10.0,
        'function':lambda u:-u,
        'title':'',
        'tick_levels':0,
        'tick_text_levels':0,
        'tag':'r1'
                }
block_1_params={
             'block_type':'type_1',
             'width':10.0,
             'height':10.0,
             'f1_params':A_params,
             'f2_params':B_params,
             'f3_params':R1a_params,
             }
# type 4
R1b_params={
        'u_min':1.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$R_1$',
        'tick_levels':0,
        'tick_text_levels':0,
        'tick_side':'right',
        'title_draw_center':True,
        'title_opposite_tick':False,
        'tag':'r1'
                }
E_params={
        'u_min':1.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$E$',
        'tick_levels':3,
        'tick_text_levels':1,
        'tick_side':'right',
        'title_draw_center':True,
        'title_opposite_tick':False,
                }
F_params={
        'u_min':1.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$F$',
        'tick_levels':3,
        'tick_text_levels':1,
        'tick_side':'left',
        'title_draw_center':True,
        'title_opposite_tick':True,
                }
R2a_params={
        'u_min':1.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$R_2$',
        'tick_levels':0,
        'tick_text_levels':0,
        'tick_side':'left',
        'title_draw_center':True,
        'title_opposite_tick':False,
        'tag':'r2'
                }
 
block_2_params={
                'block_type':'type_4',
                'f1_params':R1b_params,
                'f2_params':E_params,
                'f3_params':F_params,
                'f4_params':R2a_params,
                'mirror_x':True
                             }
# type 2 N
R2b_params={
        'u_min':0.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$$',
        'tick_levels':0,
        'tick_text_levels':0,
        'tag':'r2'
                }
 
C_params={
        'u_min':0.5,
        'u_max':5.0,
        'function':lambda u:u,
        'title':r'$C$',
        'tick_levels':3,
        'tick_text_levels':1,
        'tick_side':'left',
                }
 
D_params={
        'u_min':1.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$D$',
        'tick_levels':3,
        'tick_text_levels':1,
                }
 
block_3_params={
             'block_type':'type_2',
             'width':10.0,
             'height':10.0,
             'f1_params':R2b_params,
             'f2_params':C_params,
             'f3_params':D_params,
             'mirror_y':True
             }
 
main_params={
              'filename':'ex_compound_nomo_1.pdf',
              'paper_height':10.0,
              'paper_width':10.0,
              'block_params':[block_1_params,block_2_params,block_3_params],
              'transformations':[('rotate',0.01),('scale paper',)],
              }
Nomographer(main_params)