@@ -0,0 +1,2054 @@
+# Copyright (c) 2015-2018 MetPy Developers.%0A# Distributed under the terms of the BSD 3-Clause License.%0A# SPDX-License-Identifier: BSD-3-Clause%0A%22%22%22%0AGradient%0A========%0A%0AUse %60metpy.calc.gradient%60.%0A%0AThis example demonstrates the various ways that MetPy's gradient function%0Acan be utilized.%0A%22%22%22%0A%0Aimport numpy as np%0A%0Aimport metpy.calc as mpcalc%0Afrom metpy.units import units%0A%0A###########################################%0A# Create some test data to use for our example%0Adata = np.array(%5B%5B23, 24, 23%5D,%0A                 %5B25, 26, 25%5D,%0A                 %5B27, 28, 27%5D,%0A                 %5B24, 25, 24%5D%5D) * units.degC%0A%0A# Create an array of x position data (the coordinates of our temperature data)%0Ax = np.array(%5B%5B1, 2, 3%5D,%0A              %5B1, 2, 3%5D,%0A              %5B1, 2, 3%5D,%0A              %5B1, 2, 3%5D%5D) * units.kilometer%0A%0Ay = np.array(%5B%5B1, 1, 1%5D,%0A              %5B2, 2, 2%5D,%0A              %5B3, 3, 3%5D,%0A              %5B4, 4, 4%5D%5D) * units.kilometer%0A%0A###########################################%0A# Calculate the gradient using the coordinates of the data%0Agrad = mpcalc.gradient(data, x=(y, x))%0Aprint('Gradient in y direction: ', grad%5B0%5D)%0Aprint('Gradient in x direction: ', grad%5B1%5D)%0A%0A###########################################%0A# It's also possible that we do not have the position of data points, but know%0A# that they are evenly spaced. We can then specify a scalar delta value for each%0A# axes.%0Ax_delta = 2 * units.km%0Ay_delta = 1 * units.km%0Agrad = mpcalc.gradient(data, deltas=(y_delta, x_delta))%0Aprint('Gradient in y direction: ', grad%5B0%5D)%0Aprint('Gradient in x direction: ', grad%5B1%5D)%0A%0A###########################################%0A# Finally, the deltas can be arrays for unevenly spaced data.%0Ax_deltas = np.array(%5B%5B2, 3%5D,%0A                     %5B1, 3%5D,%0A                     %5B2, 3%5D,%0A                     %5B1, 2%5D%5D) * units.kilometer%0Ay_deltas = np.array(%5B%5B2, 3, 1%5D,%0A                     %5B1, 3, 2%5D,%0A                     %5B2, 3, 1%5D%5D) * units.kilometer%0Agrad = mpcalc.gradient(data, deltas=(y_deltas, x_deltas))%0Aprint('Gradient in y direction: ', grad%5B0%5D)%0Aprint('Gradient in x direction: ', grad%5B1%5D)%0A

Add example of using gradient.