Type 4

From Pynomo
Revision as of 19:20, 14 August 2008 by WikiSysop (Talk | contribs) (Block parameters)

Jump to: navigation, search

In general

Type 4 is proportion nomograph that have functional relationship:

[math]\frac{F_1(u_1)}{F_2(u_2)}=\frac{F_3(u_3)}{F_4(u_4)} [/math]

Use of this nomograph is given by the following simple example.

Simple example

Simple example: Type 4
600px
Generated portable document file (pdf): Ex_type4_nomo_1.pdf

Source code of simple example of type 2

"""
    ex_type4_nomo_1.py
 
    Simple nomogram of type 2: F1=F2*F3
 
    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 *
 
N_params_1={
        'u_min':0.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$u_1$',
        'tick_levels':3,
        'tick_text_levels':1,
                }
 
N_params_2={
        'u_min':0.5,
        'u_max':6.0,
        'function':lambda u:u,
        'title':r'$u_2$',
        'tick_levels':3,
        'tick_text_levels':1,
                }
 
N_params_3={
        'u_min':0.0,
        'u_max':10.0,
        'function':lambda u:u,
        'title':r'$u_3$',
        'tick_levels':3,
        'tick_text_levels':1,
                }
 
 
block_1_params={
             'block_type':'type_2',
             'width':10.0,
             'height':10.0,
             'f1_params':N_params_1,
             'f2_params':N_params_2,
             'f3_params':N_params_3,
             }
 
main_params={
              'filename':'ex_type2_nomo_1.pdf',
              'paper_height':10.0,
              'paper_width':10.0,
              'block_params':[block_1_params],
              'transformations':[('rotate',0.01),('scale paper',)],
              'title_str':r'$u_1=u_2\times u_3$'
              }
Nomographer(main_params)

Parameters for type 2

Axis parameters

Specific axis parameters for type 2
Parameter Default value Explanation
'function' -

Function in the equation

'u_min' -

Minimum value of function variable

'u_max' -

Maximum value of function variable

Common axis parameters
Parameter Default value Explanation
'ID' 'none'

To identify the axis

'tag' 'none'

To align blocks w.r.t each other along axes with same tag

'title' ''

Axis title

'title_x_shift' 0.0

Title shift in x-direction

'title_y_shift' 0.25

Title shift in y-direction

'scale_type' 'linear'

Scale type. can be

  • 'linear': linear scale
  • 'log': logarithmic scale
  • 'smart linear': linear scale with equal spacings
  • 'smart log': logarithmic scale with equal spacings, can also have negative values
  • 'manual point': Points and corresponding text positions are given manually in 'manual axis data'. No line is drawn.
  • 'manual line': Ticks and corresponding text positions are given manually in 'manual axis data'. Line is drawn.
'tick_levels' 4

How many levels (minor, minor-minor, etc.) of ticks are drawn. Largest effect to 'linear' scale.

'tick_text_levels' 3

How many levels (minor, minor-minor, etc.) of texts are drawn. Largest effect to 'linear' scale.

'tick_side' 'right'

Tick and text side in final paper. Can be:

  • 'right'
  • 'left'
'reference' False

If axis is treated as reference line that is a turning point.

'reference_padding' 0.2

Fraction of reference line over other lines

'manual_axis_data' {}

Manually set tick/point positions and text positions. Could be for example:

{1:'1',3.14:r'$\pi$',5:'5',7:'seven',10:'10'}
'title_draw_center' False

Title is drawn to center of line

'title_distance_center' 0.5

Distance of centered title from line if centered title

'title_opposite_tick' True

Title in opposite direction w.r.t ticks

'align_func' lambda u:u

function to align different scalings

'align_x_offset' 0.0

If axis is aligned with other axis, this value x offsets final scale

'align_y_offset' 0.0

If axis is aligned with other axis, this value y offsets final scale

'text_format' r"$%4.4g$ "

Format for numbers in scale.

'extra_params' --

List of dictionary of params to be drawn additionally.

'text_distance_#' --

where #=0,1,2,3 or 4. Distance of text from scale line. Number corresponds to the level, where 0 is the major tick and 4 is the most minor ticks.

'grid_length_#' --

where #=0,1,2,3 or 4. Length of the tick. Number corresponds to the level, where 0 is the major tick and 4 is the most minor ticks.

'text_size_#' --

where #=0,1,2,3 or 4. Text size. For example: text.size.small, text.size.scriptsize or text.size.tiny . Number corresponds to the level, where 0 is the major tick and 4 is the most minor ticks.

'text_size_log_#' --

where #=0,1 or 2. Text size. For example: text.size.small, text.size.scriptsize or text.size.tiny . Number corresponds to the level, where 0 is the major tick and 2 is the most minor ticks.

'full_angle' False

If true, text can be upside down, otherwise +- 90 degrees from horizontal. Good foor example for full circle scales.

'extra_angle' 0.0

Angle to rotate tick text from horizontal along tick.

'text_horizontal_align_center' False

Aligns tick text horizontally to center. Good when text rotated 90 degrees.

'turn_relative' False

Side left or right is relative according to traveling of scale from min to max.

'arrow_size' 0.2

Used with arrow scale.

'arrow_length' 1.0

Used with arrow scale.

'arrow_color' color.rgb.black

Used with arrow scale.

'axis_color' color.rgb.black

Color of axis.

'text_color' color.rgb.black

Color of tick texts.

'extra_titles' []

List of extra title dicts for scale. Could be i.e.

[{'dx':1.0,
 'dy':1.0,
 'text':'extra title 1',
 'width':5,
 'pyx_extra_defs':[color.rgb.red,text.size.Huge]
 },
 {'text':'extra title 2'}
]
'base_start' None

Defines number with 'base_stop' (instead of u_min or u_max) to find major tick decades.

'base_stop' None

Defines number with 'base_start' (instead of u_min or u_max) to find major tick decades.

Block parameters

Specific block parameters for type 4
Parameter Default value Explanation
'block_type' 'type_4'

This is type 4 block

'width' 10.0

Block width (to be scaled)

'height' 10.0

Block height (to be scaled)

'f1_params' --

Axis params for function f1

'f2_params' --

Axis params for function f2

'f3_params' --

Axis params for function f3

'f4_params' --

Axis params for function f4

'mirror_x' False

If x-axis is mirrored

'mirror_y' False

If y-axis is mirrored

'float_axis' --

If given 'F1 or F2', then scaling is according to them, otherwise according to F3 and F4.

'padding' 0.9

how much axis extend w.r.t. width/height

General main parameters

General main parameters
Parameter Default value Explanation
'filename' --

filename of generated pdf

'paper_height' 10.0

Height of paper (roughly, ticks and texts extend this)

'paper_width' 10.0

Width of paper (roughly, ticks and texts extend this)

'block_params' --

List of blocks that make the nomograph

'transformations' --

List of transformations to transform nomograph

'title_str' --

Title string of nomograph

'title_x' --

Title x-position

'title_y' --

Title y-position

'title_box_width' --

Title box width

'title_color' color.rgb.black

Title color

'make_grid' False

If True, draws grid to help position texts, etc.

'draw_lines' False

If True, draws (brute-force) lines according to 'line_params'

'line_params' []

OBSOLETE, USE ISOPLETHS. List of dics of (brute-force) lines. For example:

[{'coords':[[0,0,1,1],[2,2,3,3]],
 'line_style':[color.cmyk.Black,
               style.linewidth.thick,
               style.linestyle.dashed],
 'circle_size':0.0005,
 'circle_color':color.cmyk.Black,
}]
'pre_func' None

PyX function(canvas) to draw under nomograph. Function definitin could be:

def post(c):
    c.stroke(path.line(2, 2, 15, 2) +
         path.line(15, 2, 10, 15) +
         path.line(15, 15, 2, 15) +
         path.line(2, 15, 2, 2))
'post_func' None

PyX function(canvas) to draw over nomograph. Definiton same as for 'pre_func'.

'debug' False

If True, prints dicts of definions. Feature in PyNomo 0.2.1: not all default values are printed.

'extra_texts' []

List of dicts defining extra texts. Could be for example:

[{'x':1.0,
  'y':1.0,
  'text':'testing',
  'width':5,
  'pyx_extra_defs':[color.rgb.red,text.size.Huge]
 },
 {'x':1.0,
  'y':2.0,
  'text':'testing',
  'width':5,
  'pyx_extra_defs':[color.rgb.green]
 },
 {'x':1.0,
  'y':3.0,
  'text':r"line \par break",
  'width':5,
  'pyx_extra_defs':[color.rgb.blue,text.size.tiny]
 }]
'isopleth_params' [{}]

List of dicts defining isopleths. Could be for example:

[{'color':'MidnightBlue',
  'linewidth':'THICK',
  'linestyle':'dashdotted',
  'transparency':0.2},
  {'color':'Orange',
   'linewidth':'THIN',
   'linestyle':'dashdotted',
   'transparency':0.9}]