Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfrantz committed Nov 1, 2021
2 parents 5aec0be + f86e5ba commit 04c25c6
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 111 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Framework for Operational Radiometric Correction for Environmental monitoring**

**Version 3.7.2**
**Version 3.7.3**

![FORCE Logo](/images/force.png)

Expand Down
23 changes: 23 additions & 0 deletions docs/source/history/v3.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
.. _v3:

FORCE v. 3.7.3
--------------

Release: 01.11.2021

* **FORCE L2PS**

* The fix for ESA baseline 4.0 in v. 3.7.2 introduced an issue for old/current processsing baselines.
This is fixed now, backwards compatibility is given again.
Thanks to Vincent Schut for noticing.

* The multi-parameter based resolution merge option caused segfaults in some images.
This is fixed now, ``RES_MERGE = REGRESSION`` is now safe to use.
Thanks to J. Antonio Guzmán Q. for reporting this issue.
In addition, this method lacked multithreading, which is no implemented, too.

* **FORCE HLPS**

* in force-higher-level, all sub-modules:
Implemented updates for enhancing the material-specific spectral adjustment.
Thanks to Daniel Scheffler for discussion, testing and help on porting.


FORCE v. 3.7.2
--------------

Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FORCE documentation

**FORCE: Framework for Operational Radiometric Correction for Environmental monitoring**

**Version 3.7.2**
**Version 3.7.3**

`Download from Github <https://github.com/davidfrantz/force>`_.

Expand Down
2 changes: 1 addition & 1 deletion src/cross-level/_version-cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Version number
extern "C" {
#endif

#define _VERSION_ "3.7.2"
#define _VERSION_ "3.7.3"

#ifdef __cplusplus
}
Expand Down
56 changes: 30 additions & 26 deletions src/higher-level/spec-adjust-hl.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ int spectral_predict(ard_t ard, small *mask_, int nc, int sid);
#define _SPECHOMO_N_DST_ 10 // number of destination bands
#define _SPECHOMO_N_COF_ 7 // number of coefficients
#define _SPECHOMO_N_SIM_ 10 // max. number of close clusters to be used for kNN
#define _SPECHOMO_GOOD_SAM_ 0.0698132 // accept clusters that are closer than this angle
#define _SPECHOMO_POOR_SAM_ 0.2617995 // used to compute a weight for each cluster
#define _SPECHOMO_GOOD_SAM_ 0.0698132 // good clusters are closer than this angle (4°)
#define _SPECHOMO_MEDI_SAM_ 0.2094395 // ok'ish clusters are closer than this angle (12°)
#define _SPECHOMO_POOR_SAM_ 0.2617995 // clusters further away from this angle (15°) should not be used
// also used to compute a weight for each cluster
#define _SPECHOMO_MIN_WEIGHT_ 1.0 - _SPECHOMO_GOOD_SAM_/_SPECHOMO_POOR_SAM_
#define _SPECHOMO_MED_WEIGHT_ 1.0 - _SPECHOMO_MEDI_SAM_/_SPECHOMO_POOR_SAM_

const char _SPECHOMO_SENSOR_[_SPECHOMO_N_SEN_][NPOW_04] = {
"LND04", "LND05", "LND07", "LND08", "MOD01", "MOD02" };
Expand Down Expand Up @@ -736,41 +739,41 @@ double pred, wpred[_SPECHOMO_N_DST_], wsum;
// weight for each cluster center
// not exactly as in the paper, pragmatic suggestion by D. Scheffler
if (sam > _SPECHOMO_POOR_SAM_){
weight[s] = 0.01;
weight[s] = 0.00001;
} else {
weight[s] = 1.0 - sam / _SPECHOMO_POOR_SAM_;
}

#ifdef FORCE_DEBUG
printf("\n");
printf("on/off: %d\n", ard.msk[p]);
printf("cluster number: %d\n", s);
printf("ard: ");
for (b=0; b<_SPECHOMO_N_SRC_; b++) printf("%05d ", ard.dat[b_src[b]][p]);
printf("\n");
printf("lib: ");
for (b=0; b<_SPECHOMO_N_SRC_; b++) printf("%05d ", _SPECHOMO_CENTER_[sid][b][s]);
printf("\n");
printf("xx: %.2f, yy: %.2f, xy: %.2f, sam: %.2f, weight: %.2f\n", xx, yy, xy, sam, weight[s]);
printf("xx: %.2f, yy: %.2f, xy: %.2f, sam: %.8f, sam_deg: %.8f, weight: %.8f\n", xx, yy, xy, sam, sam*_R2D_CONV_, weight[s]);
#endif

// maximum weight of close clusters (-1 if no close cluster)
if (weight[s] >= _SPECHOMO_MIN_WEIGHT_ &&
weight[s] > max_weight &&
if (weight[s] > max_weight &&
s != _SPECHOMO_N_SIM_-1){

max_weight = weight[s];
max_cluster = s;
max_weight = weight[s];
max_cluster = s;

}

#ifdef FORCE_DEBUG
printf("max_weight: %.2f, max_cluster: %02d\n", max_weight, max_cluster);
printf("max_weight: %.5f, max_cluster: %02d\n", max_weight, max_cluster);
#endif

}

#ifdef FORCE_DEBUG
print_dvector(weight, "all weights", _SPECHOMO_N_CLS_, 2, 4);
print_dvector(weight, "all weights", _SPECHOMO_N_CLS_, 2, 5);
#endif


Expand All @@ -779,29 +782,30 @@ double pred, wpred[_SPECHOMO_N_DST_], wsum;
// find closest clusters, fill with global
for (c=0; c<_SPECHOMO_N_SIM_; c++){

// if no more close cluster can be found, add global cluster, then stop
if (max_weight < 0){
cluster_select[c] = _SPECHOMO_N_CLS_-1;
weight_select[c] = weight[cluster_select[c]];
break;
}
// init with global cluster
cluster_select[c] = _SPECHOMO_N_CLS_-1;
weight_select[c] = weight[_SPECHOMO_N_CLS_-1];

// copy closest cluster
cluster_select[c] = max_cluster;
weight_select[c] = weight[cluster_select[c]];
if (max_weight > _SPECHOMO_MIN_WEIGHT_ ||
(max_weight > _SPECHOMO_MED_WEIGHT_ &&
max_weight > weight[_SPECHOMO_N_CLS_-1])){

// copy closest cluster
cluster_select[c] = max_cluster;
weight_select[c] = max_weight;

// remove weight from closest cluster
weight[cluster_select[c]] = 0.0;
// remove weight from closest cluster
weight[max_cluster] = 0.0;

} else break;

// find the next closest cluster
max_weight = -1.0;
for (s=0; s<(_SPECHOMO_N_CLS_-1); s++){
if (weight[s] >= _SPECHOMO_MIN_WEIGHT_ &&
weight[s] > max_weight){
if (weight[s] > max_weight){
max_weight = weight[s];
max_cluster = s;
}

}

}
Expand All @@ -811,8 +815,8 @@ double pred, wpred[_SPECHOMO_N_DST_], wsum;

#ifdef FORCE_DEBUG
printf("found %d clusters\n", n_cluster);
print_ivector(cluster_select, "cluster", _SPECHOMO_N_SIM_, 7);
print_dvector(weight_select, "weights", _SPECHOMO_N_SIM_, 2, 4);
print_ivector(cluster_select, "cluster", _SPECHOMO_N_SIM_, 8);
print_dvector(weight_select, "weights", _SPECHOMO_N_SIM_, 2, 5);
#endif

// predict the target reflectance by using a weighted average of
Expand Down
10 changes: 4 additions & 6 deletions src/lower-level/meta-ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,10 @@ int svgrid = 5000;
set_brick_ncols(DN, 1);
set_brick_nrows(DN, 1);

meta->cal = allocate_calibration(nb);

// re-init to 0 to be compatible with older baselines
for (b=0; b<nb; b++) meta->cal[b].radd = 0;


/** parse top-level xml **/
Expand Down Expand Up @@ -733,8 +737,6 @@ int svgrid = 5000;

for (b=0; b<nb; b++) set_brick_sensor(DN, b, sensor);

meta->cal = allocate_calibration(nb);

// set start of Relative Spectral Response Array
if (strcmp(sensor, "SEN2A") == 0){
b_rsr = _RSR_START_SEN2A_;
Expand Down Expand Up @@ -881,10 +883,6 @@ int svgrid = 5000;

// additive scaling factor (since baseline 4.0)
} else if (strcmp(tag, "RADIO_ADD_OFFSET") == 0){
// re-init to 0 to be compatible with older baselines
for (b=0; b<nb; b++){
if (meta->cal[b].radd == meta->cal[b].fill) meta->cal[b].radd = 0;
}
b = -1;
while (strcmp(tokenptr, "/RADIO_ADD_OFFSET") != 0){
if (b < 0){
Expand Down
Loading

0 comments on commit 04c25c6

Please sign in to comment.