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