small tools package

DocStrings

class dypy.small_tools.CrossSection(variables, coo, pressure, int2p=False, int2z=False, flip=False, pollon=-170, pollat=43, nbre=1000, order=1)[source]

Create a cross-section

return the distance, the pressure levels, and the variables.

Parameters:
  • variables (dictionary) – A dictionary of the variables with the following structure {‘name’: np.array}, need to contain as least rlat, rlon
  • coo (list or numpy.ndarray) – If coo is a list of coordinates, it is used of the starting and end points: [(startlon, startlat), (endlon, endlat)] If coo is a numpy.ndarray it is used as the cross-section points. coo need then to be similar to : np.array([[10, 45], [11, 46], [12, 47]])
  • pressure (np.array) – pressure coordinate as 1D array
  • int2p (bool, optional (default: False)) – True if variables need to be interpolated on pressure levels, requires p in the variables, the levels are given by pressure
  • int2z (bool, optional (default: False)) – True if variables need to be interpolated on heights levels, requires z in the variables, the levels are given by pressure may require `flip`=True
  • flip (bool, optional (default: False)) – True if variables need to be flip vertically, the first dimension of 3D array will be flipped
  • pollon (float, optional (default: -170)) – pole_longitude of the rotated grid
  • pollat (float, optional (default: 43)) – pole_latitude of the rotated grid
  • nbre (int, optional (default: 10000)) – nbre of points along the cross-section
  • order ({1, 2, 3, 4}, optional (default: 1)) – order of interpolation see for details
dypy.small_tools.interpolate(data, grid, interplevels)[source]

intrerpolate data to grid at interplevels data and grid are numpy array in the form (z,lat,lon)

dypy.small_tools.rotate_points(pole_longitude, pole_latitude, lon, lat, direction='n2r')[source]

rotate points from non-rotated system to rotated system n2r : non-rotated to rotated (default) r2n : rotated to non-rotated return rlon,rlat,

dypy.small_tools.dewpoint(p, qv)[source]

Calculate the dew point temperature based on p and qv following (eq.8): Lawrence, M.G., 2005. The Relationship between Relative Humidity and the Dewpoint Temperature in Moist Air: A Simple Conversion and Applications. Bulletin of the American Meteorological Society 86, 225–233. doi:10.1175/BAMS-86-2-225

dypy.small_tools.esat(t)[source]

Calculate the saturation vapor pressure for t in °C

Examples

>>> esat(0)
610.94000000000005

Following eq. 6 of Lawrence, M.G., 2005. The Relationship between Relative Humidity and the Dewpoint Temperature in Moist Air: A Simple Conversion and Applications. Bulletin of the American Meteorological Society 86, 225–233. doi:10.1175/BAMS-86-2-225

dypy.small_tools.moist_lapse(t, p)[source]

Calculates moist adiabatic lapse rate for T (Celsius) and p (Pa) Note: We calculate dT/dp, not dT/dz See formula 3.16 in Rogers&Yau for dT/dz, but this must be combined with the dry adiabatic lapse rate (gamma = g/cp) and the inverse of the hydrostatic equation (dz/dp = -RT/pg)

dypy.small_tools.equivalent_pot_temp(t, p, qv)[source]

Return the equivalent potential temperature in K

computation of equivalent potential temperature according to Bolton (1980) except constant 0.1998 (4.805 according to Bolton).

Parameters:
  • t (np.array, np.float) – Temperature in K
  • p (np.array, np.float) – Pressure in hPa
  • qv (np.array, np.float) – Specific humidity in kg/kg
Returns:

the – equivalent potential temperature in K

Return type:

np.array, np.float

Examples:

>>> t = 16 + 273
>>> qv = 0.01156
>>> p = 850
>>> equivalent_pot_temp(t, p, qv)
337.59612858187029