[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IDV #VNQ-937112]: A formula error for calculating relative humidity?



Dave,

The problem is that Math.exp expects a numeric type of double, but
somehow the IDV/Jython is providing a float (I guess).

I have been trying for the last hour to try to convert
17.67*t/(t+243.5) calculation to a double but I am unable to. You may
wish to ask address@hidden because I am out of ideas.

Best Wishes,

Unidata IDV Support

> Full Name: dave
> Email Address: address@hidden
> Organization: china, NMC
> Package Version: 5.0 build date:2014-01-18 08:05 UTC
> Operating System: Windows 7
> Hardware: Java: home: C:\Program Files\IDV_5.0\jre version: 1.6.0_43 
> j3d:1.5.2 fcs (build4)
> Description of problem: Hi,
> I write a jython function to calculate relative humidity, like this:
> 
> def bolton(t):
> """Estimates the saturation vapour pressure in hPa at a given temperature,
> T, in celcius"""
> # return saturation vapour pressure at a given temperature in celcius
> es = 6.112*Math.exp(17.67*t/(t+243.5))
> return es
> 
> def tdew2rh(tdew, t):
> """Calculate relative humidity from temperature and dew/frostpoint,
> tdew and t, in kelvin.
> writed by daikan, 2014/1/31.
> """
> return bolton(tdew-273.15)/bolton(t-273.15)*100.0
> 
> but when I run this function, I get the errors:
> 
> Creating display: Contour Plan View
> TypeError: exp(): 1st arg can't be coerced to double
> org.python.core.PyException
> 
> So, how can I solve this? Thanks!
> Dave
> 
> 


Ticket Details
===================
Ticket ID: VNQ-937112
Department: Support IDV
Priority: Normal
Status: Closed


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.