monet package¶
Subpackages¶
Submodules¶
monet.met_funcs module¶
DESCRIPTION¶
- This package contains the main routines for estimating variables related to the
- Monin-Obukhov (MO) Similarity Theory, such as MO length, adiabatic correctors
for heat and momentum transport. It requires the following package.
-
monet.met_funcs.
calc_L
(ustar, T_A_K, rho, c_p, H, LE)¶ Calculates the Monin-Obukhov length.
Parameters: - ustar (float) – friction velocity (m s-1).
- T_A_K (float) – air temperature (Kelvin).
- rho (float) – air density (kg m-3).
- c_p (float) – Heat capacity of air at constant pressure (J kg-1 K-1).
- H (float) – sensible heat flux (W m-2).
- LE (float) – latent heat flux (W m-2).
Returns: L – Obukhov stability length (m).
Return type: float
References
[Brutsaert2005] Brutsaert, W. (2005). Hydrology: an introduction (Vol. 61, No. 8). Cambridge: Cambridge University Press.
-
monet.met_funcs.
calc_Psi_H
(zoL)¶ Calculates the adiabatic correction factor for heat transport.
Parameters: zoL (float) – stability coefficient (unitless). Returns: Psi_H – adiabatic corrector factor fof heat transport (unitless). Return type: float References
[Brutsaert2005] Brutsaert, W. (2005). Hydrology: an introduction (Vol. 61, No. 8). Cambridge: Cambridge University Press.
-
monet.met_funcs.
calc_Psi_M
(zoL)¶ Adiabatic correction factor for momentum transport.
Parameters: zoL (float) – stability coefficient (unitless). Returns: Psi_M – adiabatic corrector factor fof momentum transport (unitless). Return type: float References
[Brutsaert2005] Brutsaert, W. (2005). Hydrology: an introduction (Vol. 61, No. 8). Cambridge: Cambridge University Press.
-
monet.met_funcs.
calc_c_p
(p, ea)¶ Calculates the heat capacity of air at constant pressure.
Parameters: - p (float) – total air pressure (dry air + water vapour) (mb).
- ea (float) – water vapor pressure at reference height above canopy (mb).
Returns: c_p
Return type: heat capacity of (moist) air at constant pressure (J kg-1 K-1)
References
based on equation (6.1) from Maarten Ambaum (2010): Thermal Physics of the Atmosphere (pp 109).
-
monet.met_funcs.
calc_delta_vapor_pressure
(T_K)¶ Calculate the slope of saturation water vapour pressure.
Parameters: T_K (float) – temperature (K). Returns: s – slope of the saturation water vapour pressure (kPa K-1) Return type: float
-
monet.met_funcs.
calc_lambda
(T_A_K)¶ Calculates the latent heat of vaporization.
Parameters: T_A_K (float) – Air temperature (Kelvin). Returns: Lambda – Latent heat of vaporisation (J kg-1). Return type: float References
based on Eq. 3-1 Allen FAO98
-
monet.met_funcs.
calc_lapse_rate_moist
(T_A_K, ea, p)¶ Calculate moist-adiabatic lapse rate (K/m)
Parameters: - T_A_K (float or numpy array) – air temperature at reference height (K).
- ea (float or numpy array) – water vapor pressure at reference height (mb).
- p (float or numpy array) – total air pressure (dry air + water vapour) at reference height (mb).
Returns: Gamma_w – moist-adiabatic lapse rate (K/m)
Return type: float or numpy array
References
http://glossary.ametsoc.org/wiki/Saturation-adiabatic_lapse_rate
-
monet.met_funcs.
calc_mixing_ratio
(ea, p)¶ Calculate ratio of mass of water vapour to the mass of dry air (-)
Parameters: - ea (float or numpy array) – water vapor pressure at reference height (mb).
- p (float or numpy array) – total air pressure (dry air + water vapour) at reference height (mb).
Returns: r – mixing ratio (-)
Return type: float or numpy array
References
-
monet.met_funcs.
calc_pressure
(z)¶ Calculates the barometric pressure above sea level.
Parameters: z (float) – height above sea level (m). Returns: p – air pressure (mb). Return type: float
-
monet.met_funcs.
calc_psicr
(c_p, p, Lambda)¶ Calculates the psicrometric constant.
Parameters: - c_p (float) – heat capacity of (moist) air at constant pressure (J kg-1 K-1).
- p (float) – atmopheric pressure (mb).
- Lambda (float) – latent heat of vaporzation (J kg-1).
Returns: psicr – Psicrometric constant (mb C-1).
Return type: float
-
monet.met_funcs.
calc_rho
(p, ea, T_A_K)¶ Calculates the density of air.
Parameters: - p (float) – total air pressure (dry air + water vapour) (mb).
- ea (float) – water vapor pressure at reference height above canopy (mb).
- T_A_K (float) – air temperature at reference height (Kelvin).
Returns: rho – density of air (kg m-3).
Return type: float
References
based on equation (2.6) from Brutsaert (2005): Hydrology - An Introduction (pp 25).
-
monet.met_funcs.
calc_richardson
(u, z_u, d_0, T_R0, T_R1, T_A0, T_A1)¶ Richardson number.
Estimates the Bulk Richardson number for turbulence using time difference temperatures.
Parameters: - u (float) – Wind speed (m s-1).
- z_u (float) – Wind speed measurement height (m).
- d_0 (float) – Zero-plane displacement height (m).
- T_R0 (float) – radiometric surface temperature at time 0 (K).
- T_R1 (float) – radiometric surface temperature at time 1 (K).
- T_A0 (float) – air temperature at time 0 (K).
- T_A1 (float) – air temperature at time 1 (K).
Returns: Ri – Richardson number.
Return type: float
References
[Norman2000] Norman, J. M., W. P. Kustas, J. H. Prueger, and G. R. Diak (2000), Surface flux estimation using radiometric temperature: A dual-temperature-difference method to minimize measurement errors, Water Resour. Res., 36(8), 2263-2274, http://dx.doi.org/10.1029/2000WR900033.
-
monet.met_funcs.
calc_stephan_boltzmann
(T_K)¶ Calculates the total energy radiated by a blackbody.
Parameters: T_K (float) – body temperature (Kelvin) Returns: M – Emitted radiance (W m-2) Return type: float
-
monet.met_funcs.
calc_sun_angles
(lat, lon, stdlon, doy, ftime)¶ Calculates the Sun Zenith and Azimuth Angles (SZA & SAA).
Parameters: - lat (float) – latitude of the site (degrees).
- long (float) – longitude of the site (degrees).
- stdlng (float) – central longitude of the time zone of the site (degrees).
- doy (float) – day of year of measurement (1-366).
- ftime (float) – time of measurement (decimal hours).
Returns: - sza (float) – Sun Zenith Angle (degrees).
- saa (float) – Sun Azimuth Angle (degrees).
-
monet.met_funcs.
calc_theta_s
(xlat, xlong, stdlng, doy, year, ftime)¶ Calculates the Sun Zenith Angle (SZA).
Parameters: - xlat (float) – latitude of the site (degrees).
- xlong (float) – longitude of the site (degrees).
- stdlng (float) – central longitude of the time zone of the site (degrees).
- doy (float) – day of year of measurement (1-366).
- year (float) – year of measurement .
- ftime (float) – time of measurement (decimal hours).
Returns: theta_s – Sun Zenith Angle (degrees).
Return type: float
References
Adopted from Martha Anderson’s fortran code for ALEXI which in turn was based on Cupid.
-
monet.met_funcs.
calc_u_star
(u, z_u, L, d_0, z_0M)¶ Friction velocity.
Parameters: - u (float) – wind speed above the surface (m s-1).
- z_u (float) – wind speed measurement height (m).
- L (float) – Monin Obukhov stability length (m).
- d_0 (float) – zero-plane displacement height (m).
- z_0M (float) – aerodynamic roughness length for momentum transport (m).
References
[Brutsaert2005] Brutsaert, W. (2005). Hydrology: an introduction (Vol. 61, No. 8). Cambridge: Cambridge University Press.
-
monet.met_funcs.
calc_vapor_pressure
(T_K)¶ Calculate the saturation water vapour pressure.
Parameters: T_K (float) – temperature (K). Returns: ea – saturation water vapour pressure (mb). Return type: float
-
monet.met_funcs.
flux_2_evaporation
(flux, T_K=293.15, time_domain=1)¶ Converts heat flux units (W m-2) to evaporation rates (mm time-1) to a given temporal window
Parameters: - flux (float or numpy array) – heat flux value to be converted, usually refers to latent heat flux LE to be converted to ET
- T_K (float or numpy array) – environmental temperature in Kelvin. Default=20 Celsius
- time_domain (float) – Temporal window in hours. Default 1 hour (mm h-1)
Returns: ET – evaporation rate at the time_domain. Default mm h-1
Return type: float or numpy array
monet.monet_accessor module¶
MONET Accessor
-
class
monet.monet_accessor.
MONETAccessor
(xray_obj)¶ Bases:
object
Short summary.
Parameters: xray_obj (type) – Description of parameter xray_obj. -
obj
¶ Description of attribute obj.
Type: type
-
cftime_to_datetime64
(name=None)¶ Short summary.
Parameters: name (type) – Description of parameter name. Returns: Description of returned object. Return type: type
-
combine_point
(data, suffix=None, pyresample=True, **kwargs)¶ Short summary.
Parameters: - data (type) – Description of parameter data.
- col (type) – Description of parameter col.
- radius (type) – Description of parameter radius.
Returns: Description of returned object.
Return type: type
-
interp_constant_lat
(lat=None, lat_name='latitude', lon_name='longitude', **kwargs)¶ Interpolates the data array to constant longitude.
Parameters: lon (float) – Latitude on which to interpolate to Returns: DataArray of at constant longitude Return type: DataArray
-
interp_constant_lon
(lon=None, **kwargs)¶ Interpolates the data array to constant longitude.
Parameters: lon (float) – Latitude on which to interpolate to Returns: DataArray of at constant longitude Return type: DataArray
-
is_land
(return_xarray=False)¶ checks the mask of land and ocean.
Parameters: return_xarray (bool) – If True, return the data array with the ocean values set to NaN. If False, return a numpy boolean array of the land (True). Returns: Return type: xarray.DataArray or numpy.array
-
is_ocean
(return_xarray=False)¶ checks the mask of land and ocean.
Parameters: return_xarray (bool) – If True, return the data array with the land values set to NaN. If False, return a numpy boolean array of the ocean (True). Returns: Return type: xarray.DataArray or numpy.array
-
nearest_ij
(lat=None, lon=None, **kwargs)¶ Uses pyresample to intepolate to find the i, j index of grid with respect to the given lat lon.
Parameters: - lat (float) – latitude in question
- lon (float) – longitude in question
- **kwargs (dict) – pyresample kwargs for nearest neighbor interpolation
Returns: Returns the i (x index) and j (y index) of the given latitude longitude value
Return type: i,j
-
nearest_latlon
(lat=None, lon=None, cleanup=True, esmf=False, **kwargs)¶ Uses xesmf to intepolate to a given latitude and longitude. Note that the conservative method is not available.
Parameters: - lat (type) – Description of parameter lat.
- lon (type) – Description of parameter lon.
- **kwargs (type) – Description of parameter **kwargs.
Returns: Description of returned object.
Return type: type
-
quick_imshow
(map_kws={}, center=True, **kwargs)¶ Creates a quick map view of a given data array.
Parameters: - map_kws (dict) – kwargs for monet.plots.mapgen.draw_map.
- **kwargs (dict) – kwargs for xarray plotting.
Returns: return of the axes handle for matplotlib.
Return type: matplotlib.axes
-
quick_map
(map_kws={}, center=True, **kwargs)¶ Creates a quick map view of a given data array.
Parameters: - map_kws (dict) – kwargs for monet.plots.mapgen.draw_map.
- **kwargs (dict) – kwargs for xarray plotting.
Returns: return of the axes handle for matplotlib.
Return type: matplotlib.axes
-
remap_nearest
(data, **kwargs)¶ - Interpolates from another grid (data) to the current grid of self using pyresample.
- it assumes that the dimensions are ordered in y,x,z per
pyresample docs
Parameters: - da (xarray DataArray or xarray DataSet) – Object to be interpolated
- radius_of_influence (float or integer) – radius of influcence for pyresample in meters.
Returns: resampled object on current grid.
Return type: xarray.DataArray
-
remap_xesmf
(dataarray, method='bilinear', **kwargs)¶ remaps from another grid to the current grid of self using xesmf
Parameters: - daaarray (ndarray or xarray DataArray) – Description of parameter dset.
- radius_of_influence (float or integer) – radius of influcence for pyresample in meters.
Returns: resampled object on current grid.
Return type: xarray.DataArray
-
stratify
(levels, vertical, axis=1)¶ Short summary.
Parameters: - levels (type) – Description of parameter levels.
- vertical (type) – Description of parameter vertical.
- axis (type) – Description of parameter axis.
Returns: Description of returned object.
Return type: type
-
structure_for_monet
(lat_name='lat', lon_name='lon', return_obj=True)¶ This will attempt to restucture a given DataArray for use within MONET.
Parameters: - lat_name (type) – Description of parameter lat_name.
- lon_name (type) – Description of parameter lon_name.
- return (type) – Description of parameter return.
Returns: Description of returned object.
Return type: type
-
tidy
(lon_name='longitude')¶ Tidy’s DataArray–wraps longitudes and sorts lats and lons
Returns: The tidy object Return type: xr.DataArray
-
window
(lat_min=None, lon_min=None, lat_max=None, lon_max=None, rectilinear=False)¶ Function to window, ie select a specific region, given the lower left latitude and longitude and the upper right latitude and longitude
Parameters: - lat_min (float) – lower left latitude .
- lon_min (float) – lower left longitude.
- lat_max (float) – upper right latitude.
- lon_max (float) – upper right longitude.
- rectilinear (bool) – flag if this is a rectilinear lat lon grid
Returns: returns the windowed object.
Return type: xr.DataArray
-
wrap_longitudes
(lon_name='longitude')¶ Ensures longitudes are from -180 -> 180
Returns: Description of returned object. Return type: type
-
-
class
monet.monet_accessor.
MONETAccessorDataset
(xray_obj)¶ Bases:
object
Monet accessor to the xarray.Dataset.
Parameters: xray_obj (type) – Description of parameter xray_obj. -
obj
¶ Description of attribute obj.
Type: type
-
cftime_to_datetime64
(name=None)¶ Convert cftime o numpy datetime64 objects.
Parameters: name (str) – time variable name. Returns: Description of returned object. Return type: xarray.DataArray
-
combine_point
(data, suffix=None, pyresample=True, **kwargs)¶ Short summary.
Parameters: - data (type) – Description of parameter data.
- col (type) – Description of parameter col.
- radius (type) – Description of parameter radius.
Returns: Description of returned object.
Return type: type
-
interp_constant_lat
(lat=None, lat_name='latitude', lon_name='longitude', **kwargs)¶ Interpolates the data array to constant longitude.
Parameters: lon (float) – Latitude on which to interpolate to Returns: DataArray of at constant longitude Return type: DataArray
-
interp_constant_lon
(lon=None, **kwargs)¶ Interpolates the data array to constant longitude.
Parameters: lon (float) – Latitude on which to interpolate to Returns: DataArray of at constant longitude Return type: xr.Dataset or xr.DataArray
-
is_land
(return_xarray=False)¶ checks the mask of land and ocean if the global_land_mask libra.
Parameters: return_xarray (bool) – If True, return the data array with the ocean values set to NaN. If False, return a numpy boolean array of the land (True). Returns: Return type: xarray.DataArray or numpy.array
-
is_ocean
(return_xarray=False)¶ checks the mask of land and ocean.
Parameters: return_xarray (bool) – If True, return the data array with the land values set to NaN. If False, return a numpy boolean array of the ocean (True). Returns: Return type: xarray.DataArray or numpy.array
-
nearest_ij
(lat=None, lon=None, **kwargs)¶ Uses pyresample to intepolate to find the i, j index of grid with respect to the given lat lon.
Parameters: - lat (float) – latitude in question
- lon (float) – longitude in question
- **kwargs (dict) – pyresample kwargs for nearest neighbor interpolation
Returns: Returns the i (x index) and j (y index) of the given latitude longitude value
Return type: i,j
-
nearest_latlon
(lat=None, lon=None, cleanup=True, esmf=False, **kwargs)¶ Uses xesmf to intepolate to a given latitude and longitude. Note that the conservative method is not available.
Parameters: - lat (type) – Description of parameter lat.
- lon (type) – Description of parameter lon.
- **kwargs (type) – Description of parameter **kwargs.
Returns: Description of returned object.
Return type: type
-
remap_nearest
(data, radius_of_influence=1000000.0)¶ Will remap data to the current dataset using the pyresample.kd_tree nearest neighbor interpolation.
Parameters: - data (xarray.DataArray or xarray.Dataset) – geospatial dataset that includes the latitude and longtide coordinates
- radius_of_influence (float) – radius_of_influence kwarg for pyresample.kd_tree. Default (1e6)
Returns: The interpolated xarray object
Return type: xarray.Dataset or xarray.DataArray
-
remap_xesmf
(data, **kwargs)¶ Resample the xesmf
Parameters: - data (type) – Description of parameter data.
- **kwargs (type) – Description of parameter **kwargs.
Returns: Description of returned object.
Return type: type
-
stratify
(levels, vertical, axis=1)¶ Short summary.
Parameters: - levels (type) – Description of parameter levels.
- vertical (type) – Description of parameter vertical.
- axis (type) – Description of parameter axis.
Returns: Description of returned object.
Return type: type
-
tidy
(lon_name='longitude')¶ Tidy’s DataArray–wraps longitudes and sorts lats and lons
Returns: The tidy object Return type: xr.DataArray
-
window
(lat_min, lon_min, lat_max, lon_max)¶ Function to window, ie select a specific region, given the lower left latitude and longitude and the upper right latitude and longitude
Parameters: - lat_min (float) – lower left latitude .
- lon_min (float) – lower left longitude.
- lat_max (float) – upper right latitude.
- lon_max (float) – upper right longitude.
Returns: returns the windowed object.
Return type: xr.DataSet
-
wrap_longitudes
(lon_name='longitude')¶ Ensures longitudes are from -180 -> 180
Returns: Description of returned object. Return type: type
-
-
class
monet.monet_accessor.
MONETAccessorPandas
(pandas_obj)¶ Bases:
object
-
center
¶ Short summary.
Returns: Description of returned object. Return type: type
-
cftime_to_datetime64
(col=None)¶ Short summary.
Parameters: col (type) – Description of parameter col. Returns: Description of returned object. Return type: type
-
get_sparse_SwathDefinition
()¶ Creates a pyreample.geometry.SwathDefinition for a single point.
Returns: Return type: pyreample.geometry.SwathDefinition
-
remap_nearest
(df, radius_of_influence=100000.0, combine=False, lat_name=None, lon_name=None)¶ Remap df to find nearest sites
Parameters: - df (pandas.DataFrame) – dataframe to be interpolated
- radius_of_influence (float) – kwarg for pyresample.kd_tree
Returns: Returns the interpolated dataframe
Return type: pandas.dataframe
-
rename_for_monet
(df=None)¶ Rename latitude and longitude columns in the DataFrame.
Parameters: df (type) – Description of parameter df. Returns: Description of returned object. Return type: type
-
to_ascii2nc_df
(grib_code=126, height_msl=0.0, column='aod_550nm', message_type='ADPUPA', pressure=1000.0, qc=None, height_agl=None)¶
-
to_ascii2nc_list
(**kwargs)¶
-
-
monet.monet_accessor.
wrap_longitudes
(lons)¶ Short summary.
Parameters: lons (type) – Description of parameter lons. Returns: Description of returned object. Return type: type