Processing

baseline

pycomlink.processing.baseline.baseline_constant(trsl, wet, n_average_last_dry=1)

Build baseline with constant level during a wet period

Parameters:
  • trsl (numpy.array or pandas.Series) – Transmitted signal level minus received signal level (TRSL) or received signal level or t

  • wet (numpy.array or pandas.Series) – Information if classified index of times series is wet (True) or dry (False). Note that NaN`s in `wet will lead to NaN`s in `baseline also after the NaN period since it is then not clear whether or not there was a change of wet/dry within the NaN period.

  • n_average_last_dry (int, default = 1) – Number of last baseline values before start of wet event that should be averaged to get the value of the baseline during the wet event. Note that this values should not be too large because the baseline might be at an expected level, e.g. if another wet event is ending shortly before.

Returns:

baseline – Baseline during wet period

Return type:

numpy.array

pycomlink.processing.baseline.baseline_linear(rsl, wet, ignore_nan=False)

Build baseline with linear interpolation from start till end of wet period

Parameters:
  • rsl (numpy.array or pandas.Series) –

    Received signal level or transmitted signal level minus received

    signal level

  • wet (numpy.array or pandas.Series) – Information if classified index of times series is wet (True) or dry (False). Note that NaN`s in `wet will lead to NaN`s in `baseline also after the NaN period since it is then not clear wheter there was a change of wet/dry within the NaN period.

  • ignore_nan (bool) – If set to True the last wet/dry state before a NaN will be used for deriving the baseline. If set to False, the baseline for any wet period which contains a NaN will be set to NaN for the duration of the wet period. Default is False.

Returns:

baseline – Baseline during wet period

Return type:

numpy.array

k_R_relation

pycomlink.processing.k_R_relation.a_b(f_GHz, pol, approx_type='ITU_2005')

Approximation of parameters a and b for k-R power law

Parameters:
  • f_GHz (int, float, np.array or xr.DataArray) – Frequency of the microwave link(s) in GHz.

  • pol (str, np.array or xr.DataArray) – Polarization, that is either ‘horizontal’ for horizontal or ‘vertical’ for vertical. ‘H’, ‘h’ and ‘Horizontal’ as well as ‘V’, ‘v’ and ‘Vertical’ are also allowed. Must have same shape as f_GHz or be a str. If it is a str, it will be expanded to the shape of f_GHz.

  • approx_type (str, optional) – Approximation type (the default is ‘ITU_2005’, which implies parameter approximation using a table recommanded by ITU in 2005. An older version of 2003 is available via ‘ITU_2003’.)

Returns:

a,b – Parameters of A-R relationship

Return type:

float

Note

The frequency value must be between 1 Ghz and 100 GHz.

The polarization has to be indicated by ‘h’ or ‘H’ for horizontal and ‘v’ or ‘V’ for vertical polarization respectively.

Currently only ‘ITU’ for approx_type is accepted. The approximation makes use of a table recommanded by ITU [4]. There are two versions available, P.838-2 (04/2003) and P.838-3 (03/2005).

References

pycomlink.processing.k_R_relation.calc_R_from_A(A, L_km, f_GHz=None, pol=None, a=None, b=None, a_b_approximation='ITU_2005', R_min=0.1)

Calculate rain rate from path-integrated attenuation using the k-R power law

Note that either f_GHz and pol or a and b have to be provided. The former option calculates the parameters a and b for the k-R power law internally based on frequency and polarization.

Parameters:
  • A (float or iterable of float) – Path-integrated attenuation of microwave link signal

  • L_km (float) – Length of the link in km

  • f_GHz (float, np.array, or xr.DataArray optional) – Frequency in GHz. If provided together with pol, it will be used to derive the parameters a and b for the k-R power law.

  • pol (string, np.array or xr.DataArray optional) – Polarization, that is either ‘horizontal’ for horizontal or ‘vertical’ for vertical. ‘H’, ‘h’ and ‘Horizontal’ as well as ‘V’, ‘v’ and ‘Vertical’ are also allowed. Has to be provided together with f_GHz. It will be used to derive the parameters a and b for the k-R power law. Must have same shape as f_GHz or be a str. If it is a str, it will be expanded to the shape of f_GHz.

  • a (float, optional) – Parameter of A-R relationship

  • b (float, optional) – Parameter of A-R relationship

  • a_b_approximation (string) – Specifies which approximation for the k-R power law shall be used. See the function a_b for details.

  • R_min (float) – Minimal rain rate in mm/h. Everything below will be set to zero.

Returns:

Rain rate

Return type:

float or iterable of float

Note

The A-R and k-R relation are defined as

\[A = k L_{km} = aR^{b} L_{km}\]

where A is the path-integrated attenuation in dB and k is the specific attenuation in dB/km.

pycomlink.processing.k_R_relation.calc_R_from_A_min_max(Ar_max, L, f_GHz=None, a=None, b=None, pol='H', R_min=0.1, k=90)

Calculate rain rate from attenuation using the A-R Relationship

Parameters:
  • Ar_max (float or iterable of float) – Attenuation of microwave signal (with min/max measurements of RSL/TSL)

  • f_GHz (float, optional) – Frequency in GHz

  • pol (string) – Polarization, default is ‘H’

  • a (float, optional) – Parameter of A-R relationship

  • b (float, optional) – Parameter of A-R relationship

  • L (float) – length of the link

  • R_min (float) – Minimal rain rate in mm/h. Everything below will be set to zero.

  • k (int, optional) – number of measurements between two consecutive measurement of rx/tx

Returns:

Rain rate

Return type:

float or iterable of float

Note

Based on: “Empirical Study of the Quantization Bias Effects in Commercial Microwave Links Min/Max Attenuation Measurements for Rain Monitoring” by OSTROMETZKY J., ESHEL A.

min_max

wet_antenna

pycomlink.processing.wet_antenna.eps_water(f_Hz, T_K)

Calculate the dielectric permitiviy of water

Formulas taken from dielectric permittivity of liquid water without salt according to Liebe et al. 1991 Int. J. IR+mm Waves 12(12), 659-675

Based on MATLAB code by Christian Mätzler, June 2002 Cosmetic changes by Christian Chwala, August 2012

Parameters:
  • f_Hz (array-like) – Frequency in Hz

  • T_K (float) – Temperature in Kelvin

Returns:

eps

Return type:

np.complex

pycomlink.processing.wet_antenna.waa_leijnse_2008(R, f_Hz, T_K=293.0, gamma=2.06e-05, delta=0.24, n_antenna=1.73 + 0.014j, l_antenna=0.001)

Calculate wet antenna attenuation according to Leijnse et al. 2008

Calculate the wet antenna attenuation assuming a rain rate dependent thin flat water film on the antenna following the results from [3]_.

Water film thickness:

l = gamma * R ** delta

Parameters:
  • R (array-like or scalar) – Rain rate in mm/h

  • f_Hz (array-like or scalar (but only either R or f_Hz can be array)) – Frequency of CML in Hz

  • gamma (float) – Parameter that determines the magnitutde of the water film thickness

  • delta (float) – Parameter that determines the non-linearity of the relation between water film thickness and rain rates

  • n_antenna (float) – Refractive index of antenna material

  • l_antenna (float) – Thickness of antenna cover

Returns:

waa – Wet antenna attenuation in dB

Return type:

array-like

References

pycomlink.processing.wet_antenna.waa_leijnse_2008_from_A_obs(A_obs, f_Hz, pol, L_km, T_K=293.0, gamma=2.06e-05, delta=0.24, n_antenna=1.73 + 0.014j, l_antenna=0.001)

Calculate wet antenna attenuation according to Leijnse et al. 2008

Calculate the wet antenna attenuation from observed attenuation, using the method proposed in [2], assuming a rain rate dependent thin flat water film on the antenna.

