forked from dmaciel123/Secchi_Disk_Landsat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03_MDN Application OLI.py
52 lines (34 loc) · 1.46 KB
/
03_MDN Application OLI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 6 16:36:15 2022
@author: Daniel Andrade Maciel
"""
from MDN import image_estimates, get_sensor_bands
import numpy as np
import pandas as pd
#Generate Secchi estimates using MDN for Landsat-8/9/OLI
Data = pd.read_csv(r"/Users/danielmaciel/Library/CloudStorage/OneDrive-inpe.br/Doutorado/Artigos/Global Secchi/Data/TimeSeries/testes_threshold/secchidisk_v1/l89.csv")
print(Data)
apply_secchi = Data
GC = False
# Remove possible negative values
apply_secchi = apply_secchi[(apply_secchi['blue']> 0)]
apply_secchi = apply_secchi[(apply_secchi['green']> 0)]
apply_secchi = apply_secchi[(apply_secchi['red']> 0)]
# Creating a vector to predict
validation = apply_secchi.loc[:, ('blue', 'green', 'red')].to_numpy()
validation_reshape = np.reshape(validation, (1, len(validation), 3))
# MDN arguments
sensor = "OLI-NoCoastal"
kwargs={'product':'secchi-Maciel', 'use_ratio':True}
res, idxs = image_estimates(validation_reshape, sensor=sensor,**kwargs)
# Change structure
results = res.transpose(2,0,1).reshape(1,-1).transpose()
results = pd.DataFrame(results)
results.columns = ['Secchi']
# Creating and exporting the final results in a new appended collumn
final_df = apply_secchi.reset_index()
final_df['predicted'] = results['Secchi']
print(final_df)
final_df.to_csv(r"/Users/danielmaciel/Library/CloudStorage/OneDrive-inpe.br/Doutorado/Artigos/Global Secchi/Data/TimeSeries/testes_threshold/secchidisk_v1/l89.csv")