pymicra.micro package

Submodules

pymicra.micro.functions

pymicra.micro.functions.Psi(zeta, x='tau', zeta0=0.0)

Integral Monin-Obukhov scale or deviation function, which is the deviation of a variable (x) in relation nto their logarithmic profiles due the stability zeta != 0

Taken from Simpson.ea1998–the.validity.of.similarity.theory;.in.the.roughness.sublayer

Parameters:
  • zeta (float) – the stability variable
  • x (string) – the variable. Options are ‘tau’, ‘H’, ‘E’, ‘F’
  • zeta0 (float) – value of zeta_{0 x}. Only used for the stable case
pymicra.micro.functions.nondimensionalGrad(zeta, x=None)

The nondimensional gradients, defined as:

phi_F(zeta) = kappa*(z-d)*dCdz/c_star phi_H(zeta) = kappa*(z-d)*dTdz/T_star phi_E(zeta) = kappa*(z-d)*dqdz/q_star

Currently using Businger-Dyer eqs.

TODO: generalize coefficients

pymicra.micro.functions.nondimensionalSTD(zeta, x=None)

The nondimensional standard deviation function, defined as:

phi_c(zeta) = sigma_c / c_star

From zahn.ea

pymicra.micro.functions.rte(data, w_fluctuations="w'", order=None)

Returns the Relative Transfer Efficiency in the time domain, rte according to Cancelli, Dias, Chamecki. Dimensionless criteria for the production-dissipation equilibrium of scalar fluctuations and their implications for scalar similarity, Water Resources Research, 2012

Parameters:
  • order (2-elements list) – order of variables: if its rte_ab should be [a,b], if its rte_ba should [b,a]
  • TO BE VALIDATED! (NEEDS) –
pymicra.micro.functions.ste(data, w_fluctuations="w'")

Returns the Symmetric Transfer Efficiency in the time domain, ste according to Cancelli, Dias, Chamecki. Dimensionless criteria for the production-dissipation equilibrium of scalar fluctuations and their implications for scalar similarity, Water Resources Research, 2012

Parameters:
  • data (pandas dataframe) – a three-columns dataframe, where one of them should be the vertical velocity fluctuations
  • w_fluctuations (str) – the name of the vertical velocity fluctuations

pymicra.micro.scales

pymicra.micro.scales.MonObuLen(theta_v_star, theta_v_mean, u_star, g=None)

Redirects to obukhovLen()

pymicra.micro.scales.MonObuVar(L_m, siteConf)

Redirects to stabilityParam()

pymicra.micro.scales.obukhovLen(data, units, theta_v_mean=None, theta_v_mean_unit=None, notation=None, inplace_units=True)

Calculates the Monin-Obukhov Length according to:

GARRAT, The atmospheric boundary layer, 1992 (eq. 1.11, p. 10) L = ( u_star^2 * theta_v ) / ( kappa * g * theta_v_star )

KUNDU, Fluid mechanics, 1990 (eq 71, chap. 12, p. 462) L_M = - u_star^3 / ( kappa * alpha * g * cov(w,T’) )

ARYA, Introduction to micrometeorology (eq. 11.1, p. 214) L = - u_star^3 / (kappa * (g/T_0) * (H_0/(rho*c_p)) )

STULL, An introduction to Boundary layer meteorology, 1988 (eq. 5.7b, p. 181) L = - ( theta_v * u_star^3 ) / ( kappa g cov(w’,theta_v’) )

pymicra.micro.scales.stabilityParam(L_m, siteConf)

Calculates the Monin-Obukhov Similarity Variable defined as

zeta = (z-d)/Lo where d is the displacement height or zero-plane displacement and L_m is the Monin-Obukhov Length.

pymicra.micro.scales.turbulentScales(data, siteConf, units, notation=None, theta_v_mean=None, theta_v_mean_unit=None, theta_fluct_from_theta_v=True, solutes=[], output_as_df=True, inplace_units=True)

Calculates characteristic lengths for data

The names of the variables are retrived out the dictionary. You can update the dictionary and change the names by using the notation_defs keyworkd, which is a notation object

Parameters:
  • data (pandas.DataFrame) – dataset to be used. It must either be the raw and turbulent data, or the covariances of such data
  • siteConf (pymicra.siteConfig object) – has the site configurations to calculate the obukhovLen
  • units (dict) – dict units for the input data
  • output_as_df (boolean) – True if you want the output to be a one-line pandas.DataFrame. A pd.Series will be output if False.
  • inplace_units (bool) – whether or not to update the units dict in place
