def qtmax(var, qt=95.): """Get max using quantiles This is useful for very asymmetic distributions :Params: - **var**: A numeric array. - **qt**, optional: Percentile used to define max """ if N.ma.isMA(var): var = var.compressed() qt = N.clip([qt], 0, 100.) vmax = percentiles(var.ravel(), qt) return vmax
def qtminmax(var, qt=5.): """Get min and max using quantiles This is useful for very asymmetic distributions :Params: - **var**: A numeric array. - **qt**, optional: Percentile used to define min and max - Single number: ``qt`` -> ``[qt, 100-qt]`` - Two elements: used directly. """ if N.ma.isMA(var): var = var.compressed() if not hasattr(qt, '__len__'): qt = [qt, 100-qt] qt = N.sort(N.clip(N.asarray(qt), 0, 100.)) vmin, vmax = percentiles(var.ravel(), qt) return vmin, vmax