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

• Subject: [IDV #VNQ-937112]: A formula error for calculating relative humidity?
• Date: Thu, 30 Jan 2014 16:19:31 -0700

```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

Best Wishes,

Unidata IDV Support

> Full Name: dave
> 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

```