diff --git a/sat.py b/sat.py index 5aad6ee..d6f2c97 100644 --- a/sat.py +++ b/sat.py @@ -1,6 +1,7 @@ from PIL import Image import requests from sat7_pointer import * +from numpy import np # Load Landsat 7 band 1, 2, 3 TIF images and create a composite image # from the three bands. @@ -127,3 +128,33 @@ for x in range(ndvi.size[0]): result.save('ndvi.png') +# Calculate FAPAR (Fraction of Absorbed Photosynthetically Active Radiation) +# for each pixel in the cropped image. +# +# Bands 1, 3, 4 are used. + +# Coefficients of polynominal g_0 +# l0,1 l0,2 l0,3 l0,4 l0,5 l0,6 +# 0.27505 0.35511 −0.004 −0.322 0.299 −0.0131 +l_0 = np.array([0.27505, 0.35511, -0.004, -0.322, 0.299, -0.0131]) + +# Coefficients of polynominal g_1 +# l1,1 l1,2 l1,3 l1,4 l1,5 l1,6 l1,7 l1,8 l1,9 l1,10 l1,11 +# −10.036 −0.019804 0.55438 0.14108 12.494 0 0 0 0 0 1.0 +l_1 = np.array([-10.036, -0.019804, 0.55438, 0.14108, 12.494, 0, 0, 0, 0, 0, 1.0]) + +# Coefficients of polynominal g_2 +# l2,1 l2,2 l2,3 l2,4 l2,5 l2,6 l2,7 l2,8 l2,9 l2,10 +# 0.42720 0.069884 −0.33771 0.24690 −1.0821 −0.30401 −1.1024 −1.2596 −0.31949 −1.4864 +l_2 = np.array([0.42720, 0.069884, -0.33771, 0.24690, -1.0821, -0.30401, -1.1024, -1.2596, -0.31949, -1.4864]) + +l = [l_0, l_1, l_2] + +# Function to calculate ratio of polynominals +def g_n(n, x, y): + if n == 0: + return l_0[0] * y - l_0[1] * x + l_0[2] / (l_0[3] - x)**2 + (l_0[4] - y)**2 + l_0[5] + if n == 1: + return l_1[0] + + l[n][0] * (x + l[n][1])**2 + l[n][2] * (y + l[n][3])**2 + l[n][4] * x * y / l[n][5] * (x + l[n][6])**2 + l \ No newline at end of file