The equations proposed in [2] calculate the WAA from the rain rate R. With CML data the rain rates is not directly available. We need to use the observed attenuation to derive the WAA. This is done here by building a look-up-table for the relation between A_obs and WAA, where A_obs is calculated as A_obs = A_rain + WAA. A_rain is derived from the A-R relation for the given CML frequency and length.

Parameters:
  • A_obs (array-like or scalar) – Observed attenuation

  • f_Hz (array-like or scalar (but only either R or f_Hz can be array)) – Frequency of CML in Hz

  • pol (string) – Polarization of CML. Has to be either ‘H’ or ‘V’.

  • L_km (float) – Lenght of CML in kilometer

  • gamma (float) – Parameter that determines the magnitutde of the water film thickness

  • delta (float) – Parameter that determines the non-linearity of the relation between water film thickness and rain rates

  • n_antenna (float) – Refractive index of antenna material

  • l_antenna (float) – Thickness of antenna cover

Returns:

waa – Wet antenna attenuation in dB

Return type:

array-like

References

pycomlink.processing.wet_antenna.waa_pastorek_2021(R, A_max=14, zeta=0.55, d=0.1)

Calculate wet antenna attenuation according to Pastorek et al. 2021 [3] (model denoted “KR-alt” in their study, i.e. a variation of the WAA model suggested by Kharadly and Ross 2001 [4])

Calculate the wet antenna from rain rate explicitly assuming an upper limit A_max.

Parameters:
  • A_max (upper bound of WAA (“C” in [3]))

  • R (array-like or scalar) – Rain rate in mm/h

  • zeta (power-law parameters)

  • d (power-law parameters)

Returns:

waa – Wet antenna attenuation in dB

Return type:

array-like

References

pycomlink.processing.wet_antenna.waa_pastorek_2021_from_A_obs(A_obs, f_Hz, pol, L_km, A_max=14, zeta=0.55, d=0.1)

Calculate wet antenna attenuation according to Pastorek et al. 2021 [3] (model denoted “KR-alt” in their study, i.e. a variation of the WAA model suggested by Kharadly and Ross 2001 [4])

Calculate the wet antenna from rain rate explicitly assuming an upper limit A_max.

The equation proposed in [3] calculates the WAA from the rain rate R. With CML data the rain rates is not directly available. We need to use the observed attenuation to derive the WAA. This is done here by building a look-up-table for the relation between A_obs and WAA, where A_obs is calculated as A_obs = A_rain + WAA. A_rain is derived from the A-R relation for the given CML frequency and length.

Parameters:
  • A_max (upper bound of WAA (“C” in [3]))

  • R (array-like or scalar) – Rain rate in mm/h

  • f_Hz (array-like or scalar (but only either R or f_Hz can be array)) – Frequency of CML in Hz

  • pol (string) – Polarisation of CML. Must be either ‘H’ or ‘V’.

  • L_km (float) – Lenght of CML in kilometer

  • zeta (power-law parameters)

  • d (power-law parameters)

Returns:

waa – Wet antenna attenuation in dB

Return type:

array-like

References

pycomlink.processing.wet_antenna.waa_schleiss_2013(rsl, baseline, wet, waa_max, delta_t, tau)

Calculate WAA according to Schleiss et al 2013

Parameters:
  • rsl (iterable of float) – Time series of received signal level

  • baseline (iterable of float) – Time series of baseline for rsl

  • wet (iterable of int or iterable of float) – Time series with wet/dry classification information.

  • waa_max (float) – Maximum value of wet antenna attenuation

  • delta_t (float) – Parameter for wet antenna attention model

  • tau (float) – Parameter for wet antenna attenuation model

Returns:

Time series of wet antenna attenuation

Return type:

iterable of float

Note

The wet antenna adjusting is based on a peer-reviewed publication [1]

References

xarray_wrapper

pycomlink.processing.xarray_wrapper.xarray_apply_along_time_dim()

A decorator to apply CML processing function along the time dimension of DataArrays

This will work if the decorated function takes 1D numpy arrays, which hold the CML time series data, as arguments. Additional argument are also handled.