Returns:

depending on return_as_df

Return type:

pandas.Series or pandas.Dataframe

pymicra.micro.spectral

pymicra.micro.spectral.Ogive(df, no_nan=True)

Integrates the Ogive from Coespectra

Parameters:df (dataframe) – cospectrum to be integrated
pymicra.micro.spectral.cospectrum(*args, **kwargs)

Gets cospectra from cross-spectrum

pymicra.micro.spectral.hfc_Dias_ea_16(cross_spec, T)

Applies correction to high frequencies using the quadrature. Xab_ab = Co_ab - i Qu_ab

Co_recovered = Co_ab + 2*pi*n*T*Qu_ab

Parameters:
  • cross_spec (series of dataframe) – the cross spectrum whose coespectrum you’d like to correct
  • T (float) – response time to use
pymicra.micro.spectral.hfc_Massman_Ibrom_08(df)
pymicra.micro.spectral.hfc_zeroQuad(slow_spec, freqs, T)

Applies a correction factor to the spectrum of a slow-measured variable based on the response-time T. Quadrature must be analytically zero!

Parameters:
  • slow_spec (numpy.array or series) – the spectrum to be corrected (not cross-spectrum!)
  • freqs (numpy.array) – frequencies
  • T (float) – the response-time
Returns:

spec – the recovered array

Return type:

numpy.array

pymicra.micro.spectral.phaseCorrection(cross_spec, T)
pymicra.micro.spectral.quadrature(*args, **kwargs)

Gets quadrature from cross-spectrum

pymicra.micro.spectral.recspeAux(df, T)

Wrapper to make hfc_zeroQuad work in a pandas.DataFrame

pymicra.micro.spectral.zeroQuadCorrection(*args, **kwargs)

Applies the correction assuming that the quadrature is zero to a dataframe with spectra

Wrapper to make hfc_zeroQuad work in a pandas.DataFrame

Parameters:
  • df (pandas.DataFrame) – dataframe with cospectra to correct
  • T (float) – response time to be used

pymicra.micro.util

pymicra.micro.util.eddyCovariance(data, units, wpl=True, get_turbulent_scales=True, site_config=None, output_as_df=True, notation=None, theta_fluct_from_theta_v=True, inplace_units=True, solutes=[])

Get fluxes from the turbulent fluctuations

Parameters:
  • data (pandas.DataFrame) – dataframe with the characteristic lengths calculated
  • units (dict) – units dictionary
  • wpl (boolean) – whether or not to apply WPL correction on the latent heat flux and solutes flux
  • get_turbulent_scales (bool) – whether or not to use getScales to return turbulent scales
  • site_config (pymica.siteConfig) – siteConfig object to pass to getScales if get_turbulent_scales==True
  • notation (pymicra.Notation) – object that holds the notation used in the dataframe
  • inplace_units (bool) – whether or not to treat the units inplace
  • solutes (list) – list that holds every solute considered for flux
pymicra.micro.util.preProcess(data, units, notation=None, rotation='2d', use_means=False, expand_temperature=True, rho_air_from_theta_v=True, convert_sound_speed=True, skip_h2o=False, inplace_units=True, theta=None, theta_unit=None, solutes=[])

Calculates moist and dry air densities, specific humidity mass density and other important variables using the variables provided in the input DataFrame.

Parameters:
  • data (pandas.DataFrame) – dataframe with micrometeorological measurements
  • units (dict) – units dictionary with the columns of data as keys
  • notation (pymicra.notation) – defining notation used in data
  • rotation (string) – Rotation method to use on data (passed to rotateCoor function). Default is “2d”. If None, no rotation is done.
  • rho_air_from_theta_v (bool) – whether to use theta_v to calculate air density or theta
  • inplace_units (bool) – treat units inplace or not
  • theta (pandas.Series) – auxiliar theta measurement to be used if rho_air_from_theta_v==False
  • theta_unit (pint.quantity) – auxiliar theta measurement’s unit to be used if rho_air_from_theta_v==False
  • solutes (list) – list of string where each string is a solute to be considered
Returns:

data – dataframe with original columns and new calculated ones

Return type:

pandas.DataFrame

pymicra.micro.util.rotateCoor(data, notation=None, how='2d')

Module contents

Submodule that holds the specifically micrometeorological functions and variables