signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def mixing_ratio_from_relative_humidity(relative_humidity, temperature, pressure): | return (relative_humidity<EOL>* saturation_mixing_ratio(pressure, temperature)).to('<STR_LIT>')<EOL> | r"""Calculate the mixing ratio from relative humidity, temperature, and pressure.
Parameters
----------
relative_humidity: array_like
The relative humidity expressed as a unitless ratio in the range [0, 1]. Can also pass
a percentage if proper units are attached.
temperature: `pint.Quan... | f8476:m26 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def relative_humidity_from_mixing_ratio(mixing_ratio, temperature, pressure): | return mixing_ratio / saturation_mixing_ratio(pressure, temperature)<EOL> | r"""Calculate the relative humidity from mixing ratio, temperature, and pressure.
Parameters
----------
mixing_ratio: `pint.Quantity`
Dimensionless mass mixing ratio
temperature: `pint.Quantity`
Air temperature
pressure: `pint.Quantity`
Total atmospheric pressure
Return... | f8476:m27 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def mixing_ratio_from_specific_humidity(specific_humidity): | try:<EOL><INDENT>specific_humidity = specific_humidity.to('<STR_LIT>')<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>return specific_humidity / (<NUM_LIT:1> - specific_humidity)<EOL> | r"""Calculate the mixing ratio from specific humidity.
Parameters
----------
specific_humidity: `pint.Quantity`
Specific humidity of air
Returns
-------
`pint.Quantity`
Mixing ratio
Notes
-----
Formula from [Salby1996]_ pg. 118.
.. math:: w = \frac{q}{1-q}
... | f8476:m28 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def specific_humidity_from_mixing_ratio(mixing_ratio): | try:<EOL><INDENT>mixing_ratio = mixing_ratio.to('<STR_LIT>')<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>return mixing_ratio / (<NUM_LIT:1> + mixing_ratio)<EOL> | r"""Calculate the specific humidity from the mixing ratio.
Parameters
----------
mixing_ratio: `pint.Quantity`
mixing ratio
Returns
-------
`pint.Quantity`
Specific humidity
Notes
-----
Formula from [Salby1996]_ pg. 118.
.. math:: q = \frac{w}{1+w}
* :mat... | f8476:m29 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def relative_humidity_from_specific_humidity(specific_humidity, temperature, pressure): | return (mixing_ratio_from_specific_humidity(specific_humidity)<EOL>/ saturation_mixing_ratio(pressure, temperature))<EOL> | r"""Calculate the relative humidity from specific humidity, temperature, and pressure.
Parameters
----------
specific_humidity: `pint.Quantity`
Specific humidity of air
temperature: `pint.Quantity`
Air temperature
pressure: `pint.Quantity`
Total atmospheric pressure
Ret... | f8476:m30 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def cape_cin(pressure, temperature, dewpt, parcel_profile): | <EOL>lfc_pressure, _ = lfc(pressure, temperature, dewpt,<EOL>parcel_temperature_profile=parcel_profile)<EOL>if np.isnan(lfc_pressure):<EOL><INDENT>return <NUM_LIT:0> * units('<STR_LIT>'), <NUM_LIT:0> * units('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>lfc_pressure = lfc_pressure.magnitude<EOL><DEDENT>el_pressure, _ = el... | r"""Calculate CAPE and CIN.
Calculate the convective available potential energy (CAPE) and convective inhibition (CIN)
of a given upper air profile and parcel path. CIN is integrated between the surface and
LFC, CAPE is integrated between the LFC and EL (or top of sounding). Intersection points of
the ... | f8476:m31 |
def _find_append_zero_crossings(x, y): | <EOL>crossings = find_intersections(x[<NUM_LIT:1>:], y[<NUM_LIT:1>:], np.zeros_like(y[<NUM_LIT:1>:]) * y.units)<EOL>x = concatenate((x, crossings[<NUM_LIT:0>]))<EOL>y = concatenate((y, crossings[<NUM_LIT:1>]))<EOL>sort_idx = np.argsort(x)<EOL>x = x[sort_idx]<EOL>y = y[sort_idx]<EOL>keep_idx = np.ediff1d(x, to_end=[<NUM... | r"""
Find and interpolate zero crossings.
Estimate the zero crossings of an x,y series and add estimated crossings to series,
returning a sorted array with no duplicate values.
Parameters
----------
x : `pint.Quantity`
x values of data
y : `pint.Quantity`
y values of data
... | f8476:m32 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def most_unstable_parcel(pressure, temperature, dewpoint, heights=None,<EOL>bottom=None, depth=<NUM_LIT> * units.hPa): | p_layer, t_layer, td_layer = get_layer(pressure, temperature, dewpoint, bottom=bottom,<EOL>depth=depth, heights=heights, interpolate=False)<EOL>theta_e = equivalent_potential_temperature(p_layer, t_layer, td_layer)<EOL>max_idx = np.argmax(theta_e)<EOL>return p_layer[max_idx], t_layer[max_idx], td_layer[max_idx], max_id... | Determine the most unstable parcel in a layer.
Determines the most unstable parcel of air by calculating the equivalent
potential temperature and finding its maximum in the specified layer.
Parameters
----------
pressure: `pint.Quantity`
Atmospheric pressure profile
temperature: `pint.Quantity`
Atmospheric te... | f8476:m33 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def isentropic_interpolation(theta_levels, pressure, temperature, *args, **kwargs): | <EOL>def _isen_iter(iter_log_p, isentlevs_nd, ka, a, b, pok):<EOL><INDENT>exner = pok * np.exp(-ka * iter_log_p)<EOL>t = a * iter_log_p + b<EOL>f = isentlevs_nd - t * exner<EOL>fp = exner * (ka * t - a)<EOL>return iter_log_p - (f / fp)<EOL><DEDENT>tmpk_out = kwargs.pop('<STR_LIT>', False)<EOL>max_iters = kwargs.pop('<S... | r"""Interpolate data in isobaric coordinates to isentropic coordinates.
Parameters
----------
theta_levels : array
One-dimensional array of desired theta surfaces
pressure : array
One-dimensional array of pressure levels
temperature : array
Array of temperature
args : ar... | f8476:m34 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def surface_based_cape_cin(pressure, temperature, dewpoint): | p, t, td, profile = parcel_profile_with_lcl(pressure, temperature, dewpoint)<EOL>return cape_cin(p, t, td, profile)<EOL> | r"""Calculate surface-based CAPE and CIN.
Calculate the convective available potential energy (CAPE) and convective inhibition (CIN)
of a given upper air profile for a surface-based parcel. CIN is integrated
between the surface and LFC, CAPE is integrated between the LFC and EL (or top of
sounding). In... | f8476:m35 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def most_unstable_cape_cin(pressure, temperature, dewpoint, **kwargs): | _, parcel_temperature, parcel_dewpoint, parcel_idx = most_unstable_parcel(pressure,<EOL>temperature,<EOL>dewpoint,<EOL>**kwargs)<EOL>mu_profile = parcel_profile(pressure[parcel_idx:], parcel_temperature, parcel_dewpoint)<EOL>return cape_cin(pressure[parcel_idx:], temperature[parcel_idx:],<EOL>dewpoint[parcel_idx:], mu_... | r"""Calculate most unstable CAPE/CIN.
Calculate the convective available potential energy (CAPE) and convective inhibition (CIN)
of a given upper air profile and most unstable parcel path. CIN is integrated between the
surface and LFC, CAPE is integrated between the LFC and EL (or top of sounding).
Int... | f8476:m36 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def mixed_parcel(p, temperature, dewpt, parcel_start_pressure=None,<EOL>heights=None, bottom=None, depth=<NUM_LIT:100> * units.hPa, interpolate=True): | <EOL>if not parcel_start_pressure:<EOL><INDENT>parcel_start_pressure = p[<NUM_LIT:0>]<EOL><DEDENT>theta = potential_temperature(p, temperature)<EOL>mixing_ratio = saturation_mixing_ratio(p, dewpt)<EOL>mean_theta, mean_mixing_ratio = mixed_layer(p, theta, mixing_ratio, bottom=bottom,<EOL>heights=heights, depth=depth,<EO... | r"""Calculate the properties of a parcel mixed from a layer.
Determines the properties of an air parcel that is the result of complete mixing of a
given atmospheric layer.
Parameters
----------
p : `pint.Quantity`
Atmospheric pressure profile
temperature : `pint.Quantity`
Atmos... | f8476:m37 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def mixed_layer(p, *args, **kwargs): | <EOL>heights = kwargs.pop('<STR_LIT>', None)<EOL>bottom = kwargs.pop('<STR_LIT>', None)<EOL>depth = kwargs.pop('<STR_LIT>', <NUM_LIT:100> * units.hPa)<EOL>interpolate = kwargs.pop('<STR_LIT>', True)<EOL>layer = get_layer(p, *args, heights=heights, bottom=bottom,<EOL>depth=depth, interpolate=interpolate)<EOL>p_layer = l... | r"""Mix variable(s) over a layer, yielding a mass-weighted average.
This function will integrate a data variable with respect to pressure and determine the
average value using the mean value theorem.
Parameters
----------
p : array-like
Atmospheric pressure profile
datavar : array-like... | f8476:m38 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def dry_static_energy(heights, temperature): | return (mpconsts.g * heights + mpconsts.Cp_d * temperature).to('<STR_LIT>')<EOL> | r"""Calculate the dry static energy of parcels.
This function will calculate the dry static energy following the first two terms of
equation 3.72 in [Hobbs2006]_.
Notes
-----
.. math::\text{dry static energy} = c_{pd} * T + gz
* :math:`T` is temperature
* :math:`z` is height
Paramete... | f8476:m39 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def moist_static_energy(heights, temperature, specific_humidity): | return (dry_static_energy(heights, temperature)<EOL>+ mpconsts.Lv * specific_humidity.to('<STR_LIT>')).to('<STR_LIT>')<EOL> | r"""Calculate the moist static energy of parcels.
This function will calculate the moist static energy following
equation 3.72 in [Hobbs2006]_.
Notes
-----
.. math::\text{moist static energy} = c_{pd} * T + gz + L_v q
* :math:`T` is temperature
* :math:`z` is height
* :math:`q` is spec... | f8476:m40 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def thickness_hydrostatic(pressure, temperature, **kwargs): | mixing = kwargs.pop('<STR_LIT>', None)<EOL>molecular_weight_ratio = kwargs.pop('<STR_LIT>', mpconsts.epsilon)<EOL>bottom = kwargs.pop('<STR_LIT>', None)<EOL>depth = kwargs.pop('<STR_LIT>', None)<EOL>if bottom is None and depth is None:<EOL><INDENT>if mixing is None:<EOL><INDENT>layer_p, layer_virttemp = pressure, tempe... | r"""Calculate the thickness of a layer via the hypsometric equation.
This thickness calculation uses the pressure and temperature profiles (and optionally
mixing ratio) via the hypsometric equation with virtual temperature adjustment
.. math:: Z_2 - Z_1 = -\frac{R_d}{g} \int_{p_1}^{p_2} T_v d\ln p,
w... | f8476:m41 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def thickness_hydrostatic_from_relative_humidity(pressure, temperature, relative_humidity,<EOL>**kwargs): | bottom = kwargs.pop('<STR_LIT>', None)<EOL>depth = kwargs.pop('<STR_LIT>', None)<EOL>mixing = mixing_ratio_from_relative_humidity(relative_humidity, temperature, pressure)<EOL>return thickness_hydrostatic(pressure, temperature, mixing=mixing, bottom=bottom,<EOL>depth=depth)<EOL> | r"""Calculate the thickness of a layer given pressure, temperature and relative humidity.
Similar to ``thickness_hydrostatic``, this thickness calculation uses the pressure,
temperature, and relative humidity profiles via the hypsometric equation with virtual
temperature adjustment.
.. math:: Z_2 - Z_... | f8476:m42 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def brunt_vaisala_frequency_squared(heights, potential_temperature, axis=<NUM_LIT:0>): | <EOL>potential_temperature = potential_temperature.to('<STR_LIT>')<EOL>return mpconsts.g / potential_temperature * first_derivative(potential_temperature,<EOL>x=heights, axis=axis)<EOL> | r"""Calculate the square of the Brunt-Vaisala frequency.
Brunt-Vaisala frequency squared (a measure of atmospheric stability) is given by the
formula:
.. math:: N^2 = \frac{g}{\theta} \frac{d\theta}{dz}
This formula is based off of Equations 3.75 and 3.77 in [Hobbs2006]_.
Parameters
--------... | f8476:m43 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def brunt_vaisala_frequency(heights, potential_temperature, axis=<NUM_LIT:0>): | bv_freq_squared = brunt_vaisala_frequency_squared(heights, potential_temperature,<EOL>axis=axis)<EOL>bv_freq_squared[bv_freq_squared.magnitude < <NUM_LIT:0>] = np.nan<EOL>return np.sqrt(bv_freq_squared)<EOL> | r"""Calculate the Brunt-Vaisala frequency.
This function will calculate the Brunt-Vaisala frequency as follows:
.. math:: N = \left( \frac{g}{\theta} \frac{d\theta}{dz} \right)^\frac{1}{2}
This formula based off of Equations 3.75 and 3.77 in [Hobbs2006]_.
This function is a wrapper for `brunt_vaisal... | f8476:m44 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def brunt_vaisala_period(heights, potential_temperature, axis=<NUM_LIT:0>): | bv_freq_squared = brunt_vaisala_frequency_squared(heights, potential_temperature,<EOL>axis=axis)<EOL>bv_freq_squared[bv_freq_squared.magnitude <= <NUM_LIT:0>] = np.nan<EOL>return <NUM_LIT:2> * np.pi / np.sqrt(bv_freq_squared)<EOL> | r"""Calculate the Brunt-Vaisala period.
This function is a helper function for `brunt_vaisala_frequency` that calculates the
period of oscilation as in Exercise 3.13 of [Hobbs2006]_:
.. math:: \tau = \frac{2\pi}{N}
Returns `NaN` when :math:`N^2 > 0`.
Parameters
----------
heights : array... | f8476:m45 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def wet_bulb_temperature(pressure, temperature, dewpoint): | if not hasattr(pressure, '<STR_LIT>'):<EOL><INDENT>pressure = atleast_1d(pressure)<EOL>temperature = atleast_1d(temperature)<EOL>dewpoint = atleast_1d(dewpoint)<EOL><DEDENT>it = np.nditer([pressure, temperature, dewpoint, None],<EOL>op_dtypes=['<STR_LIT:float>', '<STR_LIT:float>', '<STR_LIT:float>', '<STR_LIT:float>'],... | Calculate the wet-bulb temperature using Normand's rule.
This function calculates the wet-bulb temperature using the Normand method. The LCL is
computed, and that parcel brought down to the starting pressure along a moist adiabat.
The Normand method (and others) are described and compared by [Knox2017]_.
... | f8476:m46 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def static_stability(pressure, temperature, axis=<NUM_LIT:0>): | theta = potential_temperature(pressure, temperature)<EOL>return - mpconsts.Rd * temperature / pressure * first_derivative(np.log(theta / units.K),<EOL>x=pressure, axis=axis)<EOL> | r"""Calculate the static stability within a vertical profile.
.. math:: \sigma = -\frac{RT}{p} \frac{\partial \ln \theta}{\partial p}
This formuala is based on equation 4.3.6 in [Bluestein1992]_.
Parameters
----------
pressure : array-like
Profile of atmospheric pressure
temperature :... | f8476:m47 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def dewpoint_from_specific_humidity(specific_humidity, temperature, pressure): | return dewpoint_rh(temperature, relative_humidity_from_specific_humidity(specific_humidity,<EOL>temperature,<EOL>pressure))<EOL> | r"""Calculate the dewpoint from specific humidity, temperature, and pressure.
Parameters
----------
specific_humidity: `pint.Quantity`
Specific humidity of air
temperature: `pint.Quantity`
Air temperature
pressure: `pint.Quantity`
Total atmospheric pressure
Returns
... | f8476:m48 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def vertical_velocity_pressure(w, pressure, temperature, mixing=<NUM_LIT:0>): | rho = density(pressure, temperature, mixing)<EOL>return (- mpconsts.g * rho * w).to('<STR_LIT>')<EOL> | r"""Calculate omega from w assuming hydrostatic conditions.
This function converts vertical velocity with respect to height
:math:`\left(w = \frac{Dz}{Dt}\right)` to that
with respect to pressure :math:`\left(\omega = \frac{Dp}{Dt}\right)`
assuming hydrostatic conditions on the synoptic scale.
By E... | f8476:m49 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def vertical_velocity(omega, pressure, temperature, mixing=<NUM_LIT:0>): | rho = density(pressure, temperature, mixing)<EOL>return (omega / (- mpconsts.g * rho)).to('<STR_LIT>')<EOL> | r"""Calculate w from omega assuming hydrostatic conditions.
This function converts vertical velocity with respect to pressure
:math:`\left(\omega = \frac{Dp}{Dt}\right)` to that with respect to height
:math:`\left(w = \frac{Dz}{Dt}\right)` assuming hydrostatic conditions on
the synoptic scale. By Equat... | f8476:m50 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def precipitable_water(dewpt, pressure, bottom=None, top=None): | <EOL>sort_inds = np.argsort(pressure)[::-<NUM_LIT:1>]<EOL>pressure = pressure[sort_inds]<EOL>dewpt = dewpt[sort_inds]<EOL>if top is None:<EOL><INDENT>top = np.nanmin(pressure) * pressure.units<EOL><DEDENT>if bottom is None:<EOL><INDENT>bottom = np.nanmax(pressure) * pressure.units<EOL><DEDENT>pres_layer, dewpt_layer = ... | r"""Calculate precipitable water through the depth of a sounding.
Formula used is:
.. math:: -\frac{1}{\rho_l g} \int\limits_{p_\text{bottom}}^{p_\text{top}} r dp
from [Salby1996]_, p. 28.
Parameters
----------
dewpt : `pint.Quantity`
Atmospheric dewpoint profile
pressure : `pin... | f8477:m0 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def mean_pressure_weighted(pressure, *args, **kwargs): | heights = kwargs.pop('<STR_LIT>', None)<EOL>bottom = kwargs.pop('<STR_LIT>', None)<EOL>depth = kwargs.pop('<STR_LIT>', None)<EOL>ret = [] <EOL>layer_arg = get_layer(pressure, *args, heights=heights,<EOL>bottom=bottom, depth=depth)<EOL>layer_p = layer_arg[<NUM_LIT:0>]<EOL>layer_arg = layer_arg[<NUM_LIT:1>:]<EOL>pres_in... | r"""Calculate pressure-weighted mean of an arbitrary variable through a layer.
Layer top and bottom specified in height or pressure.
Parameters
----------
pressure : `pint.Quantity`
Atmospheric pressure profile
*args : `pint.Quantity`
Parameters for which the pressure-weighted mean... | f8477:m1 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def bunkers_storm_motion(pressure, u, v, heights): | <EOL>wind_mean = concatenate(mean_pressure_weighted(pressure, u, v, heights=heights,<EOL>depth=<NUM_LIT> * units('<STR_LIT>')))<EOL>wind_500m = concatenate(mean_pressure_weighted(pressure, u, v, heights=heights,<EOL>depth=<NUM_LIT> * units('<STR_LIT>')))<EOL>wind_5500m = concatenate(mean_pressure_weighted(pressure, u, ... | r"""Calculate the Bunkers right-mover and left-mover storm motions and sfc-6km mean flow.
Uses the storm motion calculation from [Bunkers2000]_.
Parameters
----------
pressure : array-like
Pressure from sounding
u : array-like
U component of the wind
v : array-like
V co... | f8477:m2 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def bulk_shear(pressure, u, v, heights=None, bottom=None, depth=None): | _, u_layer, v_layer = get_layer(pressure, u, v, heights=heights,<EOL>bottom=bottom, depth=depth)<EOL>u_shr = u_layer[-<NUM_LIT:1>] - u_layer[<NUM_LIT:0>]<EOL>v_shr = v_layer[-<NUM_LIT:1>] - v_layer[<NUM_LIT:0>]<EOL>return u_shr, v_shr<EOL> | r"""Calculate bulk shear through a layer.
Layer top and bottom specified in meters or pressure.
Parameters
----------
pressure : `pint.Quantity`
Atmospheric pressure profile
u : `pint.Quantity`
U-component of wind.
v : `pint.Quantity`
V-component of wind.
height : `... | f8477:m3 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def supercell_composite(mucape, effective_storm_helicity, effective_shear): | effective_shear = np.clip(atleast_1d(effective_shear), None, <NUM_LIT:20> * units('<STR_LIT>'))<EOL>effective_shear[effective_shear < <NUM_LIT:10> * units('<STR_LIT>')] = <NUM_LIT:0> * units('<STR_LIT>')<EOL>effective_shear = effective_shear / (<NUM_LIT:20> * units('<STR_LIT>'))<EOL>return ((mucape / (<NUM_LIT:1000> * ... | r"""Calculate the supercell composite parameter.
The supercell composite parameter is designed to identify
environments favorable for the development of supercells,
and is calculated using the formula developed by
[Thompson2004]_:
.. math:: \text{SCP} = \frac{\text{MUCAPE}}{1000 \text{J/kg}} *
... | f8477:m4 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def significant_tornado(sbcape, surface_based_lcl_height, storm_helicity_1km, shear_6km): | surface_based_lcl_height = np.clip(atleast_1d(surface_based_lcl_height),<EOL><NUM_LIT:1000> * units.m, <NUM_LIT> * units.m)<EOL>surface_based_lcl_height[surface_based_lcl_height > <NUM_LIT> * units.m] = <NUM_LIT:0> * units.m<EOL>surface_based_lcl_height = ((<NUM_LIT> * units.m - surface_based_lcl_height)<EOL>/ (<NUM_LI... | r"""Calculate the significant tornado parameter (fixed layer).
The significant tornado parameter is designed to identify
environments favorable for the production of significant
tornadoes contingent upon the development of supercells.
It's calculated according to the formula used on the SPC
mesoana... | f8477:m5 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def critical_angle(pressure, u, v, heights, stormu, stormv): | <EOL>u = u.to('<STR_LIT>')<EOL>v = v.to('<STR_LIT>')<EOL>stormu = stormu.to('<STR_LIT>')<EOL>stormv = stormv.to('<STR_LIT>')<EOL>sort_inds = np.argsort(pressure[::-<NUM_LIT:1>])<EOL>pressure = pressure[sort_inds]<EOL>heights = heights[sort_inds]<EOL>u = u[sort_inds]<EOL>v = v[sort_inds]<EOL>shr5 = bulk_shear(pressure, ... | r"""Calculate the critical angle.
The critical angle is the angle between the 10m storm-relative inflow vector
and the 10m-500m shear vector. A critical angle near 90 degrees indicates
that a storm in this environment on the indicated storm motion vector
is likely ingesting purely streamwise vorticity ... | f8477:m6 |
def get_bounds_data(): | pressures = np.linspace(<NUM_LIT:1000>, <NUM_LIT:100>, <NUM_LIT:10>) * units.hPa<EOL>heights = pressure_to_height_std(pressures)<EOL>return pressures, heights<EOL> | Provide pressure and height data for testing layer bounds calculation. | f8483:m15 |
@exporter.export<EOL>@preprocess_xarray<EOL>def wind_speed(u, v): | speed = np.sqrt(u * u + v * v)<EOL>return speed<EOL> | r"""Compute the wind speed from u and v-components.
Parameters
----------
u : array_like
Wind component in the X (East-West) direction
v : array_like
Wind component in the Y (North-South) direction
Returns
-------
wind speed: array_like
The speed of the wind
Se... | f8485:m0 |
@exporter.export<EOL>@preprocess_xarray<EOL>def wind_direction(u, v): | wdir = <NUM_LIT> * units.deg - np.arctan2(-v, -u)<EOL>origshape = wdir.shape<EOL>wdir = atleast_1d(wdir)<EOL>wdir[wdir <= <NUM_LIT:0>] += <NUM_LIT> * units.deg<EOL>calm_mask = (np.asarray(u) == <NUM_LIT:0.>) & (np.asarray(v) == <NUM_LIT:0.>)<EOL>if np.any(calm_mask):<EOL><INDENT>wdir[calm_mask] = <NUM_LIT:0.> * units.d... | r"""Compute the wind direction from u and v-components.
Parameters
----------
u : array_like
Wind component in the X (East-West) direction
v : array_like
Wind component in the Y (North-South) direction
Returns
-------
direction: `pint.Quantity`
The direction of the ... | f8485:m1 |
@exporter.export<EOL>@preprocess_xarray<EOL>def wind_components(speed, wdir): | wdir = _check_radians(wdir, max_radians=<NUM_LIT:4> * np.pi)<EOL>u = -speed * np.sin(wdir)<EOL>v = -speed * np.cos(wdir)<EOL>return u, v<EOL> | r"""Calculate the U, V wind vector components from the speed and direction.
Parameters
----------
speed : array_like
The wind speed (magnitude)
wdir : array_like
The wind direction, specified as the direction from which the wind is
blowing (0-2 pi radians or 0-360 degrees), with... | f8485:m2 |
@exporter.export<EOL>@preprocess_xarray<EOL>@deprecated('<STR_LIT>', addendum='<STR_LIT>',<EOL>pending=False)<EOL>def get_wind_speed(u, v): | return wind_speed(u, v)<EOL> | Wrap wind_speed for deprecated get_wind_speed function. | f8485:m3 |
@exporter.export<EOL>@preprocess_xarray<EOL>@deprecated('<STR_LIT>', addendum='<STR_LIT>',<EOL>pending=False)<EOL>def get_wind_dir(u, v): | return wind_direction(u, v)<EOL> | Wrap wind_direction for deprecated get_wind_dir function. | f8485:m4 |
@exporter.export<EOL>@preprocess_xarray<EOL>@deprecated('<STR_LIT>', addendum='<STR_LIT>',<EOL>pending=False)<EOL>def get_wind_components(u, v): | return wind_components(u, v)<EOL> | Wrap wind_components for deprecated get_wind_components function. | f8485:m5 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units(temperature='<STR_LIT>', speed='<STR_LIT>')<EOL>def windchill(temperature, speed, face_level_winds=False, mask_undefined=True): | <EOL>if face_level_winds:<EOL><INDENT>speed = speed * <NUM_LIT><EOL><DEDENT>temp_limit, speed_limit = <NUM_LIT> * units.degC, <NUM_LIT:3> * units.mph<EOL>speed_factor = speed.to('<STR_LIT>').magnitude ** <NUM_LIT><EOL>wcti = units.Quantity((<NUM_LIT> + <NUM_LIT> * speed_factor) * temperature.to('<STR_LIT>').magnitude<E... | r"""Calculate the Wind Chill Temperature Index (WCTI).
Calculates WCTI from the current temperature and wind speed using the formula
outlined by the FCM [FCMR192003]_.
Specifically, these formulas assume that wind speed is measured at
10m. If, instead, the speeds are measured at face level, the winds... | f8485:m6 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def heat_index(temperature, rh, mask_undefined=True): | delta = temperature.to(units.degF) - <NUM_LIT:0.> * units.degF<EOL>rh2 = rh * rh<EOL>delta2 = delta * delta<EOL>hi = (-<NUM_LIT> * units.degF<EOL>+ <NUM_LIT> * delta<EOL>+ <NUM_LIT> * units.delta_degF * rh<EOL>- <NUM_LIT> * delta * rh<EOL>- <NUM_LIT> / units.delta_degF * delta2<EOL>- <NUM_LIT> * units.delta_degF * rh2<... | r"""Calculate the Heat Index from the current temperature and relative humidity.
The implementation uses the formula outlined in [Rothfusz1990]_. This equation is a
multi-variable least-squares regression of the values obtained in [Steadman1979]_.
Parameters
----------
temperature : `pint.Quantity... | f8485:m7 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units(temperature='<STR_LIT>', speed='<STR_LIT>')<EOL>def apparent_temperature(temperature, rh, speed, face_level_winds=False): | is_not_scalar = isinstance(temperature.m, (list, tuple, np.ndarray))<EOL>temperature = atleast_1d(temperature)<EOL>rh = atleast_1d(rh)<EOL>speed = atleast_1d(speed)<EOL>wind_chill_temperature = windchill(temperature, speed, face_level_winds=face_level_winds,<EOL>mask_undefined=True).to(temperature.units)<EOL>heat_index... | r"""Calculate the current apparent temperature.
Calculates the current apparent temperature based on the wind chill or heat index
as appropriate for the current conditions. Follows [NWS10201]_.
Parameters
----------
temperature : `pint.Quantity`
The air temperature
rh : `pint.Quantity`... | f8485:m8 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def pressure_to_height_std(pressure): | t0 = <NUM_LIT> * units.kelvin<EOL>gamma = <NUM_LIT> * units('<STR_LIT>')<EOL>p0 = <NUM_LIT> * units.mbar<EOL>return (t0 / gamma) * (<NUM_LIT:1> - (pressure / p0).to('<STR_LIT>')**(<EOL>mpconsts.Rd * gamma / mpconsts.g))<EOL> | r"""Convert pressure data to heights using the U.S. standard atmosphere.
The implementation uses the formula outlined in [Hobbs1977]_ pg.60-61.
Parameters
----------
pressure : `pint.Quantity`
Atmospheric pressure
Returns
-------
`pint.Quantity`
The corresponding height va... | f8485:m9 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def height_to_geopotential(height): | <EOL>geopot = mpconsts.G * mpconsts.me * ((<NUM_LIT:1> / mpconsts.Re) - (<NUM_LIT:1> / (mpconsts.Re + height)))<EOL>return geopot<EOL> | r"""Compute geopotential for a given height.
Parameters
----------
height : `pint.Quantity`
Height above sea level (array_like)
Returns
-------
`pint.Quantity`
The corresponding geopotential value(s)
Examples
--------
>>> from metpy.constants import g, G, me, Re
... | f8485:m10 |
@exporter.export<EOL>@preprocess_xarray<EOL>def geopotential_to_height(geopot): | <EOL>height = (((<NUM_LIT:1> / mpconsts.Re) - (geopot / (mpconsts.G * mpconsts.me))) ** -<NUM_LIT:1>) - mpconsts.Re<EOL>return height<EOL> | r"""Compute height from a given geopotential.
Parameters
----------
geopotential : `pint.Quantity`
Geopotential (array_like)
Returns
-------
`pint.Quantity`
The corresponding height value(s)
Examples
--------
>>> from metpy.constants import g, G, me, Re
>>> imp... | f8485:m11 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def height_to_pressure_std(height): | t0 = <NUM_LIT> * units.kelvin<EOL>gamma = <NUM_LIT> * units('<STR_LIT>')<EOL>p0 = <NUM_LIT> * units.mbar<EOL>return p0 * (<NUM_LIT:1> - (gamma / t0) * height) ** (mpconsts.g / (mpconsts.Rd * gamma))<EOL> | r"""Convert height data to pressures using the U.S. standard atmosphere.
The implementation inverts the formula outlined in [Hobbs1977]_ pg.60-61.
Parameters
----------
height : `pint.Quantity`
Atmospheric height
Returns
-------
`pint.Quantity`
The corresponding pressure v... | f8485:m12 |
@exporter.export<EOL>@preprocess_xarray<EOL>def coriolis_parameter(latitude): | latitude = _check_radians(latitude, max_radians=np.pi / <NUM_LIT:2>)<EOL>return (<NUM_LIT> * mpconsts.omega * np.sin(latitude)).to('<STR_LIT>')<EOL> | r"""Calculate the coriolis parameter at each point.
The implementation uses the formula outlined in [Hobbs1977]_ pg.370-371.
Parameters
----------
latitude : array_like
Latitude at each point
Returns
-------
`pint.Quantity`
The corresponding coriolis force at each point | f8485:m13 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def add_height_to_pressure(pressure, height): | pressure_level_height = pressure_to_height_std(pressure)<EOL>return height_to_pressure_std(pressure_level_height + height)<EOL> | r"""Calculate the pressure at a certain height above another pressure level.
This assumes a standard atmosphere.
Parameters
----------
pressure : `pint.Quantity`
Pressure level
height : `pint.Quantity`
Height above a pressure level
Returns
-------
`pint.Quantity`
... | f8485:m14 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>')<EOL>def add_pressure_to_height(height, pressure): | pressure_at_height = height_to_pressure_std(height)<EOL>return pressure_to_height_std(pressure_at_height - pressure)<EOL> | r"""Calculate the height at a certain pressure above another height.
This assumes a standard atmosphere.
Parameters
----------
height : `pint.Quantity`
Height level
pressure : `pint.Quantity`
Pressure above height level
Returns
-------
`pint.Quantity`
The corre... | f8485:m15 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def sigma_to_pressure(sigma, psfc, ptop): | if np.any(sigma < <NUM_LIT:0>) or np.any(sigma > <NUM_LIT:1>):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if psfc.magnitude < <NUM_LIT:0> or ptop.magnitude < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return sigma * (psfc - ptop) + ptop<EOL> | r"""Calculate pressure from sigma values.
Parameters
----------
sigma : ndarray
The sigma levels to be converted to pressure levels.
psfc : `pint.Quantity`
The surface pressure value.
ptop : `pint.Quantity`
The pressure value at the top of the model domain.
Returns
... | f8485:m16 |
@exporter.export<EOL>@preprocess_xarray<EOL>def smooth_gaussian(scalar_grid, n): | <EOL>n = int(round(n))<EOL>if n < <NUM_LIT:2>:<EOL><INDENT>n = <NUM_LIT:2><EOL><DEDENT>sgma = n / (<NUM_LIT:2> * np.pi)<EOL>nax = len(scalar_grid.shape)<EOL>sgma_seq = [sgma if i > nax - <NUM_LIT:3> else <NUM_LIT:0> for i in range(nax)]<EOL>res = gaussian_filter(scalar_grid, sgma_seq, truncate=<NUM_LIT:2> * np.sqrt(<NU... | Filter with normal distribution of weights.
Parameters
----------
scalar_grid : `pint.Quantity`
Some n-dimensional scalar grid. If more than two axes, smoothing
is only done across the last two.
n : int
Degree of filtering
Returns
-------
`pint.Quantity`
Th... | f8485:m17 |
@exporter.export<EOL>@preprocess_xarray<EOL>def smooth_n_point(scalar_grid, n=<NUM_LIT:5>, passes=<NUM_LIT:1>): | if n == <NUM_LIT:9>:<EOL><INDENT>p = <NUM_LIT><EOL>q = <NUM_LIT><EOL>r = <NUM_LIT><EOL><DEDENT>elif n == <NUM_LIT:5>:<EOL><INDENT>p = <NUM_LIT:0.5><EOL>q = <NUM_LIT><EOL>r = <NUM_LIT:0.0><EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>smooth_grid = scalar_grid[:].copy()<EOL>for ... | Filter with normal distribution of weights.
Parameters
----------
scalar_grid : array-like or `pint.Quantity`
Some 2D scalar grid to be smoothed.
n: int
The number of points to use in smoothing, only valid inputs
are 5 and 9. Defaults to 5.
passes : int
The number ... | f8485:m18 |
def _check_radians(value, max_radians=<NUM_LIT:2> * np.pi): | try:<EOL><INDENT>value = value.to('<STR_LIT>').m<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>if np.greater(np.nanmax(np.abs(value)), max_radians):<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>'.format(max_radians))<EOL><DEDENT>return value<EOL> | Input validation of values that could be in degrees instead of radians.
Parameters
----------
value : `pint.Quantity`
The input value to check.
max_radians : float
Maximum absolute value of radians before warning.
Returns
-------
`pint.Quantity`
The input value | f8485:m19 |
def distances_from_cross_section(cross): | if (CFConventionHandler.check_axis(cross.metpy.x, '<STR_LIT>')<EOL>and CFConventionHandler.check_axis(cross.metpy.y, '<STR_LIT>')):<EOL><INDENT>from pyproj import Geod<EOL>g = Geod(cross.metpy.cartopy_crs.proj4_init)<EOL>lon = cross.metpy.x<EOL>lat = cross.metpy.y<EOL>forward_az, _, distance = g.inv(lon[<NUM_LIT:0>].va... | Calculate the distances in the x and y directions along a cross-section.
Parameters
----------
cross : `xarray.DataArray`
The input DataArray of a cross-section from which to obtain geometeric distances in
the x and y directions.
Returns
-------
x, y : tuple of `xarray.DataArra... | f8486:m0 |
def latitude_from_cross_section(cross): | y = cross.metpy.y<EOL>if CFConventionHandler.check_axis(y, '<STR_LIT>'):<EOL><INDENT>return y<EOL><DEDENT>else:<EOL><INDENT>import cartopy.crs as ccrs<EOL>latitude = ccrs.Geodetic().transform_points(cross.metpy.cartopy_crs,<EOL>cross.metpy.x.values,<EOL>y.values)[..., <NUM_LIT:1>]<EOL>latitude = xr.DataArray(latitude, ... | Calculate the latitude of points in a cross-section.
Parameters
----------
cross : `xarray.DataArray`
The input DataArray of a cross-section from which to obtain latitudes.
Returns
-------
latitude : `xarray.DataArray`
Latitude of points | f8486:m1 |
@exporter.export<EOL>def unit_vectors_from_cross_section(cross, index='<STR_LIT:index>'): | x, y = distances_from_cross_section(cross)<EOL>dx_di = first_derivative(x, axis=index).values<EOL>dy_di = first_derivative(y, axis=index).values<EOL>tangent_vector_mag = np.hypot(dx_di, dy_di)<EOL>unit_tangent_vector = np.vstack([dx_di / tangent_vector_mag, dy_di / tangent_vector_mag])<EOL>unit_normal_vector = np.vstac... | r"""Calculate the unit tanget and unit normal vectors from a cross-section.
Given a path described parametrically by :math:`\vec{l}(i) = (x(i), y(i))`, we can find
the unit tangent vector by the formula
.. math:: \vec{T}(i) =
\frac{1}{\sqrt{\left( \frac{dx}{di} \right)^2 + \left( \frac{dy}{di} \ri... | f8486:m2 |
@exporter.export<EOL>@check_matching_coordinates<EOL>def cross_section_components(data_x, data_y, index='<STR_LIT:index>'): | <EOL>unit_tang, unit_norm = unit_vectors_from_cross_section(data_x, index=index)<EOL>component_tang = data_x * unit_tang[<NUM_LIT:0>] + data_y * unit_tang[<NUM_LIT:1>]<EOL>component_norm = data_x * unit_norm[<NUM_LIT:0>] + data_y * unit_norm[<NUM_LIT:1>]<EOL>component_tang.attrs = {'<STR_LIT>': data_x.attrs['<STR_LIT>'... | r"""Obtain the tangential and normal components of a cross-section of a vector field.
Parameters
----------
data_x : `xarray.DataArray`
The input DataArray of the x-component (in terms of data projection) of the vector
field.
data_y : `xarray.DataArray`
The input DataArray of th... | f8486:m3 |
@exporter.export<EOL>@check_matching_coordinates<EOL>def normal_component(data_x, data_y, index='<STR_LIT:index>'): | <EOL>_, unit_norm = unit_vectors_from_cross_section(data_x, index=index)<EOL>component_norm = data_x * unit_norm[<NUM_LIT:0>] + data_y * unit_norm[<NUM_LIT:1>]<EOL>for attr in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if attr in data_x.attrs:<EOL><INDENT>component_norm.attrs[attr] = data_x.attrs[attr]<EOL><DEDENT><DEDENT... | r"""Obtain the normal component of a cross-section of a vector field.
Parameters
----------
data_x : `xarray.DataArray`
The input DataArray of the x-component (in terms of data projection) of the vector
field.
data_y : `xarray.DataArray`
The input DataArray of the y-component (i... | f8486:m4 |
@exporter.export<EOL>@check_matching_coordinates<EOL>def tangential_component(data_x, data_y, index='<STR_LIT:index>'): | <EOL>unit_tang, _ = unit_vectors_from_cross_section(data_x, index=index)<EOL>component_tang = data_x * unit_tang[<NUM_LIT:0>] + data_y * unit_tang[<NUM_LIT:1>]<EOL>for attr in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if attr in data_x.attrs:<EOL><INDENT>component_tang.attrs[attr] = data_x.attrs[attr]<EOL><DEDENT><DEDENT... | r"""Obtain the tangential component of a cross-section of a vector field.
Parameters
----------
data_x : `xarray.DataArray`
The input DataArray of the x-component (in terms of data projection) of the vector
field.
data_y : `xarray.DataArray`
The input DataArray of the y-componen... | f8486:m5 |
@exporter.export<EOL>@check_matching_coordinates<EOL>def absolute_momentum(u_wind, v_wind, index='<STR_LIT:index>'): | <EOL>norm_wind = normal_component(u_wind, v_wind, index=index)<EOL>norm_wind.metpy.convert_units('<STR_LIT>')<EOL>latitude = latitude_from_cross_section(norm_wind) <EOL>_, latitude = xr.broadcast(norm_wind, latitude)<EOL>f = coriolis_parameter(np.deg2rad(latitude.values)).magnitude <EOL>x, y = distances_from_cross_se... | r"""Calculate cross-sectional absolute momentum (also called pseudoangular momentum).
As given in [Schultz1999]_, absolute momentum (also called pseudoangular momentum) is
given by
.. math:: M = v + fx
where :math:`v` is the along-front component of the wind and :math:`x` is the cross-front
dista... | f8486:m6 |
@exporter.export<EOL>@preprocess_xarray<EOL>def resample_nn_1d(a, centers): | ix = []<EOL>for center in centers:<EOL><INDENT>index = (np.abs(a - center)).argmin()<EOL>if index not in ix:<EOL><INDENT>ix.append(index)<EOL><DEDENT><DEDENT>return ix<EOL> | Return one-dimensional nearest-neighbor indexes based on user-specified centers.
Parameters
----------
a : array-like
1-dimensional array of numeric values from which to
extract indexes of nearest-neighbors
centers : array-like
1-dimensional array of numeric values representing ... | f8488:m0 |
@exporter.export<EOL>@preprocess_xarray<EOL>def nearest_intersection_idx(a, b): | <EOL>difference = a - b<EOL>sign_change_idx, = np.nonzero(np.diff(np.sign(difference)))<EOL>return sign_change_idx<EOL> | Determine the index of the point just before two lines with common x values.
Parameters
----------
a : array-like
1-dimensional array of y-values for line 1
b : array-like
1-dimensional array of y-values for line 2
Returns
-------
An array of indexes representing the in... | f8488:m1 |
@exporter.export<EOL>@preprocess_xarray<EOL>@units.wraps(('<STR_LIT>', '<STR_LIT>'), ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'))<EOL>def find_intersections(x, a, b, direction='<STR_LIT:all>'): | <EOL>nearest_idx = nearest_intersection_idx(a, b)<EOL>next_idx = nearest_idx + <NUM_LIT:1><EOL>sign_change = np.sign(a[next_idx] - b[next_idx])<EOL>_, x0 = _next_non_masked_element(x, nearest_idx)<EOL>_, x1 = _next_non_masked_element(x, next_idx)<EOL>_, a0 = _next_non_masked_element(a, nearest_idx)<EOL>_, a1 = _next_no... | Calculate the best estimate of intersection.
Calculates the best estimates of the intersection of two y-value
data sets that share a common x-value set.
Parameters
----------
x : array-like
1-dimensional array of numeric x-values
a : array-like
1-dimensional array of y-values f... | f8488:m2 |
@exporter.export<EOL>@preprocess_xarray<EOL>@deprecated('<STR_LIT>', addendum=('<STR_LIT>'<EOL>'<STR_LIT>'), pending=False)<EOL>def interpolate_nans(x, y, kind='<STR_LIT>'): | return interpolate_nans_1d(x, y, kind=kind)<EOL> | Wrap interpolate_nans_1d for deprecated interpolate_nans. | f8488:m3 |
def _next_non_masked_element(a, idx): | try:<EOL><INDENT>next_idx = idx + a[idx:].mask.argmin()<EOL>if ma.is_masked(a[next_idx]):<EOL><INDENT>return None, None<EOL><DEDENT>else:<EOL><INDENT>return next_idx, a[next_idx]<EOL><DEDENT><DEDENT>except (AttributeError, TypeError, IndexError):<EOL><INDENT>return idx, a[idx]<EOL><DEDENT> | Return the next non masked element of a masked array.
If an array is masked, return the next non-masked element (if the given index is masked).
If no other unmasked points are after the given masked point, returns none.
Parameters
----------
a : array-like
1-dimensional array of numeric va... | f8488:m4 |
def _delete_masked_points(*arrs): | if any(hasattr(a, '<STR_LIT>') for a in arrs):<EOL><INDENT>keep = ~functools.reduce(np.logical_or, (np.ma.getmaskarray(a) for a in arrs))<EOL>return tuple(ma.asarray(a[keep]) for a in arrs)<EOL><DEDENT>else:<EOL><INDENT>return arrs<EOL><DEDENT> | Delete masked points from arrays.
Takes arrays and removes masked points to help with calculations and plotting.
Parameters
----------
arrs : one or more array-like
source arrays
Returns
-------
arrs : one or more array-like
arrays with masked elements removed | f8488:m5 |
@exporter.export<EOL>@preprocess_xarray<EOL>def reduce_point_density(points, radius, priority=None): | <EOL>if points.ndim < <NUM_LIT:2>:<EOL><INDENT>points = points.reshape(-<NUM_LIT:1>, <NUM_LIT:1>)<EOL><DEDENT>tree = cKDTree(points)<EOL>if priority is not None:<EOL><INDENT>sorted_indices = np.argsort(priority)[::-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>sorted_indices = range(len(points))<EOL><DEDENT>keep = np.ones... | r"""Return a mask to reduce the density of points in irregularly-spaced data.
This function is used to down-sample a collection of scattered points (e.g. surface
data), returning a mask that can be used to select the points from one or more arrays
(e.g. arrays of temperature and dew point). The points sele... | f8488:m6 |
def _get_bound_pressure_height(pressure, bound, heights=None, interpolate=True): | <EOL>sort_inds = np.argsort(pressure)[::-<NUM_LIT:1>]<EOL>pressure = pressure[sort_inds]<EOL>if heights is not None:<EOL><INDENT>heights = heights[sort_inds]<EOL><DEDENT>if bound.dimensionality == {'<STR_LIT>': -<NUM_LIT:1.0>, '<STR_LIT>': <NUM_LIT:1.0>, '<STR_LIT>': -<NUM_LIT>}:<EOL><INDENT>if bound in pressure:<EOL><... | Calculate the bounding pressure and height in a layer.
Given pressure, optional heights, and a bound, return either the closest pressure/height
or interpolated pressure/height. If no heights are provided, a standard atmosphere is
assumed.
Parameters
----------
pressure : `pint.Quantity`
... | f8488:m7 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def get_layer_heights(heights, depth, *args, **kwargs): | bottom = kwargs.pop('<STR_LIT>', None)<EOL>interpolate = kwargs.pop('<STR_LIT>', True)<EOL>with_agl = kwargs.pop('<STR_LIT>', False)<EOL>for datavar in args:<EOL><INDENT>if len(heights) != len(datavar):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>if with_agl:<EOL><INDENT>sfc_height = np.min(heights)<E... | Return an atmospheric layer from upper air data with the requested bottom and depth.
This function will subset an upper air dataset to contain only the specified layer using
the heights only.
Parameters
----------
heights : array-like
Atmospheric heights
depth : `pint.Quantity`
... | f8488:m8 |
@exporter.export<EOL>@preprocess_xarray<EOL>@check_units('<STR_LIT>')<EOL>def get_layer(pressure, *args, **kwargs): | <EOL>heights = kwargs.pop('<STR_LIT>', None)<EOL>bottom = kwargs.pop('<STR_LIT>', None)<EOL>depth = kwargs.pop('<STR_LIT>', <NUM_LIT:100> * units.hPa)<EOL>interpolate = kwargs.pop('<STR_LIT>', True)<EOL>if depth is None:<EOL><INDENT>depth = <NUM_LIT:100> * units.hPa<EOL><DEDENT>for datavar in args:<EOL><INDENT>if len(p... | r"""Return an atmospheric layer from upper air data with the requested bottom and depth.
This function will subset an upper air dataset to contain only the specified layer. The
bottom of the layer can be specified with a pressure or height above the surface
pressure. The bottom defaults to the surface pres... | f8488:m9 |
@exporter.export<EOL>@preprocess_xarray<EOL>@deprecated('<STR_LIT>', addendum=('<STR_LIT>'<EOL>'<STR_LIT>'), pending=False)<EOL>def interp(x, xp, *args, **kwargs): | return interpolate_1d(x, xp, *args, **kwargs)<EOL> | Wrap interpolate_1d for deprecated interp. | f8488:m10 |
@exporter.export<EOL>@preprocess_xarray<EOL>def find_bounding_indices(arr, values, axis, from_below=True): | <EOL>indices_shape = list(arr.shape)<EOL>indices_shape[axis] = len(values)<EOL>indices = np.empty(indices_shape, dtype=np.int)<EOL>good = np.empty(indices_shape, dtype=np.bool)<EOL>store_slice = [slice(None)] * arr.ndim<EOL>for level_index, value in enumerate(values):<EOL><INDENT>switches = np.abs(np.diff((arr <= value... | Find the indices surrounding the values within arr along axis.
Returns a set of above, below, good. Above and below are lists of arrays of indices.
These lists are formulated such that they can be used directly to index into a numpy
array and get the expected results (no extra slices or ellipsis necessary)... | f8488:m11 |
@exporter.export<EOL>@preprocess_xarray<EOL>@deprecated('<STR_LIT>', addendum=('<STR_LIT>'<EOL>'<STR_LIT>'), pending=False)<EOL>def log_interp(x, xp, *args, **kwargs): | return log_interpolate_1d(x, xp, *args, **kwargs)<EOL> | Wrap log_interpolate_1d for deprecated log_interp. | f8488:m12 |
def _greater_or_close(a, value, **kwargs): | return (a > value) | np.isclose(a, value, **kwargs)<EOL> | r"""Compare values for greater or close to boolean masks.
Returns a boolean mask for values greater than or equal to a target within a specified
absolute or relative tolerance (as in :func:`numpy.isclose`).
Parameters
----------
a : array-like
Array of values to be compared
value : flo... | f8488:m13 |
def _less_or_close(a, value, **kwargs): | return (a < value) | np.isclose(a, value, **kwargs)<EOL> | r"""Compare values for less or close to boolean masks.
Returns a boolean mask for values less than or equal to a target within a specified
absolute or relative tolerance (as in :func:`numpy.isclose`).
Parameters
----------
a : array-like
Array of values to be compared
value : float
... | f8488:m14 |
@deprecated('<STR_LIT>', addendum='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>pending=False)<EOL>@exporter.export<EOL>@preprocess_xarray<EOL>def lat_lon_grid_spacing(longitude, latitude, **kwargs): | <EOL>dx, dy = lat_lon_grid_deltas(longitude, latitude, **kwargs)<EOL>return np.abs(dx), np.abs(dy)<EOL> | r"""Calculate the distance between grid points that are in a latitude/longitude format.
Calculate the distance between grid points when the grid spacing is defined by
delta lat/lon rather than delta x/y
Parameters
----------
longitude : array_like
array of longitudes defining the grid
... | f8488:m15 |
@exporter.export<EOL>@preprocess_xarray<EOL>def lat_lon_grid_deltas(longitude, latitude, **kwargs): | from pyproj import Geod<EOL>if latitude.ndim != longitude.ndim:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if latitude.ndim < <NUM_LIT:2>:<EOL><INDENT>longitude, latitude = np.meshgrid(longitude, latitude)<EOL><DEDENT>geod_args = {'<STR_LIT>': '<STR_LIT>'}<EOL>if kwargs:<EOL><INDENT>geod_args = kwargs<EOL><D... | r"""Calculate the delta between grid points that are in a latitude/longitude format.
Calculate the signed delta distance between grid points when the grid spacing is defined by
delta lat/lon rather than delta x/y
Parameters
----------
longitude : array_like
array of longitudes defining the... | f8488:m16 |
@exporter.export<EOL>def grid_deltas_from_dataarray(f): | if f.metpy.crs['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>dx, dy = lat_lon_grid_deltas(f.metpy.x, f.metpy.y,<EOL>initstring=f.metpy.cartopy_crs.proj4_init)<EOL>slc_x = slc_y = tuple([np.newaxis] * (f.ndim - <NUM_LIT:2>) + [slice(None)] * <NUM_LIT:2>)<EOL><DEDENT>else:<EOL><INDENT>dx = np.diff(f.metpy.x.metpy.unit_array.t... | Calculate the horizontal deltas between grid points of a DataArray.
Calculate the signed delta distance between grid points of a DataArray in the horizontal
directions, whether the grid is lat/lon or x/y.
Parameters
----------
f : `xarray.DataArray`
Parsed DataArray on a latitude/longitude... | f8488:m17 |
def xarray_derivative_wrap(func): | @functools.wraps(func)<EOL>def wrapper(f, **kwargs):<EOL><INDENT>if '<STR_LIT:x>' in kwargs or '<STR_LIT>' in kwargs:<EOL><INDENT>return preprocess_xarray(func)(f, **kwargs)<EOL><DEDENT>elif isinstance(f, xr.DataArray):<EOL><INDENT>axis = f.metpy.find_axis_name(kwargs.get('<STR_LIT>', <NUM_LIT:0>))<EOL>new_kwargs = {'<... | Decorate the derivative functions to make them work nicely with DataArrays.
This will automatically determine if the coordinates can be pulled directly from the
DataArray, or if a call to lat_lon_grid_deltas is needed. | f8488:m18 |
@exporter.export<EOL>@xarray_derivative_wrap<EOL>def first_derivative(f, **kwargs): | n, axis, delta = _process_deriv_args(f, kwargs)<EOL>slice0 = [slice(None)] * n<EOL>slice1 = [slice(None)] * n<EOL>slice2 = [slice(None)] * n<EOL>delta_slice0 = [slice(None)] * n<EOL>delta_slice1 = [slice(None)] * n<EOL>slice0[axis] = slice(None, -<NUM_LIT:2>)<EOL>slice1[axis] = slice(<NUM_LIT:1>, -<NUM_LIT:1>)<EOL>slic... | Calculate the first derivative of a grid of values.
Works for both regularly-spaced data and grids with varying spacing.
Either `x` or `delta` must be specified, or `f` must be given as an `xarray.DataArray` with
attached coordinate and projection information. If `f` is an `xarray.DataArray`, and `x` or
... | f8488:m19 |
@exporter.export<EOL>@xarray_derivative_wrap<EOL>def second_derivative(f, **kwargs): | n, axis, delta = _process_deriv_args(f, kwargs)<EOL>slice0 = [slice(None)] * n<EOL>slice1 = [slice(None)] * n<EOL>slice2 = [slice(None)] * n<EOL>delta_slice0 = [slice(None)] * n<EOL>delta_slice1 = [slice(None)] * n<EOL>slice0[axis] = slice(None, -<NUM_LIT:2>)<EOL>slice1[axis] = slice(<NUM_LIT:1>, -<NUM_LIT:1>)<EOL>slic... | Calculate the second derivative of a grid of values.
Works for both regularly-spaced data and grids with varying spacing.
Either `x` or `delta` must be specified, or `f` must be given as an `xarray.DataArray` with
attached coordinate and projection information. If `f` is an `xarray.DataArray`, and `x` or
... | f8488:m20 |
@exporter.export<EOL>def gradient(f, **kwargs): | pos_kwarg, positions, axes = _process_gradient_args(f, kwargs)<EOL>return tuple(first_derivative(f, axis=axis, **{pos_kwarg: positions[ind]})<EOL>for ind, axis in enumerate(axes))<EOL> | Calculate the gradient of a grid of values.
Works for both regularly-spaced data, and grids with varying spacing.
Either `coordinates` or `deltas` must be specified, or `f` must be given as an
`xarray.DataArray` with attached coordinate and projection information. If `f` is an
`xarray.DataArray`, and... | f8488:m21 |
@exporter.export<EOL>def laplacian(f, **kwargs): | pos_kwarg, positions, axes = _process_gradient_args(f, kwargs)<EOL>derivs = [second_derivative(f, axis=axis, **{pos_kwarg: positions[ind]})<EOL>for ind, axis in enumerate(axes)]<EOL>laplac = sum(derivs)<EOL>if isinstance(derivs[<NUM_LIT:0>], xr.DataArray):<EOL><INDENT>laplac.attrs['<STR_LIT>'] = derivs[<NUM_LIT:0>].att... | Calculate the laplacian of a grid of values.
Works for both regularly-spaced data, and grids with varying spacing.
Either `coordinates` or `deltas` must be specified, or `f` must be given as an
`xarray.DataArray` with attached coordinate and projection information. If `f` is an
`xarray.DataArray`, an... | f8488:m22 |
def _broadcast_to_axis(arr, axis, ndim): | if arr.ndim == <NUM_LIT:1> and arr.ndim < ndim:<EOL><INDENT>new_shape = [<NUM_LIT:1>] * ndim<EOL>new_shape[axis] = arr.size<EOL>arr = arr.reshape(*new_shape)<EOL><DEDENT>return arr<EOL> | Handle reshaping coordinate array to have proper dimensionality.
This puts the values along the specified axis. | f8488:m23 |
def _process_gradient_args(f, kwargs): | axes = kwargs.get('<STR_LIT>', range(f.ndim))<EOL>def _check_length(positions):<EOL><INDENT>if '<STR_LIT>' in kwargs and len(positions) < len(axes):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>elif '<STR_LIT>' not in kwargs and len(positions) != len(axes):<EOL><INDENT>raise ValueError('<STR_LI... | Handle common processing of arguments for gradient and gradient-like functions. | f8488:m24 |
def _process_deriv_args(f, kwargs): | n = f.ndim<EOL>axis = normalize_axis_index(kwargs.get('<STR_LIT>', <NUM_LIT:0>), n)<EOL>if f.shape[axis] < <NUM_LIT:3>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>if '<STR_LIT:x>' in kwargs:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>delta = atleast_1d(kwargs[... | Handle common processing of arguments for derivative functions. | f8488:m25 |
@exporter.export<EOL>@preprocess_xarray<EOL>def parse_angle(input_dir): | if isinstance(input_dir, str):<EOL><INDENT>abb_dirs = [_abbrieviate_direction(input_dir)]<EOL><DEDENT>elif isinstance(input_dir, list):<EOL><INDENT>input_dir_str = '<STR_LIT:U+002C>'.join(input_dir)<EOL>abb_dir_str = _abbrieviate_direction(input_dir_str)<EOL>abb_dirs = abb_dir_str.split('<STR_LIT:U+002C>')<EOL><DEDENT>... | Calculate the meteorological angle from directional text.
Works for abbrieviations or whole words (E -> 90 | South -> 180)
and also is able to parse 22.5 degreee angles such as ESE/East South East
Parameters
----------
input_dir : string or array-like strings
Directional text such as west,... | f8488:m26 |
def _abbrieviate_direction(ext_dir_str): | return (ext_dir_str<EOL>.upper()<EOL>.replace('<STR_LIT:_>', '<STR_LIT>')<EOL>.replace('<STR_LIT:->', '<STR_LIT>')<EOL>.replace('<STR_LIT:U+0020>', '<STR_LIT>')<EOL>.replace('<STR_LIT>', '<STR_LIT:N>')<EOL>.replace('<STR_LIT>', '<STR_LIT:E>')<EOL>.replace('<STR_LIT>', '<STR_LIT:S>')<EOL>.replace('<STR_LIT>', '<STR_LIT>... | Convert extended (non-abbrievated) directions to abbrieviation. | f8488:m27 |
@exporter.export<EOL>@preprocess_xarray<EOL>def get_perturbation(ts, axis=-<NUM_LIT:1>): | slices = [slice(None)] * ts.ndim<EOL>slices[axis] = None<EOL>mean = ts.mean(axis=axis)[tuple(slices)]<EOL>return ts - mean<EOL> | r"""Compute the perturbation from the mean of a time series.
Parameters
----------
ts : array_like
The time series from which you wish to find the perturbation
time series (perturbation from the mean).
Returns
-------
array_like
The perturbation time series.
Othe... | f8489:m0 |
@exporter.export<EOL>@preprocess_xarray<EOL>def tke(u, v, w, perturbation=False, axis=-<NUM_LIT:1>): | if not perturbation:<EOL><INDENT>u = get_perturbation(u, axis=axis)<EOL>v = get_perturbation(v, axis=axis)<EOL>w = get_perturbation(w, axis=axis)<EOL><DEDENT>u_cont = np.mean(u * u, axis=axis)<EOL>v_cont = np.mean(v * v, axis=axis)<EOL>w_cont = np.mean(w * w, axis=axis)<EOL>return <NUM_LIT:0.5> * np.sqrt(u_cont + v_con... | r"""Compute turbulence kinetic energy.
Compute the turbulence kinetic energy (e) from the time series of the
velocity components.
Parameters
----------
u : array_like
The wind component along the x-axis
v : array_like
The wind component along the y-axis
w : array_like
... | f8489:m1 |
@exporter.export<EOL>@preprocess_xarray<EOL>def kinematic_flux(vel, b, perturbation=False, axis=-<NUM_LIT:1>): | kf = np.mean(vel * b, axis=axis)<EOL>if not perturbation:<EOL><INDENT>kf -= np.mean(vel, axis=axis) * np.mean(b, axis=axis)<EOL><DEDENT>return np.atleast_1d(kf)<EOL> | r"""Compute the kinematic flux from two time series.
Compute the kinematic flux from the time series of two variables `vel`
and b. Note that to be a kinematic flux, at least one variable must be
a component of velocity.
Parameters
----------
vel : array_like
A component of velocity
... | f8489:m2 |
@exporter.export<EOL>@preprocess_xarray<EOL>def friction_velocity(u, w, v=None, perturbation=False, axis=-<NUM_LIT:1>): | uw = kinematic_flux(u, w, perturbation=perturbation, axis=axis)<EOL>kf = uw * uw<EOL>if v is not None:<EOL><INDENT>vw = kinematic_flux(v, w, perturbation=perturbation, axis=axis)<EOL>kf += vw * vw<EOL><DEDENT>np.sqrt(kf, out=kf)<EOL>return np.sqrt(kf)<EOL> | r"""Compute the friction velocity from the time series of velocity components.
Compute the friction velocity from the time series of the x, z,
and optionally y, velocity components.
Parameters
----------
u : array_like
The wind component along the x-axis
w : array_like
The wind... | f8489:m3 |
def _make_datetime(s): | s = bytearray(s) <EOL>year, month, day, hour, minute, second, cs = s<EOL>if year < <NUM_LIT>:<EOL><INDENT>year += <NUM_LIT:100><EOL><DEDENT>return datetime(<NUM_LIT> + year, month, day, hour, minute, second, <NUM_LIT> * cs)<EOL> | r"""Convert 7 bytes from a GINI file to a `datetime` instance. | f8494:m0 |
def _scaled_int(s): | s = bytearray(s) <EOL>sign = <NUM_LIT:1> - ((s[<NUM_LIT:0>] & <NUM_LIT>) >> <NUM_LIT:6>)<EOL>int_val = (((s[<NUM_LIT:0>] & <NUM_LIT>) << <NUM_LIT:16>) | (s[<NUM_LIT:1>] << <NUM_LIT:8>) | s[<NUM_LIT:2>])<EOL>log.debug('<STR_LIT>', '<STR_LIT:U+0020>'.join(hex(c) for c in s), int_val, sign)<EOL>return (sign * int_val) / ... | r"""Convert a 3 byte string to a signed integer value. | f8494:m1 |
def _name_lookup(names): | mapper = dict(zip(range(len(names)), names))<EOL>def lookup(val):<EOL><INDENT>return mapper.get(val, '<STR_LIT>')<EOL><DEDENT>return lookup<EOL> | r"""Create an io helper to convert an integer to a named value. | f8494:m2 |
def _add_projection_coords(ds, prod_desc, proj_var, dx, dy): | proj = cf_to_proj(proj_var)<EOL>x0, y0 = proj(prod_desc.lo1, prod_desc.la1)<EOL>ds.createDimension('<STR_LIT:x>', prod_desc.nx)<EOL>x_var = ds.createVariable('<STR_LIT:x>', np.float64, dimensions=('<STR_LIT:x>',))<EOL>x_var.units = '<STR_LIT:m>'<EOL>x_var.long_name = '<STR_LIT>'<EOL>x_var.standard_name = '<STR_LIT>'<EO... | Add coordinate variables (projection and lon/lat) to a dataset. | f8494:m3 |
def __init__(self, filename): | fobj = open_as_needed(filename)<EOL>with contextlib.closing(fobj):<EOL><INDENT>self._buffer = IOBuffer.fromfile(fobj)<EOL><DEDENT>self.wmo_code = '<STR_LIT>'<EOL>self._process_wmo_header()<EOL>log.debug('<STR_LIT>', self.wmo_code)<EOL>log.debug('<STR_LIT>', len(self._buffer))<EOL>self._buffer = IOBuffer(self._buffer.re... | r"""Create an instance of `GiniFile`.
Parameters
----------
filename : str or file-like object
If str, the name of the file to be opened. Gzip-ed files are
recognized with the extension ``'.gz'``, as are bzip2-ed files with
the extension ``'.bz2'`` If `filena... | f8494:c1:m0 |
@deprecated(<NUM_LIT>, alternative='<STR_LIT>')<EOL><INDENT>def to_dataset(self):<DEDENT> | ds = Dataset()<EOL>ds.createDimension('<STR_LIT:time>', <NUM_LIT:1>)<EOL>time_var = ds.createVariable('<STR_LIT:time>', np.int32, dimensions=('<STR_LIT:time>',))<EOL>base_time = self.prod_desc.datetime.replace(hour=<NUM_LIT:0>, minute=<NUM_LIT:0>, second=<NUM_LIT:0>, microsecond=<NUM_LIT:0>)<EOL>time_var.units = '<STR_... | Convert to a CDM dataset.
Gives a representation of the data in a much more user-friendly manner, providing
easy access to Variables and relevant attributes.
Returns
-------
Dataset
.. deprecated:: 0.8.0 | f8494:c1:m1 |
def _process_wmo_header(self): | data = self._buffer.get_next(<NUM_LIT:64>).decode('<STR_LIT:utf-8>', '<STR_LIT:ignore>')<EOL>match = self.wmo_finder.search(data)<EOL>if match:<EOL><INDENT>self.wmo_code = match.groups()[<NUM_LIT:0>]<EOL>self.siteID = match.groups()[-<NUM_LIT:1>]<EOL>self._buffer.skip(match.end())<EOL><DEDENT> | Read off the WMO header from the file, if necessary. | f8494:c1:m2 |
def __str__(self): | parts = [self.__class__.__name__ + '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>']<EOL>return '<STR_LIT>'.join(parts).format(self.prod_desc, self.prod_desc2)<EOL> | Return a string representation of the product. | f8494:c1:m3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.