Module diskchef.engine.other

Expand source code
import os
from typing import Union

import matplotlib.colors
import numpy as np
import scipy.interpolate

PathLike = Union[str, os.PathLike]


class LogNormMaxOrders(matplotlib.colors.LogNorm):
    """`matplotlib.colors.LogNorm` subclass with maximal range"""

    def __init__(self, vmin=None, vmax=None, clip=False, maxdepth: float = 1e6):
        self.maxdepth = maxdepth
        super().__init__(vmin, vmax, clip)

    def autoscale_None(self, A):
        super().autoscale_None(A)
        self.vmin = max([self.vmin, self.vmax / self.maxdepth])

class unsorted_interp2d(scipy.interpolate.interp2d):
    """interp2d subclass that remembers original order of data points"""

    def __call__(self, x, y, dx=0, dy=0, assume_sorted=None):
        unsorted_idxs = np.argsort(np.argsort(x))
        return scipy.interpolate.interp2d.__call__(self, x, y, dx=dx, dy=dy)[unsorted_idxs]

Classes

class LogNormMaxOrders (vmin=None, vmax=None, clip=False, maxdepth: float = 1000000.0)

matplotlib.colors.LogNorm subclass with maximal range

Parameters

vmin, vmax : float or None
If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).
clip : bool, default: False

If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked.

Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.

Notes

Returns 0 if vmin == vmax.

Expand source code
class LogNormMaxOrders(matplotlib.colors.LogNorm):
    """`matplotlib.colors.LogNorm` subclass with maximal range"""

    def __init__(self, vmin=None, vmax=None, clip=False, maxdepth: float = 1e6):
        self.maxdepth = maxdepth
        super().__init__(vmin, vmax, clip)

    def autoscale_None(self, A):
        super().autoscale_None(A)
        self.vmin = max([self.vmin, self.vmax / self.maxdepth])

Ancestors

  • matplotlib.colors.LogNorm
  • matplotlib.colors.Normalize

Methods

def autoscale_None(self, A)

If vmin or vmax are not set, use the min/max of A to set them.

Expand source code
def autoscale_None(self, A):
    super().autoscale_None(A)
    self.vmin = max([self.vmin, self.vmax / self.maxdepth])
class unsorted_interp2d (**kwds)

interp2d subclass that remembers original order of data points

interp2d is deprecated! interp2d is deprecated in SciPy 1.10 and will be removed in SciPy 1.12.0.

For legacy code, nearly bug-for-bug compatible replacements are RectBivariateSpline on regular grids, and bisplrep/bisplev for scattered 2D data.

In new code, for regular grids use RegularGridInterpolator instead. For scattered data, prefer LinearNDInterpolator or CloughTocher2DInterpolator.

For more details see https://gist.github.com/ev-br/8544371b40f414b7eaf3fe6217209bff

Expand source code
class unsorted_interp2d(scipy.interpolate.interp2d):
    """interp2d subclass that remembers original order of data points"""

    def __call__(self, x, y, dx=0, dy=0, assume_sorted=None):
        unsorted_idxs = np.argsort(np.argsort(x))
        return scipy.interpolate.interp2d.__call__(self, x, y, dx=dx, dy=dy)[unsorted_idxs]

Ancestors

  • scipy.interpolate._interpolate.interp2d