An error occurred while loading the file. Please try again.
-
Stephane ALBERT authored533b6ffa
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
from theiacesprodapp.backend.servicemanager import SSMManager
from theiacesprodapp.backend.service.calibration import OrthorectifySentinel1
from theiacesprodapp.backend.service.ssmproduction import SSMProduction
from theiacesprodapp.backend.service.preprocess import gapfilling_pipeline, gpm_pipeline, ndvi_pipeline, processrgp_pipeline, slope_pipeline, stack_pipeline
from theiacesprodapp.backend.service.download import ClimateDataSystem, Microsoft_Stac_Catalog, SentinelEodag, Dataspace_Copernicus_Catalog
from django.conf import settings
def run(*args):
try:
print(args)
split_args = list(args) #shlex.split(args[0])
choix = args[0]
split_args.pop(0)
argsdict={}
for arg in split_args:
argsdict[arg.split("@")[0]]=arg.split("@")[1]
if arg.split("@")[0] in ['overwrite', 'addtodb','debug']:
argsdict[arg.split("@")[0]]=bool(int(arg.split("@")[1]))
if arg.split("@")[0] in ['slopevalue', 'prodtypenum']:
argsdict[arg.split("@")[0]] = int(arg.split("@")[1])
if arg.split("@")[1] == 'none' :
argsdict[arg.split("@")[0]]=None
except :
choix = None
if "debug" in argsdict :
if argsdict["debug"] :
# logger.setLevel(logging.DEBUG)
settings.DEBUG = True
else:
settings.DEBUG = False
else:
settings.DEBUG = False
if choix == "autossmfr":
parametres={
#attribut download
"agriref":argsdict["agriref"],
"zone":argsdict["zone"],
"aoifile":argsdict["aoifile"],
"landusemap":argsdict["landusemap"],
"mrgstile":argsdict["s2tile"], #define workdir
"startdate":argsdict["sd"],
"enddate":argsdict["ed"], #0=S1-GRD,1=S2-L2A,2=S2-L3A
"sentinel1_polar_mode" : argsdict["sarmode"], #choices=['vv', 'vh', 'vvvh']
"rgpshp":argsdict["rgpshp"],
"rpg_pub_year":argsdict["rpg_pub_year"],
"labelsfield":argsdict["labelsfield"],
"landusefield":argsdict["landusefield"],
"agrivalues": argsdict["agrivalues"],
"tfmodel_dir": argsdict["modeldir"],
'tfmodel_choice':argsdict["modelchoice"], #["dry","wet"],
'slope_value':argsdict["slopevalue"],
'outformat':argsdict["outformat"],# choices=['raster', 'csv'],
"skipdownloads":argsdict["skipdownloads"],
'addtodb':argsdict["addtodb"],
"overwrite":argsdict["overwrite"],
"debug":argsdict["debug"],
}
autop = SSMManager(parametres)
autop.autoprodssmfr()
print("Wrapper done.")
elif choix == "autossmww":
parametres={
#attribut download
"agriref":argsdict["agriref"], #user zone
"zone":argsdict["zone"],
"aoifile":argsdict["aoifile"],
"landusemap":argsdict["landusemap"],
"mrgstile":argsdict["s2tile"], #user zone
"startdate":argsdict["sd"],
"enddate":argsdict["ed"],
"rgpshp":argsdict["rgpshp"],
"labelsfield":argsdict["labelsfield"],
"landusefield":argsdict["landusefield"],
"agrivalues": argsdict["agrivalues"],
"tfmodel_dir": argsdict["modeldir"],
'tfmodel_choice':argsdict["modelchoice"], #["dry","wet"],
'slope_value':argsdict["slopevalue"],
"sentinel1_polar_mode":argsdict["sarmode"],
'outformat':argsdict["outformat"],
"skipdownloads":argsdict["skipdownloads"],
"overwrite":argsdict["overwrite"],
"debug":argsdict["debug"],
}
autop = SSMManager(parametres)
autop.autoprodssmww()
print("Wrapper done.")
elif choix == "calibration":
parametres={
#attribut download
"sentinel1_L1A_zip_dir":argsdict["indir"], #define workdir
"reference_image_file":argsdict["inref"],
"mrgstile":argsdict["mrgstile"], #0=S1-GRD,1=S2-L2A,2=S2-L3A
"s1_ortho_dir" : argsdict["outdir"], #choices=['vv', 'vh', 'vvvh']
"sentinel1_polar_mode":argsdict["polar"],
"sentinel1_incidence_type":argsdict["theta"],
"overwrite":argsdict["overwrite"],
"urlsrmt":"http://step.esa.int/auxdata/dem/SRTMGL1/",
"srtmhgtzip":"/data/SRTM/",
"geoid":"/work/python/data/egm96.grd"
}
autop = OrthorectifySentinel1(parametres)
autop.start()
print("Wrapper done.")
elif choix == "production":
parametres={
#attribut download
"agriref":"vector",
"landusemap":"",
"tfmodel_dir":argsdict["modeldir"], #define workdir
"tfmodel_choice":argsdict["modelchoice"],
"s1_ortho_dir" : argsdict["s1orthodir"],
"mrgstile":argsdict["mrgstile"],
"gapfndvidir" : argsdict["ndvidir"], #choices=['vv', 'vh', 'vvvh']
"labels_file" : argsdict["labels_file"],
"slope_file" : argsdict["slope"],
"slope_value" : argsdict["slopevalue"],
"outformat" : argsdict["outformat"],
"data_output_dir" : argsdict["outdir"],
"sentinel1_polar_mode":argsdict["polar"],
"sentinel1_incidence_type":argsdict["incid"],
"overwrite":argsdict["overwrite"],
"ssmfootprint_shpname":""
}
autop = SSMProduction(parametres)
autop.start()
print("Wrapper done.")
elif choix == "ndvi":
parametres={
#attribut download
"s2l2zipdir":argsdict["zipdir"], #define workdir
# "format":argsdict["format"],
"ndvidir" : argsdict["ndvidir"],
"mrgstile":argsdict["mrgstile"],
"overwrite":argsdict["overwrite"]
}
autop = ndvi_pipeline(parametres)
autop.process()
print("Wrapper done.")
elif choix == "gapfill":
parametres={
#attribut download
"ndvidir":argsdict["ndvidir"], #define workdir
"interpolation":argsdict["interpolation"],
"gapfmaskdir" : argsdict["outmaskdir"],
"gapfndvidir":argsdict["outdir"],
"interpolation":argsdict["interpolation"],
"overwrite":argsdict["overwrite"]
}
autop = gapfilling_pipeline(parametres)
autop.process()
print("Wrapper done.")
elif choix == "processrgp":
parametres={
#attribut download
"rgpshp":argsdict["rgpshp"], #define workdir
"labelsfield":argsdict["labelsfield"],
"landusefield" : argsdict["landusefield"],
"mrgstile":argsdict["mrgstile"], #0=S1-GRD,1=S2-L2A,2=S2-L3A
"agrivalues" : argsdict["agrivalues"], #choices=['vv', 'vh', 'vvvh']
"reference_image_file" : argsdict["inref"],
"processrgpdir" : argsdict["outdir"],
"overwrite":argsdict["overwrite"]
}
autop = processrgp_pipeline(parametres)
autop.process()
print("Wrapper done.")
elif choix == "stack":
parametres={
#attribut download
"ndvidir":argsdict["ndvidir"], #define workdir
"lulc":argsdict["lulc"],
"agrivalues" : argsdict["agrivalues"],
"outdir":argsdict["outdir"]
}
autop = stack_pipeline(parametres)
autop.process()
print("Wrapper done.")
elif choix == "slope":
parametres={
#attribut download
"srtmhgtzip":argsdict["srtmdir"], #define workdir
"reference_image_file":argsdict["modelchoice"],
"mrgstile" : argsdict["mrgstile"],
"outdir":argsdict["outdir"]
}
autop = slope_pipeline(parametres)
autop.process()
print("Wrapper done.")
elif choix == "gpm":
parametres={
#attribut download
"s1_ortho_dir":argsdict["s1orthodir"], #define workdir
"GPM_DIR":argsdict["gpmdir"],
"mrgstile" : argsdict["mrgstile"],
"modelchoice_outdir":argsdict["outtxt"]
}
autop = gpm_pipeline(parametres)
autop.process()
print("Wrapper done.")
elif choix == "eodag":
eod = SentinelEodag()
eod.search_and_download_from_tile(argsdict["prodtypenum"], argsdict["mrgstile"], argsdict["startdate"], argsdict["enddate"], argsdict["downdir"])
print("Wrapper done.")
elif choix == "dataspace":
tilegeom = Dataspace_Copernicus_Catalog.get_wkt_tile(argsdict['mrgstile'])
collection={"s1":["SENTINEL-1",tilegeom.wkt],"s2":["SENTINEL-2",tilegeom.centroid.wkt]}
dataspace = Dataspace_Copernicus_Catalog(collection[argsdict["prodtype"]][0],argsdict["startdate"], argsdict["enddate"],
collection[argsdict["prodtype"]][1], argsdict['mrgstile'],argsdict["downdir"])
dataspace.search_dataspace_odata()
S1filelist = dataspace.download_data()
else:
print("Wrong argument.")
exit()