Difference between revisions of "Temperature converter"

From Pynomo
Jump to: navigation, search
(New page: {{Infobox_general | name = Celcius Fahrenheit converter | image = 150px | Field1a =author | Field1b =Leif Roschier }} == Theory and background == Relation b...)
 
m (Source code)
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
 
== Theory and background ==
 
== Theory and background ==
 
Relation between Celcius degrees <math>T_C</math> and Fahrenheit degrees <math>T_F</math> of temperature is
 
Relation between Celcius degrees <math>T_C</math> and Fahrenheit degrees <math>T_F</math> of temperature is
<ref><http://en.wikipedia.org/wiki/Comparison_of_temperature_scales/ref>
+
<ref><http://en.wikipedia.org/wiki/Comparison_of_temperature_scales</ref>
  
 
<math>T_C = \frac{5}{9}(T_F-32)</math>
 
<math>T_C = \frac{5}{9}(T_F-32)</math>
Line 46: Line 46:
 
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
"""
 
"""
from nomographer import *
+
from pynomo.nomographer import *
 
F_start=-40.0
 
F_start=-40.0
 
F_stop=90.0
 
F_stop=90.0

Latest revision as of 18:19, 7 October 2008

Celcius Fahrenheit converter
Ex temp converter.png
author Leif Roschier

Theory and background

Relation between Celcius degrees [math]T_C[/math] and Fahrenheit degrees [math]T_F[/math] of temperature is [1]

[math]T_C = \frac{5}{9}(T_F-32)[/math]

Construction of the nomograph

Dual scale was constructed by using type 8 singular blocks.

References

  1. <http://en.wikipedia.org/wiki/Comparison_of_temperature_scales

Generated nomograph

Celcius Fahrenheit converter
Ex temp converter.png
Generated portable document file (pdf): File:Ex temp converter.pdf

Source code

"""
    ex_temp_convert.py
 
    Celcius-Fahrenheit converter
 
    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 pynomo.nomographer import *
F_start=-40.0
F_stop=90.0
C_start=-40.0
C_stop=30.0
 
def celcius(fahrenheit):
    return (fahrenheit-32.0)/1.8
 
F_para={
        'tag':'A',
        'u_min':F_start,
        'u_max':F_stop,
        'function':lambda u:celcius(u),
        'title':r'$^\circ$ F',
        'tick_levels':4,
        'tick_text_levels':3,
        'align_func':celcius,
        'title_x_shift':0.5
        }
 
C_para={
        'tag':'A',
        'u_min':C_start,
        'u_max':C_stop,
        'function':lambda u:u,
        'title':r'$^\circ$ C',
        'tick_levels':5,
        'tick_text_levels':3,
        'scale_type':'linear',
        'tick_side':'left',
        'title_x_shift':-0.5
}
 
C_block={
         'block_type':'type_8',
            'f_params':C_para
         }
F_block={
         'block_type':'type_8',
            'f_params':F_para
            }
 
main_params={
              'filename':'ex_temp_converter.pdf',
              'paper_height':20.0,
              'paper_width':2.0,
              'block_params':[C_block,F_block],
              'transformations':[('scale paper',)]
              }
Nomographer(main_params)