Weather Calculations with heavy math

# Thread: Weather Calculations with heavy math

1. ## Weather Calculations with heavy math

I am reading a temp sensor and want to calculate the saturation pressure of water vapor. Below is the formula.

One question, how in the hell am I going to do this?

=6.1078*(0.99999683+TempF*(-0.0090826951+TempF*(0.000078736169+TempF*(-0.00000061117958+TempF*(0.0000000043884187+TempF*(-0.000000000029883885+TempF*(2.1874425E-13+TempF*(-1.7892321E-15+TempF*(1.1112018E-17+TempF*(-3.0994571E-20))))))))))^-8

2. Originally Posted by Tobias
I am reading a temp sensor and want to calculate the saturation pressure of water vapor. Below is the formula.

One question, how in the hell am I going to do this?

=6.1078*(0.99999683+TempF*(-0.0090826951+TempF*(0.000078736169+TempF*(-0.00000061117958+TempF*(0.0000000043884187+TempF*(-0.000000000029883885+TempF*(2.1874425E-13+TempF*(-1.7892321E-15+TempF*(1.1112018E-17+TempF*(-3.0994571E-20))))))))))^-8
This post calculates dew point: http://www.picbasic.co.uk/forum/show...8155#post58155
Does that help, or am I way of base?

There are also some simplified equations for water vapor here: http://www.conservationphysics.org/atmcalc/atmoclc2.pdf
Last edited by ScaleRobotics; - 5th January 2011 at 05:38.

3. Thanks for the info. I am not sure if that is the same as dew point. I have a weather geek friend I am helping out with this project. I will check with him in the morning.

4. Originally Posted by Tobias
One question, how in the hell am I going to do this?
Floating Point Numbers should do it.

http://melabs.com/resources/fp.htm

Robert

5. Hi, Tobias

let's take it easy ...

your temp probably may be > -10°C and < 40°C ... right ???

make a 50°C range.

current thermometer sensors give a +/- 0.5°C PRECISION

so, ...

a 100 points retrieve table may be enough !!! PBP allows you 255 points !

if wanting more " whistles and bells " ... It will be easy to use an interpolation between table values ... and show for 1/10th of degree !!!

Soooooo simple !!!

don't you think ???

Alain

6. Originally Posted by Tobias
I am reading a temp sensor and want to calculate the saturation pressure of water vapor. Below is the formula.

One question, how in the hell am I going to do this?

=6.1078*(0.99999683+TempF*(-0.0090826951+TempF*(0.000078736169+TempF*(-0.00000061117958+TempF*(0.0000000043884187+TempF*(-0.000000000029883885+TempF*(2.1874425E-13+TempF*(-1.7892321E-15+TempF*(1.1112018E-17+TempF*(-3.0994571E-20))))))))))^-8
Use Excel spreadsheet to generate a table of results for the desired temperature range, import the table into your code, use a lookup function to retreive the value relative to your temp reading.

7. damn good ideas guys
Thank you

8. I used a lookup table for the first math formula I posted and again a great idea. Amazing how simple things work so much better than complicated ones.

This is my first shot using the FP routines and I am trying to sort out an overflow problem. First off, I have MSP 3.0.0.5, compilier PBP 2.60L and an 18F4620 PIC.

Maybe I am interpreting the readme file in the FP.zip file incorrectly. The way I understand it is when using the FP1832L.BAS file I can use numbers larger than 65535. If that is correct I have something wrong with the code below because when the result of a fpmul routine is larger than 65535 the numbers start again at zero.

Code:
```define osc 20
Include "modedefs.bas"	' Mode definitions for Serout
include "fp1832l.bas"   ' Include file for 18xxxx (32-bit, PBPL.EXE)

Prefix          con      \$FE             ' needed before each command
LcdCls          CON      \$51             ' clear LCD (use PAUSE 5 after)
LcdLine1        CON      \$00             ' move cursor to line 1
LcdLine2        con      \$40             ' move curson to line 2
LcdLine3        con      \$14             ' move curson to line 3
lcdLine4        con      \$54             ' move curson to line 4
LcdCol1         con      \$00             ' move cursor to column 1
LcdCol2         con      \$07             ' move cursor to column 7
LcdCR           CON      \$0D             ' move pos 0 of next line
LcdOn           CON      \$41             ' LCD on; cursor off, blink off
LcdHome         con      \$46
Backlight       con      \$53             ' Backlighting 1-8
Contrast        con      \$52             ' Contrast 1-50
CursorPS        con      \$45             'Cursor Position
CursorOn        con      \$47             'Cursof On
CursorOff       con      \$48             'Cursor Off
BackSpace       CON      \$4E             'Backspace
UnderlineOn     con      \$47
UnderlineOff    con     \$48

LCD             VAR      PortC.6         'LCD output

Inlet           var      word
RH              Var      word
RH1             var      Word            'Used for math purposes
Baro            var      word
Baro1           var      word            'Used for math purposes
Temp            var      word
Temp2           var      word            'Used for math purposes
CurPos          var      word
SAP             var      word            'Saturation Pressure
AVP             var      word            'Actual Vapor Pressure
DAVP            var      word            'Dry Ait Vapor Pressure
WAVP            var      word            'Wet Air Vapor Pressure
DAD             var      word            'Dry Air Density
WVD             var      word            'Water Vapor Density
WAD             var      word            'Wet Air Density

Serout2 LCD, 84, [Prefix,LcdCLS]
Temp = 500
Temp2 = (Temp/10)-50
Lookup2 Temp2,[1227,1274,1322,1371,1422,1475,1530,1586,1644,1704,1766,1830,1896,1964,2034,2107, _
2181,2258,2337,2419,2503,2590,2679,2771,2866,2963,3064,3167,3273,3383,3496,3612, _
3731,3854,3980,4110,4243,4380,4522,4667,4816,4969,5126,5288,5454,5625,5800,5980, _
6165,6355,6550,6750,6955,7166,7383,7605,7833,8066,8306,8553],SAP

RH = 600
RH1 = RH/10
aint = RH1
Gosub itofa     ' Convert int to float
bint = SAP
Gosub itofb     ' Convert int to float
Gosub fpmul
Gosub ftoia
AVP = aint      'AVP = ((RH)*SAP)
'RH1   SAP    AVP(code)    AVP(real)
'Results  600    1227   8084         73620
'500    1227   61350        61350

Serout LCD, T9600,[Prefix,CursorPS,0,#RH1, " ", #SAP, " ", #AVP]
stop```

9. You would need LONG variables to hold values larger than 65535.

But you certainly don't need the floating point routines for the math you're doing.

10. Thanks, the floating point part is the next step. I was just using some simple math to check the results.

11. The Long helped and I learned tonite that I needed to use Serout2 to get the correct number to display. It took a few beers to sort it out. Thanks for pointing me to the Long.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts