wmetpy

Download and install

Download the latest version as gzipped tarball and (for Linux) untar and install as root:

tar -xvzf wmetpy<-x.y.z-yyyy-mm-dd>.tar.gz
cd wmetpy<-x.y.z-yyyy-mm-dd>
sudo python3 setup.py install

Now the module can be used in python scripts by

import wmetpy

The module has never been tested with Windows, but it should work.

Meteorological constants and functions

Based on earlier versions of the module dating back to 2009 named admeteopy.

© Dietmar Thaler 2009-2019

Note

This module makes use of the numpy library. NumPy is the fundamental package for scientific computing with Python. Make sure you have it installed. See http://www.numpy.org/ and http://sourceforge.net/projects/numpy/


This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License. If not, see <http://www.gnu.org/licenses/gpl.html> .


wmetpy.c2k(tk)[source]

Converts temperature in Celsius to temperature in Kelvin

wmetpy.celsius2kelvin(tc)[source]

Converts temperature in Celsius to temperature in Kelvin

wmetpy.e_ice(t=0.0)[source]

Saturation water vapor over a plane frozen water (ice) surface (according http://cires.colorado.edu/~voemel/vp.html or http://cires.colorado.edu/~voemel/vp.html “Guide to Meteorological Instruments and Methods of Observation”, CIMO Guide, WMO 2008)

t … temperature t in C
e_ice … sat. water vapor in hPa
wmetpy.e_ice_p(t=0.0, p=1013.25)[source]

Saturation water vapor over ice with pressure correction. ANNEX 4.B. FORMULAE FOR THE COMPUTATION OF MEASURES OF HUMIDITY p. 163 (Guide to Meteorological Instruments and Methods of Observation, WMO, Geneva, 2014, 2017). - e_ice*f(p)

t … temperature t in C
p … pressure in hPa
e_ice_p … sat. water vapor in hPa
wmetpy.e_pot_temp(T, p, m)[source]

Equivalent potential temperature K

T … Temp in K
p … pressure in hPa
m … mixing ration in kg/kg (!)
e_pot_temp … equivalent potential temp. in K
wmetpy.e_pot_temp_bolton(Tk, Tl, p, m)[source]

Equivalent potential temperature K after Bolton(1980): The Computation of Eqivalent Potential Temperature (MWR Vol.108)

Tk … Temp in the starting level of ascend in K
Tl … Temp. in the lifting condensation level in K
p … pressure in hPa
m … mixing ration in kg/kg (!)
e_pot_temp_bolton … equivalent potential temp. in K
wmetpy.e_stefan_boltzmann(T, eps=1.0)[source]

Radiation flux density of a black or grey body (Stefan-Boltzmann law)

T …. temperature of the body [K]
eps .. emissivity <= 1, defaults to 1
e_stefan_boltzmann … emitted radiation flux density W/m^2/K^4
wmetpy.e_water(t=0.0)[source]

Saturation water vapor over a plane liqid water surface (according http://cires.colorado.edu/~voemel/vp.html or http://cires.colorado.edu/~voemel/vp.html Guide to Meteorological Instruments and Methods of Observation, CIMO Guide, WMO 2008)

t … temperature t in C
e_water … sat. water vapor in hPa
wmetpy.e_water_p(t=0.0, p=1013.25)[source]

Saturation water vapor over water with pressure correction. ANNEX 4.B. FORMULAE FOR THE COMPUTATION OF MEASURES OF HUMIDITY p. 163 (Guide to Meteorological Instruments and Methods of Observation, WMO, Geneva, 2014, 2017). - e_water*f(p)

t … temperature t in C
p … pressure in hPa
e_water_p … sat. water vapor in hPa
wmetpy.g_welmec(phi=45.0, z=0.0)[source]

WELMEC-formula for the caculation of gravity as function of latitude and height

phi … latitude in decimal grade (positive north)
z … height in meter
g_welmec… gravity in m/s^2
wmetpy.gpotheight(phi=45.0, z=0.0)[source]

Geopotential (ICAO-) height according to the WELMEC-formula for the caculation of gravity as function of latitude and height. gp(z) = integral(g(z)dz) from ground with z=0 to height z.

phi … latitude in decimal grade (positive north)
z … height in meter
gpotheight … geopotential in units of g0 (ICAO)
wmetpy.k2c(tk)[source]

Converts temperature in Kelvin to temperature in Ceslius

wmetpy.kelvin2celsius(tk)[source]

Converts temperature in Kelvin to temperature in Ceslius

wmetpy.l_evw(t=0.0)[source]

Latent heat of evaporation/condensation of water (vapor - liquid) valid from -40 to +40 C.

Cubic fit to Table 2.1,p.16, Textbook: R.R.Rogers & M.K. Yau, A Short Course in Cloud Physics, 3e,(1989), Pergamon press http://en.wikipedia.org/wiki/Latent_heat (2009-11-09) V 2009-11-09, (p) dietmar.thaler@gmx.at

T .. Temperature in C
l_evw .. Latent heat in J/kg as function of Temperature
wmetpy.m_mixingratio(e, p)[source]

mixing ratio as function of water-vapor pressure and air pressure

e … vapor pressur
p … air pressure
m_mixingratio … mixing ratio in kg/kg
wmetpy.p0_wmocimo2008(ps, Hp, ts, es)[source]

Pressure reduction to mean sealevel according to WMO CIMO Guide, Part I, Chapter 3 (Edition 2008, updated in 2010) http://www.wmo.int/pages/prog/www/IMOP/CIMO-Guide.html

ps … station pressure
Hp … station height in geopotential meter (local gravity correction)
ts … station temperature in C
es … station vapor presser in hPa
wmetpy.p_iso(p0, T0, z, g=9.80665)[source]

Isothermal atmosphere - pressure reduction

p0 .. pressure at level 0
T0 .. temperature in K
z .. thickness level in [m]
g .. gravity, defaults to g0
p_iso .. pressure at level z
wmetpy.p_poly(p0, T0, z, gamma, g=9.80665)[source]

Polytropic atmosphere - pressure reduction

p0 .. pressure at level 0
T0 .. temperature in K
z .. thickness level in [m]
gamma = -dT/dz .. vertical temperature gradient [K/m]
g .. gravity, defaults to standard gravity g0
p_poly .. pressure at level z
wmetpy.planck_black_body_fr(T, nu, eps=1.0)[source]

Planck thermal radiance as a function of

T … temparature of the body [K]
nu … frequency [Hz]
eps … spectral emissivity, 0 =< eps <=1
wmetpy.planck_black_body_wl(T, lam, eps=1.0)[source]

Planck thermal radiance as a function of

T .. temparature of the body [K]
lam .. wavelenghth [m]
eps .. spectral emissivity, 0 =< eps <=1
wmetpy.pot_temp(T, p)[source]

Potential temperatur as function of temperature and pressure (reduction to ps=1000.0 hpa)

T .. temperatur of dry air [K]
p .. pressure of air [hPa !!!]
pot_temp .. pot. Temp. [K]
wmetpy.q_spechum(e, p)[source]

Specific humidity as function of water-vapor pressure and air pressure

e … vapor pressure
p … air pressure
q_spechum … specific humidity in kg/kg
wmetpy.sat_mixingratio_water(T, p)[source]

Saturation mixing ratio as function of temperature and air pressure

T … Temperature in C
p … Pressure in hPa
sat_mixingratio_water .. Saturation mixing ratio
wmetpy.showalter_index_bolton1(t_lower, t_upper, td_lower, p_lower=850.0, p_upper=500.0)[source]

Showalter index [C] as a function of pressure, temperature and dewpoint at the lower level and pressure and temperature at the upper level. Calculation is done according to Bolton(1980): “The Computation of Eqivalent Potential Temperature” (MWR Vol.108). Terminates with an error message when there is no convergence within 100 iterations.

t_lower … temperature at p_lower in C
t_upper … temperature at p_upper in C
td_lower … dewpoint temperature at p_lower in C
p_lower … pressure at the lower level in hPa
p_upper … pressure at the upper level in hPa
showalter_index_bolton1 … Showalter Index (SWI) in C

SWI = Temp at the upper level - Showalter temperature for the upper level

wmetpy.showalter_temperature_bolton1(ThetaE, p, tswi)[source]

Showalter temperature [C] as a function of the eqivalent-potential temperature according to Bolton(1980): “The Computation of Eqivalent Potential Temperature” (MWR Vol.108) and pressure. Terminates with an error message when there is no convergence within 100 iterations.

ThetaE … equivalent (pseudo-) potential temp.
p … pressure in hPa
tswi … start value for the Showalter temperature as 0th-approximation
[C]
showalter_temperature_bolton1 … Showalter temperature [C]
wmetpy.t_lifting_condensation_level_bolton1(Tk, Td)[source]

Lifting condensation according to Bolton(1980): “The Computation of Eqivalent Potential Temperature” (MWR Vol.108)

Tk … Temp in the starting level of ascend in K
Td … Dewpoint Temp. in the starting in the starting level of ascend
in K
p … pressure in hPa
m … mixing ration in kg/kg (!)
t_lifting_condensation_level_bolton1 … lift. condens.level in K
wmetpy.t_virt(T, q)[source]

Virtual Temperatur as function of air temperature and spezific humidity

T … air temperature [K]
q … spezific humidity [kg/kg]
t_virt … virtual temperature [K]
wmetpy.t_virt2(t, td, p)[source]

Virtual Temperature as function of temp., dewpoint and pressure

t … temp. in C(!)
td … dewpoint temp. in C(!)
p … air pressure in hPa
t_virt2 … virtual temp. in K(!)
wmetpy.wind_dd2phi(dd)[source]

Converts meteorological wind direction dd in degrees into the mathematical direction phi in degrees.

wmetpy.wind_ddff2uv(dd, ff)[source]

Convert wind given in (meteorological) direction 0..360 and speed to its x- and y-components u and v

wmetpy.wind_equal_hh_field(h0, h1, dh)[source]

Returns an equidistant hh-field starting with h0, ending with h1, stepping dh.

wmetpy.wind_input_csv(infile)[source]

Reads input file with height and wind data with following format: hhhh; dddd; ffff hhhh: dddd; ffff ..; ..; .. with increasing height, dddd as meteorological direction and ffff in arbitrary units separated by a semicolon ‘;’ and EOL at the end of a line. Values in integer or floats, read as floats. Returns numpy arrays with height hh, direction dd and speed ff.

wmetpy.wind_interpolate_uv(h0, h1, dh, hh, uu, vv)[source]

h0 .. lower interpolation boundary h1 .. upper interpolation boundary, dh .. interpolation intervall hh .. height array for measured values uu, vv .. cartesian wind component arrays at hh

Returns interpolated arrays hn .. heights, un, vn .. cartesian wind components

wmetpy.wind_kmh2kt(v)[source]

km/h to knots

wmetpy.wind_kmh2ms(v)[source]

km/h to m/s

wmetpy.wind_kt2kmh(v)[source]

Knots to km/h

wmetpy.wind_kt2ms(v)[source]

knots 2 m/s

wmetpy.wind_mean_uv(hh, uh, vh)[source]

Calculates from an height and cartesian wind component field arithmetic mean component fields. All field entries are treated equally

wmetpy.wind_mean_uv_equidistant(uh, vh)[source]

Calculates from an height and cartesian wind component field the arithmetic mean component fields for an equidistant windfield. All field entries are treated equally

wmetpy.wind_ms2kmh(v)[source]

m/s to km/h

wmetpy.wind_ms2kt(v)[source]

m/s to knots

wmetpy.wind_phi2dd(phi)[source]

Converts mathematical wind direction phi in degrees into the meteorological direction ddd in degrees.

wmetpy.wind_plot_uv(hh, uu, vv, outpic='uv_h.png', title='Windcomponents as function of height', show=False)[source]

Plots wind data

hh .. array with height array
uu .. array with cartesian-x componet of wind
vv .. array with cartesian y-component of wind

Returns None
wmetpy.wind_print_huv(comment, h, u, v)[source]

Text output for a cartesian wind field and conversion to meteorological dd,ff components

wmetpy.wind_print_raw(comment, hh, dd, ff)[source]

Text output for measured raw wind data

wmetpy.wind_single_w_inter(hx, hh, ww)[source]

“Linear interpolation between sampling points For hx lower then the (geometrically)lowest entry is set to the lowest entry, for hx higher then the (geometrically) highes entry is set to the highes entry, meaning constant interpolation beyond the boundaries.

wmetpy.wind_uv2ddff(u, v)[source]

Convert wind given in x- and y-components u and v to the (meteorological) direction 0..360 and speed.

wmetpy.z_iso(T0, p0, p1, g=9.80665)[source]

Isothermal atmosphere - thickness

p0 .. pressure at level 0
p1 .. pressure at level 1
T0 .. temperature in K
g .. gravity, defaults to standard gravity g0
z_iso .. thickness between level 1 an 0 in [m]
wmetpy.z_poly(T0, p0, p1, gamma, g=9.80665)[source]

Polytropic atmosphere - thickness

p0 .. pressure at level 0
p1 .. pressure at level 1
T0 .. temperature in K
gamma=-dT/dz .. vertical temperature gradient [K/m]
g .. gravity, defaults to standard gravity g0
z_poly .. thickness between level 1 an 0 in [m]
wmetpy.z_poly2(T0, p0, T1, p1, g=9.80665)[source]

Polytropic atmosphere - thickness

p0 .. pressure at level 0
p1 .. pressure at level 1
T0 .. temperature in K in level 0
T1 .. temperature in K in level 1
g .. gravity, defaults to standard gravity g0
z_poly2 .. thickness between level 1 an 0 in [gpm]