comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Calculating Sat. water vapor pressure from air temperature: What is wrong?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Calculating Sat. water vapor pressure from air temperature: What is wrong? [message #53309] Wed, 04 April 2007 23:34
kim20026 is currently offline  kim20026
Messages: 54
Registered: November 2006
Member
Thanks, Lasse and Paul. I made it!!!

Harry
Re: Calculating Sat. water vapor pressure from air temperature: What is wrong? [message #53315 is a reply to message #53309] Wed, 04 April 2007 00:53 Go to previous message
krum is currently offline  krum
Messages: 1
Registered: April 2007
Junior Member
Hi Harry,

I think your problem is with this line:
tem0 = tem/10 - 273.3 ; for unit conversion from celcius into K.
If converting from degree C into Kelvins then should add 273.3:
tem0 = tem/10. + 273.3

Cheers, Paul
Re: Calculating Sat. water vapor pressure from air temperature: What is wrong? [message #53326 is a reply to message #53315] Tue, 03 April 2007 05:03 Go to previous message
lasse is currently offline  lasse
Messages: 48
Registered: February 2007
Member
On 3 Apr, 01:53, "DirtyHarry" <kim20...@gmail.com> wrote:
> Goodday, everyone. I came with a new question. Please take a look at
> this code.
>
> I am going to calculate saturated water vapor pressure from air
> temperature using clausius-clapeyron equation.
> The air temperature is on tem(4:27, *) in my test.txt below.
>
> ;site_id year month day h01 h02 h03 h04 h05 h06 h07 h08 h09 h10 h11
> h12 h13 h14 h15 h16 h17 h18 h19 h20 h21 h22 h23 h24
> ; 90 2003 1 1 -53 -21 -22 -38 -44 -52 -50
> -51 -23 -12 -6 1 1 13 6 4 -13 -19
> -29 -34 -43 -59 -59 -61
> ; 90 2003 1 2 -71 -65 -76 -69 -70 -73 -67
> -69 -43 -9 4 6 14 9 21 14 0 -5
> -7 -15 -17 -13 -10 -24
> ; 90 2003 1 3 -17 -7 -6 -14 -23 -9 -16
> -11 -19 4 13 17 24 15 9 5 -9 -19
> -19 -25 -33 -41 -50 -52
> .
> .
> .
>
> I want to keep the first 1 to 4 columns and change 4 to 28 columns
> with this equation.
>
> tem0 = tem/10 - 273.3 ; for unit conversion from celcius into K.
> SatVP = 6.11*exp(19.59*(tem0-273.3)/tem0) ; modified clausius-
> clapeyron equation.
>
> So, I tried this way.
> ---------------------------------
> pro SatVPNWS
>
> file = 'test.txt'
> ndata = file_lines(file) ;number of lines in data file
> site_num = 72 ; NATIONAL WEATHER STATION IN KOREA
> tem = intarr(28, ndata)
> tem0 = tem/10 - 273.3
> SatVP = 6.11*exp(19.59*(tem0-273.3)/tem0)
>
> close, 1
> openr, 1, file ;reading air temperature measured in NWS
> readf, 1, tem
> close, 1
>
> openw,2, 'SatVP_00.txt'
> for j=0,ndata-1 do begin
> printf, 2, tem[0:3,j], satVP[4:27,j] , format = '(4i6,2x,24F8.3,
> 2x)'
> endfor
> close, 2
>
> end
> -----------------------------
>
> and this is the SatVP_00.txt
>
> 90 2003 1 1
> ************************************************************ ************************************************************ ************************************************************ *************
> 90 2003 1 2
> ************************************************************ ************************************************************ ************************************************************ ************
> 90 2003 1 3
> ************************************************************ ************************************************************ ************************************************************ ************
>
> There must be something wrong, but I don't know what is it exactly.
> Firstly, I suspected the format statement. I changed the parmeters and
> ran again and again, but the results were always same.
>
> Please give me some suggestions for correct format for this case, and
> check if I make other mistakes. Thanks.
>
> Harry

Hi,

lots of stars when using format codes points to the fact that the
number cannot be formatted. Whenever I see lots of stars, I completely
take away the format code (or stop drinking, chichichi). Then see what
IDL prints and decide what a good format code is.

For the value tem = 41, your formula yields SatVp to be 4.77502e+17
and that's the reason why you cannot use a format code like F8.3. The
reason why you are getting values like the above is that in the
formula for SatVP you are again substracting 273.3 which you have
already done once before.

Also I noticed:

tem = intarr(28, ndata)
tem0 = tem/10 - 273.3

You are loosing one order of magnitude precision here, because you
divide by an integer, hence 41/10 will give you 4 as opposed to 4.1
which is, probably, want you really want. Divide by a float like so

tem0 = tem/10. - 273.3

and you're good because IDL will take care of the type conversion. If
you do want to loose the one digit, ignore this comment.

Cheers
Lasse
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Does IDL have a EOF(empirical orthogonal function)?
Next Topic: Combining rgb fits files

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:47:04 PDT 2025

Total time taken to generate the page: 0.00478 seconds