Skip to content

Commit

Permalink
Add vignette to normalized_diff (spatial.py) AND add vignette to plo…
Browse files Browse the repository at this point in the history
…t_bands (spatial.py) (#96)
  • Loading branch information
jeje1140 authored and Leah Wasser committed Oct 31, 2018
1 parent 1908310 commit b371829
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions earthpy/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ def normalized_diff(b1, b2):
----------
n_diff : ndarray with the same shape as inputs
The element-wise result of (b2-b1) / (b2+b1) with all nan values masked.
Examples
--------
>>>import numpy as np
>>>import earthpy.spatial as es
...
...red_band = np.array([[1, 2, 3, 4, 5],[11,12,13,14,15]])
...nir_band = np.array([[6, 7, 8, 9, 10],[16,17,18,19,20]])
...
...# Calculate normalized difference
...ndiff = es.normalized_diff(b2=nir_band, b1=red_band)
"""
if not (b1.shape == b2.shape):
raise ValueError("Both arrays should be of the same dimensions")
Expand Down Expand Up @@ -317,6 +328,18 @@ def plot_bands(arr, title=None, cmap="Greys_r", figsize=(12, 12), cols=3, extent
----------
fig, ax or axs : figure object, axes object
The figure and axes object(s) associated with the plot.
Examples
--------
>>>import earthpy.spatial as es
...
...titles = ["Red Band", "Green Band", "Blue Band", "Near Infrared (NIR) Band"]
...
...# Plot all bands of a raster tif
...es.plot_bands(naip_image,
... title=titles,
... figsize=(12,5),
... cols=2)
"""
# If the array is 3 dimensional setup grid plotting
if arr.ndim > 2 and arr.shape[0] > 1:
Expand Down

0 comments on commit b371829

Please sign in to comment.