Library of functions for meteorology.
- cp_calc: Calculate specific heat
- Delta_calc: Calculate slope of vapour pressure curve
- es_calc: Calculate saturation vapour pressures
- ea_calc: Calculate actual vapour pressures
- gamma_calc: Calculate psychrometric constant
- L_calc: Calculate latent heat of vapourisation
- pottemp: Calculate potential temperature (1000 hPa reference pressure)
- rho_calc: Calculate air density
- sun_NR: Maximum sunshine duration [h] and extraterrestrial radiation [J/day]
- vpd_calc: Calculate vapour pressure deficits
- windvec: Calculate average wind direction and speed
Module requires and imports math and scipy modules.
Tested for compatibility with Python 2.7.
Function to calculate the slope of the temperature - vapour pressure curve (Delta) from air temperature T:
where es is the saturated vapour pressure at temperature T.
References
Technical regulations 49, World Meteorological Organisation, 1984. Appendix A. 1-Ap-A-3.
Examples
>>> Delta_calc(30.0)
243.34309166827094
>>> x = [20, 25]
>>> Delta_calc(x)
array([ 144.6658414 , 188.62504569])
Function to calculate the latent heat of vapourisation from air temperature.
References
J. Bringfelt. Test of a forest evapotranspiration model. Meteorology and Climatology Reports 52, SMHI, Norrköpping, Sweden, 1986.
Examples
>>> L_calc(25)
2440883.8804625
>>> t=[10, 20, 30]
>>> L_calc(t)
array([ 2476387.3842125, 2452718.3817125, 2429049.3792125])
Function to calculate the specific heat of air:
where ea is the actual vapour pressure calculated from the relative humidity and p is the ambient air pressure.
References
R.G. Allen, L.S. Pereira, D. Raes and M. Smith (1998). Crop Evaporation Guidelines for computing crop water requirements, FAO - Food and Agriculture Organization of the United Nations. Irrigation and drainage paper 56, Chapter 3. Rome, Italy. (http://www.fao.org/docrep/x0490e/x0490e07.htm)
Examples
>>> cp_calc(25,60,101300)
1014.0749457208065
>>> t = [10, 20, 30]
>>> rh = [10, 20, 30]
>>> airpress = [100000, 101000, 102000]
>>> cp_calc(t,rh,airpress)
array([ 1005.13411289, 1006.84399787, 1010.83623841])
Function to calculate actual vapour pressure from relative humidity:
where es is the saturated vapour pressure at temperature T.
Examples
>>> ea_calc(25,60)
1900.0946514729308
Function to calculate saturated vapour pressure from temperature.
For T<0 C the saturation vapour pressure equation for ice is used accoring to Goff and Gratch (1946), whereas for T>=0 C that of Goff (1957) is used.
References
Examples
>>> es_calc(30.0)
4242.725994656632
>>> x = [20, 25]
>>> es_calc(x)
array([ 2337.08019792, 3166.82441912])
Function to calculate the psychrometric constant gamma.
where p is the air pressure and lambda the latent heat of vapourisation.
References
J. Bringfelt. Test of a forest evapotranspiration model. Meteorology and Climatology Reports 52, SMHI, Norrköpping, Sweden, 1986.
Examples
>>> gamma_calc(10,50,101300)
66.26343318657227
>>> t = [10, 20, 30]
>>> rh = [10, 20, 30]
>>> airpress = [100000, 101000, 102000]
>>> gamma_calc(t,rh,airpress)
array([ 65.25518798, 66.65695779, 68.24239285])
A libray of functions for calculation of micrometeorological parameters.
This is the help function which prints a list of functions and contact information about the author, version and last modification date.
Function to calculate the potential temperature air, theta, from air temperatures, relative humidity and air pressure. Reference pressure 1000 hPa.
Examples
>>> t = [5, 10, 20]
>>> rh = [45, 65, 89]
>>> airpress = [101300, 102000, 99800]
>>> pottemp(t,rh,airpress)
array([ 3.97741582, 8.40874555, 20.16596828])
>>> pottemp(5,45,101300)
3.977415823848844
Function to calculate the density of air, rho, from air temperatures, relative humidity and air pressure.
Examples
>>> t = [10, 20, 30]
>>> rh = [10, 20, 30]
>>> airpress = [100000, 101000, 102000]
>>> rho_calc(t,rh,airpress)
array([ 1.22948419, 1.19787662, 1.16635358])
>>> rho_calc(10,50,101300)
1.2431927125520903
Function to calculate the maximum sunshine duration [h] and incoming radiation [MJ/day] at the top of the atmosphere from day of year and latitude.
Returns: - N: (float, array) maximum sunshine hours [h]. - Rext: (float, array) extraterrestrial radiation [J day-1].
Notes
Only valid for latitudes between 0 and 67 degrees (i.e. tropics and temperate zone).
References
R.G. Allen, L.S. Pereira, D. Raes and M. Smith (1998). Crop Evaporation - Guidelines for computing crop water requirements, FAO - Food and Agriculture Organization of the United Nations. Irrigation and drainage paper 56, Chapter 3. Rome, Italy. (http://www.fao.org/docrep/x0490e/x0490e07.htm)
Examples
>>> sun_NR(50,60)
(9.1631820597268163, 9346987.824773483)
>>> days = [100,200,300]
>>> latitude = 52.
>>> sun_NR(days,latitude)
(array([ 13.31552077, 15.87073276, 9.54607624]), array([ 29354803.66244921, 39422316.42084264, 12619144.54566777]))
Function to calculate vapour pressure deficit.
Examples
>>> vpd_calc(30,60)
1697.090397862653
>>> T=[20,25]
>>> RH=[50,100]
>>> vpd_calc(T,RH)
array([ 1168.54009896, 0. ])
Function to calculate the wind vector from time series of wind speed and direction.
Examples
>>> u = scipy.array([[ 3.],[7.5],[2.1]])
>>> D = scipy.array([[340],[356],[2]])
>>> windvec(u,D)
(4.162354202836905, array([ 353.2118882]))
>>> uv, Dv = windvec(u,D)
>>> uv
4.162354202836905
>>> Dv
array([ 353.2118882])
Functions for calculation of potential and actual evaporation from meteorological data.
- E0: Calculate Penman (1948, 1956) open water evaporation.
- Em: Calculate evaporation according to Makkink (1965).
- Ept: Calculate evaporation according to Priestley and Taylor (1972).
- ET0pm: Calculate Penman Monteith reference evaporation short grass.
- Epm: Calculate Penman-Monteith evaporation (actual evapotranspiration).
- ra: Calculate aerodynamic resistance from windspeed and roughnes parameters.
- tvardry: calculate sensible heat flux from temperature variations.
- gash79: Gash (1979) analytical rainfall interception model.
Requires and imports scipy and meteolib modules. Compatible with Python 2.7.3.
Function to calculate daily Penman (open) water evaporation estimates:
Notes
Meteorological parameters measured at 2 m above the surface. Albedo alpha set by default at 0.08 for open water (Valiantzas, 2006).
References
Examples
>>> # With single values and default albedo/elevation
>>> E0(20.67,67.0,101300.0,22600000.,42000000.,3.2)
6.6029208786994467
>>> # With albedo is 0.18 instead of default and default elevation
>>> E0(20.67,67.0,101300.0,22600000.,42000000.,3.2,alpha=0.18)
5.9664248091431968
>>> # With standard albedo and Z= 250.0 m
>>> E0(20.67,67.0,101300.0,22600000.,42000000.,3.2,Z=250.0)
6.6135588207586284
>>> # With albedo alpha = 0.18 and elevation Z = 1000 m a.s.l.
>>> E0(20.67,67.0,101300.0,22600000.,42000000.,3.2,0.18,1000.)
6.00814764682986
Function to calculate daily Penman Monteith reference evaporation estimates.
Notes
Meteorological measuements standard at 2 m above soil surface.
References
R.G. Allen, L.S. Pereira, D. Raes and M. Smith (1998). Crop evapotranspiration - Guidelines for computing crop water requirements - FAO Irrigation and drainage paper 56. FAO - Food and Agriculture Organization of the United Nations, Rome, 1998. (http://www.fao.org/docrep/x0490e/x0490e07.htm)
Examples
>>> ET0pm(20.67,67.0,101300.0,22600000.,42000000.,3.2)
4.7235349721073039
Function to calculate Makkink evaporation (in mm/day):
The Makkink evaporation is a reference crop evaporation. It is a reference crop evaporation equation based on the Penman open water equation and represents evapotranspiration from short, well-watered grassland under Dutch climate conditions. Makkink reference evaporation values are published daily by the Royal Netherlands Meteorological Institute (KNMI) in the Netherlands. Values are used in combination with crop factors to provide daily estimates of actual crop evaporation for many crop types.
Notes
Meteorological measurements standard at 2 m above soil surface.
References
H.A.R. de Bruin (1987). From Penman to Makkink, in Hooghart, C. (Ed.), Evaporation and Weather, Proceedings and Information. Comm. Hydrological Research TNO, The Hague. pp. 5-30.
Examples
>>> Em(21.65,67.0,101300.,24200000.)
4.503830479197991
Function to calculate the Penman Monteith evaporation.
The function can be used with different time intervals, such as commonly used hourly or daily time intervals are used. When a plant canopy is wet, the surface resistance (rs) becomes zero (stomatal resistance irrelevant, as evaporation is directly from wet leaf surface). Function ra() in this module can be used to calculate the aerodynamic resistance (ra) from wind speed and height parameters.
References
J.L. Monteith (1965). Evaporation and environment. Symp. Soc. Exp. Biol. 19: 205-224.
Examples
>>> Epm(21.67,67.0,1013.0,14100000.,500000.,104.,70.)
3.243341146049407
Function to calculate daily Priestley - Taylor evaporation:
where alpha is set to 1.26.
Notes
Meteorological parameters normally measured at 2 m above the surface.
References
Priestley, C.H.B. and R.J. Taylor, 1972. On the assessment of surface heat flux and evaporation using large-scale parameters. Mon. Weather Rev. 100:81-82.
Examples
>>> Ept(21.65,67.0,101300.,18200000.,600000.)
6.349456116128078
Evaplib: A libray with Python functions for calculation of evaporation from meteorological data.
Function to calculate precipitation interception loss from daily precipitation values and and vegetation parameters.
References
J.H.C. Gash, An analytical model of rainfall interception by forests, Quarterly Journal of the Royal Meteorological Society, 1979, 105, pp. 43-55.
Examples
>>> gash79(12.4,0.15,1.3,0.2,0.2,0.02)
(12.4, 8.4778854123725971, 0, 3.9221145876274024)
>>> gash79(60.0,0.15,1.3,0.2,0.2,0.02)
(60.0, 47.033885412372598, 0, 12.966114587627404)
Function to calculate aerodynamic resistance from windspeed:
where k is the von Karman constant set at 0.4.
References
A.S. Thom (1075), Momentum, mass and heat exchange of plant communities, In: Monteith, J.L. Vegetation and the Atmosphere, Academic Press, London. p. 57–109.
Examples
>>> ra(3,0.12,2.4,5.0)
3.2378629924752942
>>> u=([2,4,6])
>>> ra(3,0.12,2.4,u)
array([ 8.09465748, 4.04732874, 2.69821916])
Function to calculate the sensible heat flux from high frequency temperature measurements and their standard deviation:
Notes
This function holds only for free convective conditions when C2*z/L >>1, where L is the Obhukov length.
References
Examples
>>> tvardry(1.25,1035.0,25.3,0.25,3.0)
34.658669290185287
>>> displ_len=0.25
>>> tvardry(1.25,1035.0,25.3,0.25,3.0,d=displ_len)
33.183149497185511
>>> tvardry(1.25,1035.0,25.3,0.25,3.0,d=displ_len,C2=30)
34.10507908798597
A library of miscellaneous functions for meteorological data processing.
- event2time: Convert (event) based measurements into equidistant time spaced data for a selected interval
- date2doy: Calculates day of year from day, month and year data.
The module requires and imports scipy and datetime modules. Tested for compatibility with Python 2.7.3.
Function to calculate the julian day (day of year) from day, month and year.
Examples
>>> date2doy(04,11,2006)
308
>>> date2doy(04,11,2008)
309
>>> day=[10,10,10]
>>> month=[1,2,3]
>>> year=[2007,2008,2009]
>>> date2doy(day,month,year)
array([ 10., 41., 69.])
>>>
Function to convert (event-based) time series data to equidistant time spaced data at a specified interval.
The maximum interval for processing is 86400 s, resulting in daily values. You can choose to sum (e.g. for event-based rainfall measurements) or average the input data over a given time interval. If you choose to average, a -9999 value (missing value) will be output if there are no data in the specified interval. For summation, a zero will be output, as required for event-based rainfall measurements.
Examples
>>> year=[2008,2008,2008]
>>> daytime=[153.5,153.9,154.1]
>>> vals=[0,0.4,2.]
>>> event2time(year,daytime,vals,'sum',3600)
(array([2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008]), array([ 153.58333333, 153.625 , 153.66666667, 153.70833333,
153.75 , 153.79166667, 153.83333333, 153.875 ,
153.91666667, 153.95833333, 154. , 154.04166667,
154.08333333]), array([ 0.4, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 2. , 0. , 0. ,
0. , 0. ]))
>>> yr,day_time,sum_P = event2time(year,daytime,vals,'sum',3600)
>>> yr
array([2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008])
>>> sum_P
array([ 0.4, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 2. , 0. , 0. ,
0. , 0. ])