Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lozac'h Loic
AgriSoilMoisture
Commits
9c22b49f
Commit
9c22b49f
authored
Dec 16, 2019
by
Lozac'h Loic
Browse files
debug
parent
e2a2022e
Changes
1
Hide whitespace changes
Inline
Side-by-side
python/SoilMoisturePipeline.py
View file @
9c22b49f
...
...
@@ -216,7 +216,11 @@ def download_gpm(sarlist, sartype, gpmdir):
print
(
"wget failed %d : %s"
%
(
p
.
returncode
,
output
))
def
process_gpm
(
sar
,
sar3dates
,
gpmdir
):
outdir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
gpmdir
),
"CumulPluie"
)
outdir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
gpmdir
),
"MaskWetOrDry"
)
outfile
=
os
.
path
.
join
(
outdir
,
"MaskWetOrDry"
+
args
.
zone
+
"_"
+
sar3dates
[
0
]
+
".tif"
)
if
os
.
path
.
exists
(
outfile
):
print
(
"Already exists : "
+
outfile
)
return
if
not
os
.
path
.
exists
(
outdir
):
os
.
mkdir
(
outdir
)
...
...
@@ -252,16 +256,11 @@ def process_gpm(sar, sar3dates, gpmdir):
app0
.
AddImageToParameterInputImageList
(
"il"
,
app
[
0
].
GetParameterOutputImage
(
"out"
))
app0
.
AddImageToParameterInputImageList
(
"il"
,
app
[
1
].
GetParameterOutputImage
(
"out"
))
app0
.
AddImageToParameterInputImageList
(
"il"
,
app
[
2
].
GetParameterOutputImage
(
"out"
))
app0
.
SetParameterString
(
"out"
,
"tempS.tif"
)
app0
.
SetParameterString
(
"exp"
,
"im1b1+im2b1+im3b1"
)
app0
.
Execute
()
app0
.
SetParameterString
(
"out"
,
outfile
)
app0
.
SetParameterOutputImagePixelType
(
"out"
,
otbApplication
.
ImagePixelType_uint8
)
app0
.
SetParameterString
(
"exp"
,
"im1b1+im2b1+im3b1>5?2:1"
)
app0
.
ExecuteAndWriteOutput
()
app1
=
otbApplication
.
Registry
.
CreateApplication
(
"Smoothing"
)
app1
.
SetParameterInputImage
(
"in"
,
app0
.
GetParameterOutputImage
(
"out"
))
app1
.
SetParameterString
(
"type"
,
"gaussian"
)
app1
.
SetParameterString
(
"out"
,
os
.
path
.
join
(
outdir
,
"CumulPluie_"
+
args
.
zone
+
"_"
+
sar3dates
[
0
]
+
".tif"
))
app1
.
SetParameterOutputImagePixelType
(
"out"
,
otbApplication
.
ImagePixelType_uint16
)
app1
.
ExecuteAndWriteOutput
()
def
process_gpm_noresampling
(
sar
,
sar3dates
,
gpmdir
):
outdir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
gpmdir
),
"CumulPluie"
)
...
...
@@ -305,16 +304,17 @@ def process_gpm_noresampling(sar, sar3dates, gpmdir):
app0
.
AddImageToParameterInputImageList
(
"il"
,
apps
[
0
].
GetParameterOutputImage
(
"out"
))
app0
.
AddImageToParameterInputImageList
(
"il"
,
apps
[
1
].
GetParameterOutputImage
(
"out"
))
app0
.
AddImageToParameterInputImageList
(
"il"
,
apps
[
2
].
GetParameterOutputImage
(
"out"
))
app0
.
SetParameterString
(
"out"
,
"tempS.tif"
)
app0
.
SetParameterString
(
"out"
,
outfile
)
app0
.
SetParameterString
(
"exp"
,
"im1b1+im2b1+im3b1"
)
app0
.
Execute
()
app0
.
SetParameterOutputImagePixelType
(
"out"
,
otbApplication
.
ImagePixelType_uint16
)
app0
.
ExecuteAndWriteOutput
()
app1
=
otbApplication
.
Registry
.
CreateApplication
(
"Smoothing"
)
app1
.
SetParameterInputImage
(
"in"
,
app0
.
GetParameterOutputImage
(
"out"
))
app1
.
SetParameterString
(
"type"
,
"gaussian"
)
app1
.
SetParameterString
(
"out"
,
outfile
)
app1
.
SetParameterOutputImagePixelType
(
"out"
,
otbApplication
.
ImagePixelType_uint16
)
app1
.
ExecuteAndWriteOutput
()
#
app1 = otbApplication.Registry.CreateApplication("Smoothing")
#
app1.SetParameterInputImage("in", app0.GetParameterOutputImage("out"))
#
app1.SetParameterString("type", "gaussian")
#
app1.SetParameterString("out", outfile)
#
app1.SetParameterOutputImagePixelType("out", otbApplication.ImagePixelType_uint16)
#
app1.ExecuteAndWriteOutput()
def
select_tfmodel_from_gpm
(
sardate
,
gpmdir
):
cumul
=
glob
.
glob
(
os
.
path
.
join
(
os
.
path
.
join
(
os
.
path
.
dirname
(
gpmdir
),
"CumulPluie"
),
"CumulPluie_"
+
args
.
zone
+
"_"
+
sardate
+
".tif"
))
...
...
@@ -361,7 +361,8 @@ def wet_or_dry_pipeline(args):
sardate
=
sardatetime
.
split
(
"T"
)[
0
]
sar3dates
=
get_meteodates_from_sardate
(
sardate
)
process_gpm_noresampling
(
sar
,
sar3dates
,
args
.
gpmdir
)
# process_gpm_noresampling(sar, sar3dates, args.gpmdir)
process_gpm
(
sar
,
sar3dates
,
args
.
gpmdir
)
res
=
select_tfmodel_from_gpm
(
sardate
,
args
.
gpmdir
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment