code: def maskedNanPercentile(maskedArray, percentiles, *args, **kwargs):
      
  
      #https://docs.scipy.org/doc/numpy/reference/maskedarray.generic.html#accessing-the-data
      awm = ArrayWithMask.createFromMaskedArray(maskedArray)
  
      maskIdx = awm.maskIndex()
      validData = awm.data[~maskIdx]
  
      if len(validData) >= 1:
          result = np.nanpercentile(validData, percentiles, *args, **kwargs)
      else:
          # If np.nanpercentile on an empty list only returns a single Nan. We correct this here.
          result = len(percentiles) * [np.nan]
  
      assert len(result) == len(percentiles), \
          "shape mismatch: {} != {}".format(len(result), len(percentiles))
  
      return result
docs: Calculates np.nanpercentile on the non-masked values