code: def _qmed_from_pot_records(self):
          
          pot_dataset = self.catchment.pot_dataset
          if not pot_dataset:
              raise InsufficientDataError("POT dataset must be set for catchment {} to estimate QMED from POT data."
                                          .format(self.catchment.id))
  
          complete_year_records, length = self._complete_pot_years(pot_dataset)
          if length < 1:
              raise InsufficientDataError("Insufficient POT flow records available for catchment {}."
                                          .format(self.catchment.id))
  
          position = 0.790715789 * length + 0.539684211
          i = floor(position)
          w = 1 + i - position  # This is equivalent to table 12.1!
  
          flows = [record.flow for record in complete_year_records]
          flows.sort(reverse=True)
  
          return w * flows[i - 1] + (1 - w) * flows[i]
docs: Return QMED estimate based on peaks-over-threshold (POT) records.
  
          Methodology source: FEH, Vol. 3, pp. 77-78
  
          :return: QMED in m³/s
          :rtype: float