geocat.comp.dpres_plevel

geocat.comp.dpres_plevel(plev, psfc, ptop=None, msg=None, meta=False)

Calculates the pressure layer thicknesses of a constant pressure level coordinate system.

Parameters
  • plev (numpy.ndarray) – A one dimensional array containing the constant pressure levels. May be in ascending or descending order. Must have the same units as psfc.

  • psfc (numpy.ndarray) – A scalar or an array of up to three dimensions containing the surface pressure data in Pa or hPa (mb). The rightmost dimensions must be latitude and longitude. Must have the same units as plev.

  • ptop (numpy.number) – A scalar specifying the top of the column. ptop should be <= min(plev). Must have the same units as plev.

  • msg (numpy.number) – A numpy scalar value that represent a missing value in fi. This argument allows a user to use a missing value scheme other than NaN or masked arrays, similar to what NCL allows.

  • meta (bool) – If set to True and the input array is an Xarray, the metadata from the input array will be copied to the output array; default is False. Warning: this option is not currently supported.

Returns

If psfc is a scalar the return variable will be a one-dimensional array the same size as plev; if psfc is two-dimensional [e.g. (lat,lon)] or three-dimensional [e.g. (time,lat,lon)] then the return array will have an additional level dimension: (lev,lat,lon) or (time,lev,lat,lon). The returned type will be double if psfc is double, float otherwise.

Return type

numpy.ndarray

Description:

Calculates the layer pressure thickness of a constant pressure level system. It is analogous to dpres_hybrid_ccm for hybrid coordinates. At each grid point the sum of the pressure thicknesses equates to [psfc-ptop]. At each grid point, the returned values above ptop and below psfc will be set to the missing value of psfc. If there is no missing value for psfc then the missing value will be set to the default for float or double appropriately. If ptop or psfc is between plev levels then the layer thickness is modifed accordingly. If psfc is set to a missing value, all layer thicknesses are set to the appropriate missing value.

The primary purpose of this function is to return layer thicknesses to be used to weight observations for integrations.

Examples

Example 1: Using dpres_plevel with xarray.DataArray input

import numpy as np
import xarray as xr
import geocat.comp

# Open a netCDF data file using xarray default engine and load the data stream
ds = xr.open_dataset("./SOME_NETCDF_FILE.nc")

# [INPUT] Grid & data info on the source
psfc = ds.PS
plev = ds.LEV
ptop = 0.0

# Call the function
result_dp = geocat.comp.dpres_plevel(plev, psfc, ptop)