watex.utils.funcutils.ismissing#

watex.utils.funcutils.ismissing(refarr, arr, fill_value=nan, return_index=False)[source]#

Get the missing values in array-like and fill it to match the length of the reference array.

The function makes sense especially for frequency interpollation in the ‘attenuation band’ when using the audio-frequency magnetotelluric methods.

Parameters:
  • arr – array-like- Array to be extended with fill value. It should be shorter than the refarr. Otherwise it returns the same array arr

  • refarr – array-like- the reference array. It should have a greater length than the array

  • fill_value – float - Value to fill the arr to match the length of the refarr.

  • return_index – bool or str - array-like, index of the elements element in arr. Default is False. Any other value should returns the mask of existing element in reference array

Returns:

array and values missings or indexes in reference array.

Example:

>>> import numpy as np
>>> from watex.utils.funcutils import ismissing
>>> refreq = np.linspace(7e7, 1e0, 20) # 20 frequencies as reference
>>> # remove the value between index 7 to 12 and stack again
>>> freq = np.hstack ((refreq.copy()[:7], refreq.copy()[12:] ))
>>> f, m  = ismissing (refreq, freq)
>>> f, m
...array([7.00000000e+07, 6.63157895e+07, 6.26315791e+07, 5.89473686e+07,
       5.52631581e+07, 5.15789476e+07, 4.78947372e+07,            nan,
                  nan,            nan,            nan,            nan,
       2.57894743e+07, 2.21052638e+07, 1.84210534e+07, 1.47368429e+07,
       1.10526324e+07, 7.36842195e+06, 3.68421147e+06, 1.00000000e+00])
>>> m # missing values
... array([44210526.68421052, 40526316.21052632, 36842105.73684211,
       33157895.2631579 , 29473684.78947368])
>>>  _, m_ix  = ismissing (refreq, freq, return_index =True)
>>> m_ix
... array([ 7,  8,  9, 10, 11], dtype=int64)
>>> # assert the missing values from reference values
>>> refreq[m_ix ] # is equal to m
... array([44210526.68421052, 40526316.21052632, 36842105.73684211,
       33157895.2631579 , 29473684.78947368])