Skip to content

Computes the derivatives in X and Y from a regular grid using finite differences

License

Notifications You must be signed in to change notification settings

humbertovarona/finitediff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

finitediff

Computes the derivatives in X and Y from a regular grid using finite differences

Version

Release date

License

Programming language

OS

Requirements

pip install numpy
pip install matplotlib

Installation

import numpy as np
import matplotlib.pyplot as plt

Functions list

  1. compute_derivative_x Compute the derivative in the X-direction using finite differences

Arguments:

data: 2D array of shape (n, m) containing the data.

delta_x: The known spacing between data points in the x-direction.

derivative_type: String specifying the type of derivative calculation. Can be 'left', 'right', or 'center'.

Returns: derivative 2D array of shape (n, m) containing the numerical derivative in the x-direction.

  1. compute_derivative_y Compute the derivative in the Y-direction using finite differences

Arguments:

data: 2D array of shape (n, m) containing the data.

delta_y: The known spacing between data points in the y-direction.

derivative_type: String specifying the type of derivative calculation. Can be 'left', 'right', or 'center'.

Returns: derivative 2D array of shape (n, m) containing the numerical derivative in the y-direction

  1. quick_plotContourMap Plots a contour map with the result of the derivative by finite difference

Usage examples

Sample 1

n = 150
m = 100

data = np.random.random((n, m))

delta_x = 0.35 
delta_y = 0.25

x_derivative = compute_derivative_x(data, delta_x, 'center')
quick_plotContourMap(x_derivative)

Sample 2

n = 20
m = 18

data = np.random.random((n, m))

delta_x = 0.15
delta_y = 0.12

y_derivative = compute_derivative_y(data, delta_y, 'right')
quick_plotContourMap(y_derivative)

About

Computes the derivatives in X and Y from a regular grid using finite differences

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages