Skip to content
Snippets Groups Projects
Commit 176a9f16 authored by David Hoese's avatar David Hoese
Browse files

added dewpoint_array for deriving dewpoint

parent 0a8606f7
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ import math ...@@ -10,7 +10,7 @@ import math
from datetime import timedelta from datetime import timedelta
import fpconst import fpconst
from numpy import array, average, zeros, radians, degrees, arctan2, sin, cos, ndarray from numpy import array, average, zeros, radians, degrees, arctan2, sin, cos, ndarray, log
from numpy.ma import masked_array, average as masked_average, MaskedArray, masked_where, column_stack from numpy.ma import masked_array, average as masked_average, MaskedArray, masked_where, column_stack
from pydap.client import open_url as dapopen from pydap.client import open_url as dapopen
...@@ -166,6 +166,19 @@ def dewpoint(tempC, relhum): ...@@ -166,6 +166,19 @@ def dewpoint(tempC, relhum):
return min(dp - 273.15, tempC) return min(dp - 273.15, tempC)
def dewpoint_array(tempC, relhum):
"""Equivalent to the dewpoint function, but operates on numpy arrays.
:param tempC: temperature in celsius
:param relhum: relative humidity as a percentage
"""
gasconst = 461.5
latheat = 2500800.0
dp = 1.0 / ( 1.0 / ( 273.15 + tempC ) - gasconst * log( (0.0 + relhum) / 100 ) / \
( latheat - tempC * 2397.5 ))
return numpy.minimum(dp - 273.15, tempC)
def relhum(airTempK, dewpointTempK): def relhum(airTempK, dewpointTempK):
""" """
Algorithm derived by David Hoese from the above Algorithm derived by David Hoese from the above
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment