Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MVCM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paolo Veglio
MVCM
Commits
539118ab
Commit
539118ab
authored
1 year ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
bump version
parent
3bc82d4d
No related branches found
Branches containing commit
Tags
0.2.2
Tags containing commit
No related merge requests found
Pipeline
#50512
failed
1 year ago
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mvcm/__init__.py
+1
-1
1 addition, 1 deletion
mvcm/__init__.py
mvcm/c_tools/get_b1_thresholds.c
+104
-61
104 additions, 61 deletions
mvcm/c_tools/get_b1_thresholds.c
with
105 additions
and
62 deletions
mvcm/__init__.py
+
1
−
1
View file @
539118ab
"""
Set up version.
"""
"""
Set up version.
"""
__version__
=
"
0.2.
1
"
__version__
=
"
0.2.
2
"
This diff is collapsed.
Click to expand it.
mvcm/c_tools/get_b1_thresholds.c
+
104
−
61
View file @
539118ab
...
@@ -32,13 +32,13 @@ calls:
...
@@ -32,13 +32,13 @@ calls:
#include
<stdio.h>
#include
<stdio.h>
#include
<math.h>
#include
<math.h>
#include
"thresholds.h"
//
#include "thresholds.h"
#include
"pixel.h"
//
#include "pixel.h"
/**********************************************************************/
/**********************************************************************/
int
get_b1_thresholds
(
float
*
locut
,
float
*
hi
cut
,
float
*
midpt
,
int
get_b1_thresholds
(
float
ndvibk
,
float
sctang
,
float
*
lo
cut
,
float
*
midpt
,
float
*
hicut
,
float
*
power
)
float
*
power
)
...
@@ -53,62 +53,118 @@ int get_b1_thresholds(float *locut, float *hicut, float *midpt,
...
@@ -53,62 +53,118 @@ int get_b1_thresholds(float *locut, float *hicut, float *midpt,
int
interp
=
0
;
int
interp
=
0
;
int
a
,
i
,
j
,
k
,
indvi
,
icnf
,
irtn
;
int
a
,
i
,
j
,
k
,
indvi
,
icnf
,
irtn
;
float
des_ndvi
=
0
.
3
;
static
float
delta_ndvi_bin
=
0
.
1
;
static
float
delta_ndvi_bin
=
0
.
1
;
float
x
,
x1
,
x2
,
y1
,
y2
;
float
x
,
x1
,
x2
,
y1
,
y2
;
float
coeff
[
10
][
3
][
4
],
thr
[
3
],
thr_adj
[
3
];
float
coeff
[
10
][
3
][
4
],
thr
[
3
],
thr_adj
[
3
];
float
thr_adj_fac_land
=
0
.
0
;
float
thr_adj_fac_desert
=
0
.
1
;
float
coeffs_land
[
10
][
3
][
4
]
=
{
{
{
32
.
00000000
,
0
.
00000000
,
0
.
00000000
,
0
.
00000000
},
{
42
.
00000000
,
0
.
00000000
,
0
.
00000000
,
0
.
00000000
},
{
52
.
00000000
,
0
.
00000000
,
0
.
00000000
,
0
.
00000000
}
},
{
{
24
.
00000000
,
0
.
00000000
,
0
.
00000000
,
0
.
00000000
},
{
28
.
00000000
,
0
.
00000000
,
0
.
00000000
,
0
.
00000000
},
{
32
.
00000000
,
0
.
00000000
,
0
.
00000000
,
0
.
00000000
}
},
{
{
99
.
13076923
,
-
2
.
00
907925
,
0
.
014
92075
,
-
0
.
00003531
},
{
122
.
19090909
,
-
2
.
32652292
,
0
.
0165
9848
,
-
0
.
000036
81
},
{
142
.
66293706
,
-
2
.
57860528
,
0
.
01773252
,
-
0
.
000036
85
}
},
{
{
85
.
07
902098
,
-
1
.
59413364
,
0
.
01123310
,
-
0
.
00002556
},
{
144
.
56573427
,
-
2
.
81054779
,
0
.
01
967366
,
-
0
.
00004324
},
{
204
.
35454545
,
-
4
.
03411
810
,
0
.
02
816667
,
-
0
.
00006103
}
},
{
{
85
.
03
846154
,
-
1
.
50831391
,
0
.
01006760
,
-
0
.
000021
99
},
{
165
.
15314685
,
-
3
.
24716783
,
0
.
022555
94
,
-
0
.
00004
965
},
{
242
.
06363636
,
-
4
.
90912587
,
0
.
03445455
,
-
0
.
000075
87
}
},
{
{
81
.
00
979021
,
-
1
.
37731935
,
0
.
00
881294
,
-
0
.
00001
859
},
{
220
.
36783217
,
-
4
.
44111888
,
0
.
030
87762
,
-
0
.
00006
888
},
{
359
.
72587413
,
-
7
.
50491841
,
0
.
052
94231
,
-
0
.
00011
917
}
},
{
{
76
.
94055944
,
-
1
.
35441725
,
0
.
00
896096
,
-
0
.
00001
952
},
{
172
.
36783217
,
-
3
.
33144911
,
0
.
0224230
8
,
-
0
.
00004
810
},
{
267
.
90909091
,
-
5
.
31620047
,
0
.
035
97727
,
-
0
.
000076
98
}
},
{
{
85
.
83006993
,
-
1
.
55480575
,
0
.
01025
932
,
-
0
.
00002216
},
{
160
.
73706294
,
-
3
.
072
91375
,
0
.
02041
900
,
-
0
.
00004330
},
{
237
.
37622378
,
-
4
.
63444833
,
0
.
030
91317
,
-
0
.
00006525
}
},
{
{
105
.
02447552
,
-
1
.
98017094
,
0
.
0131
9522
,
-
0
.
00002
877
},
{
135
.
50699301
,
-
2
.
59097902
,
0
.
0174
9301
,
-
0
.
00003
811
},
{
165
.
33006993
,
-
3
.
18872183
,
0
.
021713
87
,
-
0
.
00004734
}
},
{
{
105
.
02447552
,
-
1
.
98017094
,
0
.
0131
9522
,
-
0
.
00002
877
},
{
135
.
50699301
,
-
2
.
59097902
,
0
.
0174
9301
,
-
0
.
00003
811
},
{
165
.
33006993
,
-
3
.
18872183
,
0
.
021713
87
,
-
0
.
00004734
}
}
};
float
coeffs_desert
[
3
][
3
][
4
]
=
{
{
{
282
.
74916084
,
-
5
.
42869658
,
0
.
036607
81
,
-
0
.
0000
8092
},
{
344
.
87048951
,
-
6
.
80660839
,
0
.
04770163
,
-
0
.
00010
991
},
{
407
.
83734266
,
-
8
.
20392385
,
0
.
05
894114
,
-
0
.
00013
926
},
},
{
{
229
.
50727273
,
-
4
.
31606061
,
0
.
02
868182
,
-
0
.
00006212
},
{
316
.
38517483
,
-
6
.
41910256
,
0
.
046030
89
,
-
0
.
000107
87
},
{
403
.
78188811
,
-
8
.
52743395
,
0
.
063357
81
,
-
0
.
00015340
},
},
{
{
239
.
32391608
,
-
4
.
49928127
,
0
.
02
977214
,
-
0
.
00006436
},
{
270
.
31741259
,
-
5
.
33625680
,
0
.
0375716
8
,
-
0
.
0000
8609
},
{
301
.
76013986
,
-
6
.
18557498
,
0
.
04546562
,
-
0
.
00010
806
},
}
};
// Transfer all coefficients to one array.
i
=
0
;
//
Transfer all coefficients to one array.
for
(
i
=
0
;
i
<
10
;
i
++
)
{
for
(
j
=
0
;
j
<
3
;
j
++
)
{
for
(
j
=
0
;
j
<
3
;
j
++
)
{
for
(
k
=
0
;
k
<
4
;
k
++
)
{
for
(
k
=
0
;
k
<
4
;
k
++
)
{
if
(
pxin
.
ndvibk
<
des_ndvi
[
0
])
{
coeff
[
0
][
j
][
k
]
=
b8ndvi0
[
i
];
coeff
[
1
][
j
][
k
]
=
b8ndvi1
[
i
];
coeff
[
2
][
j
][
k
]
=
b8ndvi2
[
i
];
// printf("coeffs8: %d %d %d %f %f\n",i, j, k, coeff[2][j][k], b8ndvi2[i]);
}
else
{
coeff
[
0
][
j
][
k
]
=
b1ndvi0
[
i
];
coeff
[
1
][
j
][
k
]
=
b1ndvi1
[
i
];
coeff
[
2
][
j
][
k
]
=
b1ndvi2
[
i
];
coeff
[
3
][
j
][
k
]
=
b1ndvi3
[
i
];
coeff
[
4
][
j
][
k
]
=
b1ndvi4
[
i
];
coeff
[
5
][
j
][
k
]
=
b1ndvi5
[
i
];
coeff
[
6
][
j
][
k
]
=
b1ndvi6
[
i
];
coeff
[
7
][
j
][
k
]
=
b1ndvi7
[
i
];
coeff
[
8
][
j
][
k
]
=
b1ndvi8
[
i
];
coeff
[
9
][
j
][
k
]
=
b1ndvi9
[
i
];
// printf("coeffs1: %d %d %d %f %f\n",i, j, k, coeff[2][j][k], b1ndvi2[i]);
}
i
++
;
if
(
ndvibk
<
des_ndvi
)
{
coeff
[
i
][
j
][
k
]
=
coeffs_desert
[
i
][
j
][
k
];
if
(
i
>
3
)
{
break
;
}
}
else
{
coeff
[
i
][
j
][
k
]
=
coeffs_land
[
i
][
j
][
k
];
}
}
}
}
}
// printf("\nband 1, 8 coefficients initialized \n");
}
/* Compute thresholds for current pixel as functions of background
/* Compute thresholds for current pixel as functions of background
NDVI and scattering angle.
NDVI and scattering angle.
*/
*/
// Check for special cases and fill values ('ndvibk'=32.767).
// Check for special cases and fill values ('ndvibk'=32.767).
if
(
pxin
.
ndvibk
<
fill_ndvi1
[
0
]
&&
pxin
.
ndvibk
>
fill_ndvi2
[
0
]
)
{
if
(
ndvibk
<
32
.
767
&&
ndvibk
>
0
)
{
if
(
pxin
.
ndvibk
<
ndvi_bnd1
[
0
]
)
{
if
(
ndvibk
<
0
.
05
)
{
indvi
=
0
;
indvi
=
0
;
x
=
0
.
0
;
x
=
0
.
0
;
y2
=
0
.
0
;
y2
=
0
.
0
;
interp
=
0
;
interp
=
0
;
}
}
else
if
(
pxin
.
ndvibk
>=
ndvi_bnd2
[
0
]
)
{
else
if
(
ndvibk
>=
0
.
95
)
{
indvi
=
9
;
indvi
=
9
;
x
=
0
.
0
;
x
=
0
.
0
;
y2
=
0
.
0
;
y2
=
0
.
0
;
...
@@ -119,18 +175,17 @@ int get_b1_thresholds(float *locut, float *hicut, float *midpt,
...
@@ -119,18 +175,17 @@ int get_b1_thresholds(float *locut, float *hicut, float *midpt,
}
}
if
(
interp
)
{
if
(
interp
)
{
a
=
((
pxin
.
ndvibk
/
delta_ndvi_bin
)
-
0
.
5
);
a
=
((
ndvibk
/
delta_ndvi_bin
)
-
0
.
5
);
if
(
a
<
0
)
{
if
(
a
<
0
)
{
indvi
=
0
;
indvi
=
0
;
}
}
else
{
else
{
indvi
=
a
;
indvi
=
a
;
}
}
// indvi = min(nbin_ndvi, max(0, int((pxin.ndvibk / delta_ndvi_bin) - 0.5)) );
x1
=
delta_ndvi_bin
*
indvi
+
delta_ndvi_bin
/
2
.
0
;
x1
=
delta_ndvi_bin
*
indvi
+
delta_ndvi_bin
/
2
.
0
;
x2
=
x1
+
delta_ndvi_bin
;
x2
=
x1
+
delta_ndvi_bin
;
x
=
(
pxin
.
ndvibk
-
x1
)
/
(
x2
-
x1
);
x
=
(
ndvibk
-
x1
)
/
(
x2
-
x1
);
if
(
x
<
0
.
0
)
x
=
0
.
0
;
if
(
x
<
0
.
0
)
x
=
0
.
0
;
if
(
x
>
1
.
0
)
x
=
1
.
0
;
if
(
x
>
1
.
0
)
x
=
1
.
0
;
...
@@ -139,32 +194,24 @@ int get_b1_thresholds(float *locut, float *hicut, float *midpt,
...
@@ -139,32 +194,24 @@ int get_b1_thresholds(float *locut, float *hicut, float *midpt,
for
(
icnf
=
0
;
icnf
<
3
;
icnf
++
)
{
for
(
icnf
=
0
;
icnf
<
3
;
icnf
++
)
{
y1
=
coeff
[
indvi
][
icnf
][
0
]
+
y1
=
coeff
[
indvi
][
icnf
][
0
]
+
(
coeff
[
indvi
][
icnf
][
1
]
*
pxin
.
sctang
)
+
(
coeff
[
indvi
][
icnf
][
1
]
*
sctang
)
+
(
coeff
[
indvi
][
icnf
][
2
]
*
powf
(
pxin
.
sctang
,
2
))
+
(
coeff
[
indvi
][
icnf
][
2
]
*
powf
(
sctang
,
2
))
+
(
coeff
[
indvi
][
icnf
][
3
]
*
powf
(
pxin
.
sctang
,
3
));
(
coeff
[
indvi
][
icnf
][
3
]
*
powf
(
sctang
,
3
));
if
(
interp
)
{
if
(
interp
)
{
y2
=
coeff
[
indvi
+
1
][
icnf
][
0
]
+
y2
=
coeff
[
indvi
+
1
][
icnf
][
0
]
+
(
coeff
[
indvi
+
1
][
icnf
][
1
]
*
pxin
.
sctang
)
+
(
coeff
[
indvi
+
1
][
icnf
][
1
]
*
sctang
)
+
(
coeff
[
indvi
+
1
][
icnf
][
2
]
*
powf
(
pxin
.
sctang
,
2
))
+
(
coeff
[
indvi
+
1
][
icnf
][
2
]
*
powf
(
sctang
,
2
))
+
(
coeff
[
indvi
+
1
][
icnf
][
3
]
*
powf
(
pxin
.
sctang
,
3
));
(
coeff
[
indvi
+
1
][
icnf
][
3
]
*
powf
(
sctang
,
3
));
}
}
thr
[
icnf
]
=
((
1
.
0
-
x
)
*
y1
)
+
(
x
*
y2
);
thr
[
icnf
]
=
((
1
.
0
-
x
)
*
y1
)
+
(
x
*
y2
);
if
(
pxin
.
ndvibk
<
des_ndvi
[
0
]
)
{
if
(
ndvibk
<
des_ndvi
)
{
thr_adj
[
icnf
]
=
thr
[
icnf
]
*
thr_adj_fac_desert
[
0
]
;
thr_adj
[
icnf
]
=
thr
[
icnf
]
*
thr_adj_fac_desert
;
}
}
else
{
else
{
thr_adj
[
icnf
]
=
thr
[
icnf
]
*
thr_adj_fac_land
[
0
]
;
thr_adj
[
icnf
]
=
thr
[
icnf
]
*
thr_adj_fac_land
;
}
}
// printf("ndvi thr: %f %f %f %f %f %f %f\n", des_ndvi[0], fill_ndvi1[0], fill_ndvi2[0],
// ndvi_bnd1[0], ndvi_bnd2[0], thr_adj_fac_desert[0], thr_adj_fac_land[0]);
// printf("coeffs: %f %f %f %f %f %f %f %f\n", coeff[indvi][icnf][0], coeff[indvi][icnf][1],
// coeff[indvi][icnf][2], coeff[indvi][icnf][3], coeff[indvi+1][icnf][0], coeff[indvi+1][icnf][1],
// coeff[indvi+1][icnf][2], coeff[indvi+1][icnf][3]);
// printf("interpolation: %d %d %f %f %f %f %f\n", indvi, icnf, pxin.sctang, y1, y2, thr[icnf], thr_adj[icnf]);
}
}
*
(
hicut
)
=
(
thr
[
0
]
+
thr_adj
[
0
])
/
100
.
0
;
*
(
hicut
)
=
(
thr
[
0
]
+
thr_adj
[
0
])
/
100
.
0
;
...
@@ -182,10 +229,6 @@ int get_b1_thresholds(float *locut, float *hicut, float *midpt,
...
@@ -182,10 +229,6 @@ int get_b1_thresholds(float *locut, float *hicut, float *midpt,
}
}
// printf("\nSubroutine get_b1_thresholds\n");
// printf("%d %d %d %f %f %f %f %f %f %f %f \n", irtn, interp, indvi, pxin.ndvibk, pxin.sctang,
// x1, x2, x, *(locut), *(midpt), *(hicut));
return
irtn
;
return
irtn
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment