Utilities

Atmospheric physics

Routines for calculations of various physical properties

rcatool.utils.atmosphys.rh2sh(rh, T[, P])

Convert relative humidity to specific humidity Code from: https://github.com/PecanProject/pecan/blob/master/modules/data.atmosphere/R/metutils.R Equation for sh from standard literature, e.g. K. Emanuel (1994; eq. 4.1.4) Reference: * Emanuel, K. A. (1994): Atmospheric Convection. New York, NY: Oxford University Press, 580 pp.

rcatool.utils.atmosphys.sh2rh(sh, T[, P])

Convert specific humidity to relative humidity Code from: https://github.com/PecanProject/pecan/blob/master/modules/data.atmosphere/R/metutils.R

rcatool.utils.atmosphys.td2sh(Td, P)

Convert dew point temperature to specific humidity https://github.com/PecanProject/pecan/blob/master/modules/data.atmosphere/R/metutils.R

rcatool.utils.atmosphys.sh2td(sh, p)

Returns dew point temperature (K) at mixing ratio sh (kg/kg) and pressure p (Pa).

rcatool.utils.atmosphys.calc_e_from_w(w[, P])

Vapor pressure over liquid surface can be calculated from a variety of different combinations of state variables. Here, vapor pressure is calculated from mixing ratio w (kg/kg) and pressure P. Formula is given in standard literature; e.g. eq. 2.18 in Rogers&Yau (Cloud physics) and eq. 4.1.2 in Emanuel (1994). Reference: * Emanuel, K. A. (1994): Atmospheric Convection. New York, NY: Oxford University Press, 580 pp.

rcatool.utils.atmosphys.calc_e_from_sh(sh[, P])

Vapor pressure over liquid surface can be calculated from a variety of different combinations of state variables. Here, vapor pressure is calculated from specific humidity sh (kg/kg) and pressure P (Pa). Formula is given in standard literature; e.g. eq. 2.19 in Rogers & Yau (Cloud physics) and eq. 4.1.4 in Emanuel (1994). Reference: * Emanuel, K. A. (1994): Atmospheric Convection. New York, NY: Oxford University Press, 580 pp.

rcatool.utils.atmosphys.calc_es(T)

Returns saturation vapor pressure in hPa at temperature T (Kelvin) Formula 2.17 in Rogers&Yau

rcatool.utils.atmosphys.calc_ws(T[, P])

Returns saturation mixing ratio in kg/kg at temperature T (Kelvin) and pressure P (hPa).

rcatool.utils.atmosphys.td(e)

Returns dew point temperature (C) at vapor pressure e (Pa) Insert Td in 2.17 in Rogers&Yau and solve for Td

rcatool.utils.atmosphys.wind2uv(ws, wd[, ...])

Converts wind speed and direction to u and v components.

rcatool.utils.atmosphys.uv2wind(u, v)

Converts u and v components to wind speed and direction.

rcatool.utils.atmosphys.brunt_vaisala_frequency(...)

Calculate Brunt-Vaisala frequency in layer bounded by two pressure levels.

rcatool.utils.atmosphys.lifted_condensation_temperature(...)

Returns the lifted condensation temperature in units of Kelvin.

rcatool.utils.atmosphys.theta_equivalent(...)

Returns the equivalent potential temperature in units of Kelvin.

rcatool.utils.atmosphys.theta_pseudoequiv(...)

Returns the pseudo-equivalent potential temperature in units of Kelvin.

IO handling

This module provides routines representing tools to read and write NetCDF files.

rcatool.utils.file_io.ncdump(nc_fid[, verb])

ncdump outputs dimensions, variables and their attribute information.

rcatool.utils.file_io.openFile(filename)

Function to open netcdf file.

rcatool.utils.file_io.getDimensions(nc[, close])

Function to retrieve the dimensions of a netcdf file nc: Netcdf object opened with function "openFile" close: set True if you want the file to be closed after retrieval.

rcatool.utils.file_io.getParams(nc, params)

Function to retrieve variables from a netcdf file nc: Netcdf object opened with function "openFile" params: A list of strings with the parameters to be retrieved close: set True if you want the file to be closed after retrieval.

rcatool.utils.file_io.fracday2datetime(tdata)

Takes an array of dates given in %Y%m%d.%f format and returns a corresponding datetime object

rcatool.utils.file_io.write2netcdf(filename, ...)

Opens a new NetCDF file to write the input data to.

Grid applications

Routines to remap data given source and target grids.

rcatool.utils.grids.fnCellCorners(rgrLon, rgrLat)

File name: fnCellBoundaries Author: Andreas Prein E-mail: prein@ucar.edu Date created: 20.03.2015 Date last modified: 20.03.2015

rcatool.utils.grids.calc_vertices(lons, lats)

Estimate the cell boundaries from the cell location of regular grids

rcatool.utils.grids.fnRemapConOperator(...)

File name: fnRemapConOperator Author: Andreas Prein E-mail: prein@ucar.edu Date created: 26.05.2017 Date last modified: 26.05.2017

rcatool.utils.grids.fnRemapCon(rgrLonS, ...)

File name: fnRemapCon Author: Andreas Prein E-mail: prein@ucar.edu Date created: 13.06.2017 Date last modified: 13.06.2017

rcatool.utils.grids.add_matrix_NaNs(regridder)

Replace zero values of cells in the new grid that are outside the old grid's domain with NaN's.

Config reader module

Creates and return a dictionary built from a config file.

rcatool.utils.ini_reader.get_config_dict(...)

Create a dictionary from then input config file.

Polygons

Mask polygons

Routine for Masking Data with Polygons.

rcatool.utils.polygons.polygons([area, ...])

See available polygons and retrieve path to polygon files.

rcatool.utils.polygons.mask_region(xp, yp, area)

Routine to mask grid points outside a specified polygon.

rcatool.utils.polygons.create_polygon()

Retrieve polygon arbitrarily drawn interactively on a map by mouse clicking.

rcatool.utils.polygons.plot_polygon(polygon)

Plot polygon on map.

rcatool.utils.polygons.topo_mask(data, orog, ...)

Rotuine to mask grid points outside a specified height interval.

rcatool.utils.polygons.find_geo_indices(...)

Search for nearest decimal degree in an array of decimal degrees and return the index.

Draw polygon

Draw a simple polygon using matplotlib with mouse event handling.

rcatool.utils.draw_polygon.Canvas.set_location(event)

rcatool.utils.draw_polygon.Canvas.update_path(event)