Skip to content

Commit dfe0aae

Browse files
authored
Merge branch 'develop' into specadjust-mods
2 parents 6281855 + b3a8efe commit dfe0aae

File tree

8 files changed

+88
-9
lines changed

8 files changed

+88
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
**Version 3.7.1-develop**
5+
**Version 3.7.2-develop**
66

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

docs/source/history/v3.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
.. _v3:
22

3+
FORCE v. 3.7.2
4+
--------------
5+
6+
Release: 20.10.2021
7+
8+
* **FORCE L2PS**
9+
10+
* ESA made major changes in their Sentinel-2 products, which will become effective as of October 26, 2021.
11+
Specifically, ESA introduced additive scaling factors to convert the DNs to TOA reflectance.
12+
Older FORCE versions will fail!
13+
Update to FORCE >= 3.7.2!
14+
Thanks to Vincent Schut and Patrick Griffiths for the heads-up!
15+
16+
* **General changes**
17+
18+
* Docker containers will only be published to Docker Hub, if working in the original repository.
19+
This solves failed GitHub Actions for users that have forked the repository.
20+
Thanks to Florian Katerndahl for implementing a fix!
21+
22+
* **New Program**
23+
24+
* There is now a new program ``force-cube-init``, which can generate a ``datacube-definition.prj`` file without needing to process Level 2 data.
25+
326

427
FORCE v. 3.7.1
528
--------------

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FORCE documentation
55

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

8-
**Version 3.7.1-develop**
8+
**Version 3.7.2-develop**
99

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

src/cross-level/_version-cl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Version number
3232
extern "C" {
3333
#endif
3434

35-
#define _VERSION_ "3.7.1-develop"
35+
#define _VERSION_ "3.7.2-develop"
3636

3737
#ifdef __cplusplus
3838
}

src/cross-level/string-cl.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,39 @@ void copy_string(char *dst, size_t size, const char *src){
5050
return;
5151
}
5252

53+
54+
int char_to_int(const char *src, int *val){
55+
long int temp_val;
56+
char *temp;
57+
errno = 0;
58+
59+
60+
temp_val = strtol(src, &temp, 0);
61+
62+
if (temp == src || *temp != '\0' || errno == ERANGE){
63+
return FAILURE;}
64+
65+
if (temp_val < INT_MIN ||
66+
temp_val > INT_MAX){
67+
return FAILURE;}
68+
69+
*val = (int)temp_val;
70+
return SUCCESS;
71+
}
72+
73+
74+
int char_to_float(const char *src, float *val){
75+
float temp_val;
76+
char *temp;
77+
errno = 0;
78+
79+
80+
temp_val = strtof(src, &temp);
81+
82+
if (temp == src || *temp != '\0' || errno == ERANGE){
83+
return FAILURE;}
84+
85+
*val = (float)temp_val;
86+
return SUCCESS;
87+
}
88+

src/cross-level/string-cl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ String handling header
3131
#include <stdio.h> // core input and output functions
3232
#include <stdlib.h> // standard general utilities library
3333
#include <string.h> // string handling functions
34+
#include <limits.h> // macro constants of the integer types
35+
#include <errno.h> // error numbers
3436

37+
#include "../cross-level/const-cl.h"
3538

3639
#ifdef __cplusplus
3740
extern "C" {
3841
#endif
3942

4043
void copy_string(char *dst, size_t size, const char *src);
44+
int char_to_int(const char *src, int *val);
45+
int char_to_float(const char *src, float *val);
4146

4247
#ifdef __cplusplus
4348
}

src/lower-level/meta-ll.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,6 @@ GDALDatasetH fp_;
334334

335335

336336
meta->cal = allocate_calibration(nb);
337-
//alloc((void**)&meta->cal, nb, sizeof(cal_t));
338-
//for (b=0; b<nb; b++) init_calib(&meta->cal[b]);
339337

340338

341339
// set start of Relative Spectral Response Array
@@ -736,8 +734,6 @@ int svgrid = 5000;
736734
for (b=0; b<nb; b++) set_brick_sensor(DN, b, sensor);
737735

738736
meta->cal = allocate_calibration(nb);
739-
//alloc((void**)&meta->cal, nb, sizeof(cal_t));
740-
//for (b=0; b<nb; b++) init_calib(&meta->cal[b]);
741737

742738
// set start of Relative Spectral Response Array
743739
if (strcmp(sensor, "SEN2A") == 0){
@@ -883,6 +879,25 @@ int svgrid = 5000;
883879
tokenptr = strtok(NULL, separator);
884880
}
885881

882+
// additive scaling factor (since baseline 4.0)
883+
} else if (strcmp(tag, "RADIO_ADD_OFFSET") == 0){
884+
// re-init to 0 to be compatible with older baselines
885+
for (b=0; b<nb; b++){
886+
if (meta->cal[b].radd == meta->cal[b].fill) meta->cal[b].radd = 0;
887+
}
888+
b = -1;
889+
while (strcmp(tokenptr, "/RADIO_ADD_OFFSET") != 0){
890+
if (b < 0){
891+
char_to_int(tokenptr, &b);
892+
} else if (b >= 0 || b < nb){
893+
char_to_float(tokenptr, &meta->cal[b].radd);
894+
}
895+
tag = tokenptr;
896+
tokenptr = strtok(NULL, separator);
897+
}
898+
#ifdef FORCE_DEBUG
899+
if (b >= 0) printf("additive scaling factor for band %d: %f\n", b, meta->cal[b].radd);
900+
#endif
886901
}
887902

888903
// in case tag (key words) is not the first word in a line

src/lower-level/read-ll.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,11 @@ float dn_scale, toa_scale;
395395
dn_scale = get_brick_scale(DN, b);
396396
toa_scale = get_brick_scale(TOA, b);
397397

398-
#pragma omp parallel shared(b, nc, dn_scale, toa_scale, dn_, toa_) default(none)
398+
#pragma omp parallel shared(b, nc, dn_scale, toa_scale, dn_, toa_, meta) default(none)
399399
{
400400

401401
#pragma omp for schedule(static)
402-
for (p=0; p<nc; p++) toa_[b][p] = dn_[b][p]/dn_scale*toa_scale;
402+
for (p=0; p<nc; p++) toa_[b][p] = (dn_[b][p] + meta->cal[b].radd) / dn_scale*toa_scale;
403403

404404
}
405405

0 commit comments

Comments
 (0)