# Difference between revisions of "Type 9"

## In general

Type 9 is "general determinant" nomograph that has functional relationship:

$\begin{vmatrix} F_1(u_1[,v_1]) & G_1(u_1[,v_1]) & H_1(u_1[,v_1]) \\ F_2(u_2[,v_2]) & G_2(u_2[,v_2]) & H_2(u_2[,v_2]) \\ F_3(u_3[,v_3]) & G_3(u_3[,v_3]) & H_3(u_3[,v_3]) \end{vmatrix} = 0.$

This is the basic building block for line nomographs. Notation $u[,v]\,$ is to be understood such that if v is defined´, a grid is constructed for the row, otherwise a normal scale with variable u.

## Simple example

This simple example plots nomograph for equation in determinant form:

$\begin{vmatrix} 0 & u_1 & 1 \\ u_2+2 & 2v_2+5 & 1 \\ 4 & u_3 & 1 \end{vmatrix} = 0$

Simple example: Type 9
Generated portable document file (pdf): File:Ex type9 nomo 1.pdf

#### Source code of simple example of type 9

"""
ex_type9_nomo_1.py

Simple nomogram of type 9: determinant

This program is free software: you can redistribute it and/or modify
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 pynomo.nomographer import *

N_params_1={
'u_min':3.0,
'u_max':10.0,
'f':lambda u:0,
'g':lambda u:u,
'h':lambda u:1.0,
'title':r'$u_1$',
'scale_type':'linear',
'tick_levels':3,
'tick_text_levels':2,
'grid':False}

N_params_2={
'u_min':0.0, # for alignment
'u_max':1.0,  # for alignment
'f_grid':lambda u,v:u+2.0,
'g_grid':lambda u,v:2*v+5.0,
'h_grid':lambda u,v:1.0,
'u_start':0.0,
'u_stop':1.0,
'v_start':0.0,
'v_stop':1.0,
'u_values':[0.0,0.25,0.5,0.75,1.0],
'v_values':[0.0,0.25,0.5,0.75,1.0],
'grid':True,
'text_prefix_u':r'$u_2$=',
'text_prefix_v':r'$v_2$=',
}

N_params_3={
'u_min':3.0,
'u_max':10.0,
'f':lambda u:4.0,
'g':lambda u:u,
'h':lambda u:1.0,
'title':r'$u_3$',
'scale_type':'linear',
'tick_levels':3,
'tick_text_levels':2,
'grid':False
}

block_params={
'block_type':'type_9',
'f1_params':N_params_1,
'f2_params':N_params_2,
'f3_params':N_params_3,
'transform_ini':False,
'isopleth_values':[[7,[0.75,0.5],'x']]
}

main_params={
'filename':'ex_type9_nomo_1.pdf',
'paper_height':10.0,
'paper_width':10.0,
'block_params':[block_params],
'transformations':[('rotate',0.01),('scale paper',)]
}
Nomographer(main_params)

## Parameters for type 9

#### Axis parameters

For grid parameters, see below.

Specific axis parameters for type 9
Parameter Default value Explanation
'f' -

F function in determinant

'g' -

G function in determinant

'h' -

H function in determinant

'u_min' -

Minimum value of function variable

'u_max' -

Maximum value of function variable

'u_min_trafo' -

Minimum value of function variable for initial transformation

'u_max_trafo' -

Maximum value of function variable for initial transformation

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.

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.

#### Grid parameters

Specific axis parameters for type 9
Parameter Default value Explanation
'grid' -

True. Have to be true because this is grid

'f' -

F function in determinant. For example lambda u,v:u+v

'g' -

G function in determinant. For example lambda u,v:u+v

'h' -

H function in determinant. For example lambda u,v:u+v

'u_start' --

u start when drawing v=const line

'u_stop' --

u stop when drawing v=const line

'v_start' --

v start when drawing u=const line

'v_stop' --

v start when drawing u=const line

'u_values' --

List of grid lines u=const. For example [0.0,0.25,0.5,0.75,1.0]

'v_values' --

List of grid lines v=const. For example [0.0,0.25,0.5,0.75,1.0]

'text_prefix_u' --

Text prefix for u before value

'text_prefix_v' --

Text prefix for v before value

'v_texts_u_start' False

If v-texts are in u start side

'v_texts_u_stop' True

If v-texts are in u stop side

'u_texts_v_start' False

If u-texts are in v start side

'u_texts_v_stop' True

If u-texts are in v stop side

'u_line_color' color.rgb.black

u line color

'v_line_color' color.rgb.black

v line color

'u_text_color' color.rgb.black

u text color

'v_text_color' color.rgb.black

v text color

'text_distance' 0.25

Text distance

'circles' False

If marker circles to crossings

'extra_params' --

List of params to be drawn.

#### Block parameters

Specific block parameters for type 9
Parameter Default value Explanation
'block_type' 'type_9'

This is type 9 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

'mirror_x' False

If x-axis is mirrored

'mirror_y' False

If y-axis is mirrored

'transform_ini' False

If row 1 and row 3 end and start are to be transformed to be in rectangle corners. If True, be sure that 'u_min_trafo' and 'u_max_trafo' are defined.

'isopleth_values' [[]]

List of list of isopleth values. Grid values are given with tuple (a,b) and are not solved. Unknown values are given with strings, e.g. 'x'. An example:

'isopleth_values':[[0.8,(0.1,0.2),'x'],['x',(0.1,0.2),1.0]]

#### 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}]