pytopomap.tools =============== .. py:module:: pytopomap.tools .. autoapi-nested-parse:: Created on Wed Jun 2 16:16:39 2021 @author: peruzzetto Attributes ---------- .. autoapisummary:: pytopomap.tools.BOLD_CONTOURS_INTV pytopomap.tools.NB_THIN_CONTOURS pytopomap.tools.NB_BOLD_CONTOURS Functions --------- .. autoapisummary:: pytopomap.tools.centered_map pytopomap.tools.get_contour_intervals pytopomap.tools.auto_uniform_grey pytopomap.tools.colorbar pytopomap.tools.read_tiff pytopomap.tools.read_ascii pytopomap.tools.read_raster Module Contents --------------- .. py:data:: BOLD_CONTOURS_INTV :value: [0.1, 0.2, 0.5, 1, 2.0, 5, 10, 20, 50, 100, 200, 500, 1000] .. py:data:: NB_THIN_CONTOURS :value: 10 .. py:data:: NB_BOLD_CONTOURS :value: 3 .. py:function:: centered_map(cmap: str, vmin: float, vmax: float, ncolors: int = 256) -> matplotlib.colors.LinearSegmentedColormap Create centered colormap. :param cmap: Curent colormap of the plot. :type cmap: str :param vmin: Minimum value of the dataset. :type vmin: float :param vmax: Maximal value of the dataset. :type vmax: float :param ncolors: Total number of colors contained in the new colormap. The default is 256. :type ncolors: int, optional :returns: **new_map** -- New colormap objects centered in 0. :rtype: matplotlib.colors.LinearSegmentedColormap .. py:function:: get_contour_intervals(zmin: float, zmax: float, nb_bold_contours: int = None, nb_thin_contours: int = None) -> tuple[float, float] Provides the intervals for thin and bold contour lines :param zmin: Minimum altitude of the topography. :type zmin: float :param zmax: Maximum altitude of the topography. :type zmax: float :param nb_bold_contours: Number of bold line. The default is None. :type nb_bold_contours: int, optional :param nb_thin_contours: Number of thin line. The default is None. :type nb_thin_contours: int, optional :returns: * **bold_intv** (*float*) -- Interval between bold contour lines. * **thin_intv** (*float*) -- Interval between thin contour lines. .. py:function:: auto_uniform_grey(z: numpy.ndarray, vert_exag: float, azdeg: int = 315, altdeg: int = 45, dx: float = 1.0, dy: float = 1.0, std_threshold: float = 0.01) -> float Detect if shading must be applied to topography or not (uniform grey). The criterion in colors.LightSource.hillshade is the difference between min and max illumination, and seems to restrictive. :param z: Altitude of each point of the topography. :type z: np.ndarray :param vert_exag: Vertical exaggeration factor for hillshading. :type vert_exag: float :param azdeg: Azimuth angle for light source (degrees from North). The default is 315. :type azdeg: int, optional :param altdeg: Altitude angle for light source (degrees above horizon). The default is 45 :type altdeg: int, optional :param dx: Cell size of the x axis. The default is 1.0. :type dx: float, optional :param dy: Cell size of the y axis. The default is 1.0. :type dy: float, optional :param std_treshold: Relief detection threshold. The default is 0.5. :type std_treshold: float, optional :returns: If no shading applied return None, else return 0.5. :rtype: float | None .. py:function:: colorbar(mappable, ax=None, cax=None, size: str = '5%', pad: float = 0.1, position: str = 'right', **kwargs: dict) -> matplotlib.colorbar.Colorbar Create nice colorbar matching height/width of axe. :param mappable: Mappable object used to generate the colorbar. :type mappable: matplotlib.cm.ScalarMappable :param ax: The axis associated with the colorbar. The default is None. :type ax: matplotlib.axes.Axes, optional :param cax: Specific axis to draw the colorbar into. The default is None. :type cax: matplotlib.axes.Axes, optional :param size: Width or height of the colorbar relative to the parent axis. The default is "5%". :type size: str, optional :param pad: Padding between the parent axis and the colorbar, as a fraction of the parent axis size. The default is 0.1. :type pad: float, optional :param position: Position of the colorbar relative to the parent axis. Options: 'right', 'left', 'top', 'bottom'. The default is "right". :type position: str, optional :param \*\*kwargs: Additional keyword arguments passed to "fig.colorbar()". :type \*\*kwargs: dict :returns: The created Colorbar object. :rtype: matplotlib.colorbar.Colorbar .. py:function:: read_tiff(file) -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] Read tiff file to numpy ndarray. :param file: Path to the tiff file. :type file: str :returns: x, y, z values of the tiff file. :rtype: tuple[np.ndarray, np.ndarray, np.ndarray] .. py:function:: read_ascii(file) -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] Read ascii grid file to numpy ndarray. :param file: Path to the ascii file. :type file: str :returns: x, y, z values of the ascii file. :rtype: tuple[np.ndarray, np.ndarray, np.ndarray] .. py:function:: read_raster(file) -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] Extract x, y, z values of a tif/ascii file. :param file: Path to the file. :type file: str :returns: x, y, z values of the file. :rtype: tuple[np.ndarray, np.ndarray, np.ndarray]