Esempio n. 1
0
def NDVI():
    import time

    import matplotlib.pyplot as plt
    import matplotlib.image as mpimg
    from astropy.nddata import NDDataArray
    print("This programm will lead you through creating a NDVI map from images")
    print("It works under assumption that you input two images into it: A Red band image and Near infrared image")
    print("The images must be monochrome, cloudless and it would be best if they had a ocean mask applied.")
    print("If they contain clouds/waterbodies, those will also be falsely ranged on scale.")
    print("NIR is Band 4, R is Band 3 or broadband VIS")
    # pathNIR=input("Please input the path to near infrared image:    ")
    # pathR=input("Please input the path to red image:    ")
    print("Please select a color pallete you want to use. Available palletes:")
    print("Greens   Greys   hot    seismic")
    cmapN = input()

    r = mpimg.imread('C:/Users/Karol/Desktop/NIR.png')
    nir = mpimg.imread('C:/Users/Karol/Desktop/R.png')
    numerator = NDDataArray.subtract(nir, r)
    denominator = NDDataArray.add(nir, r)
    ndvi = NDDataArray.divide(numerator, denominator)
    plt.imshow(ndvi, cmap=cmapN)
    plt.colorbar()
    plt.show()
Esempio n. 2
0
def NOAADUST(ch4,ch5):
    numerator = NDDataArray.subtract(ch5, ch4)
    denominator = NDDataArray.add(ch4, ch5)
    dust = NDDataArray.divide(numerator, denominator)
    plt.imshow(dust,cmap="hot")
    plt.show()
    return dust
Esempio n. 3
0
from astropy.nddata import NDDataArray, StdDevUncertainty
from copy import deepcopy
n1 = NDDataArray(data=3., uncertainty=StdDevUncertainty(4.))
n2 = NDDataArray(data=4., uncertainty=StdDevUncertainty(3.))
n3 = NDDataArray(data=5., uncertainty=StdDevUncertainty(2.))
n4 = deepcopy(n2)

#ok
print("n1.multiply(n2)...OK")
n1.multiply(n2)

#ok
print("n3.multiply(n1)...OK")
n3.multiply(n1)

# will raise AttributeError

try:
    print("Reuse operand as operator : n2.divide(n1)...")
    n2.divide(n1)
except AttributeError as ex:
    print("## Caught AttributeError")
    print(''.join(
        traceback.format_exception(etype=type(ex),
                                   value=ex,
                                   tb=ex.__traceback__)))

#
print("Use deepcopy of n2 instead...OK")
n4.divide(n1)