Skip to content

Commit 7e033c4

Browse files
committed
implement #321
1 parent 621b493 commit 7e033c4

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

misc/force-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.12-dev:::2024-07-19_09:27:42
1+
3.7.12-dev:::2024-07-19_12:05:02

src/higher-level/py-udf-hl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ char bandname[NPOW_10];
426426
year_[t] = ts->d_tsi[t].year;
427427
month_[t] = ts->d_tsi[t].month;
428428
day_[t] = ts->d_tsi[t].day;
429-
copy_string(sensor_, NPOW_04, "BLEND");
429+
copy_string(sensor_, NPOW_04, ts->bandnames_tsi[t]);
430430
sensor_ += NPOW_04;
431431
}
432432

src/higher-level/r-udf-hl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ SEXP sensors, bandnames;
397397
for (t=0; t<nt; t++){
398398
INTEGER(years)[t] = ts->d_tsi[t].year;
399399
INTEGER(months)[t] = ts->d_tsi[t].month;
400-
INTEGER(days)[t] = ts->d_tsi[t].day;
401-
SET_STRING_ELT(sensors, t, mkChar("BLENDED"));
400+
INTEGER(days)[t] = ts->d_tsi[t].day;
401+
SET_STRING_ELT(sensors, t, mkChar(ts->bandnames_tsi[t]));
402402
}
403403

404404
SET_STRING_ELT(bandnames, 0, mkChar(idx_name));

src/higher-level/tsa-hl.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ typedef struct {
4242
enum { _full_, _stats_, _inter_, _nrt_, _year_, _quarter_, _month_, _week_, _day_, _lsp_, _pol_, _trd_, _cat_, _udf_};
4343

4444

45-
void alloc_ts_dates(tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni);
46-
void free_ts_dates(tsa_t *ts);
47-
void compile_ts_dates(ard_t *ard, tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni);
45+
void alloc_ts_metadata(tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni);
46+
void free_ts_metadata(tsa_t *ts, int ni);
47+
void compile_ts_metadata(ard_t *ard, tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni);
4848
brick_t *compile_tsa_brick(brick_t *ard, int idx, brick_compile_info_t *info, par_hl_t *phl);
4949
brick_t **compile_tsa(ard_t *ard, tsa_t *tsa, par_hl_t *phl, cube_t *cube, int nt, int nr, int ni, int idx, int *nproduct);
5050

@@ -451,16 +451,16 @@ int info_rsp(brick_compile_info_t *info, int o, tsa_t *ts, par_hl_t *phl){
451451
}
452452

453453

454-
/** This function allocates the date arrays
455-
+++ Free the arrays using free_ts_dates
454+
/** This function allocates the date & bandname arrays
455+
+++ Free the arrays using free_ts_metadata
456456
--- ts: pointer to instantly useable TSA image arrays
457457
--- phl: HL parameters
458458
--- nt: number of ARD products over time
459459
--- nr: number of NRT ARD products over time
460460
--- ni: number of interpolated products over time
461461
+++ Return: void
462462
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/
463-
void alloc_ts_dates(tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni){
463+
void alloc_ts_metadata(tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni){
464464

465465

466466
#ifdef FORCE_DEBUG
@@ -479,15 +479,17 @@ void alloc_ts_dates(tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni){
479479
if (phl->tsa.lsp.ny > 0) alloc((void**)&ts->d_lsp, phl->tsa.lsp.ny, sizeof(date_t)); else ts->d_lsp = NULL;
480480
if (phl->tsa.pol.ny > 0) alloc((void**)&ts->d_pol, phl->tsa.pol.ny, sizeof(date_t)); else ts->d_pol = NULL;
481481

482+
if (ni > 0) alloc_2D((void***)&ts->bandnames_tsi, ni, NPOW_04, sizeof(char)); else ts->bandnames_tsi = NULL;
483+
482484
return;
483485
}
484486

485487

486-
/** This function frees the date arrays
488+
/** This function frees the date & bandname arrays
487489
--- ts: pointer to instantly useable TSA image arrays
488490
+++ Return: void
489491
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/
490-
void free_ts_dates(tsa_t *ts){
492+
void free_ts_metadata(tsa_t *ts, int ni){
491493

492494

493495
if (ts->d_tss != NULL){ free((void*)ts->d_tss); ts->d_tss = NULL;}
@@ -501,27 +503,30 @@ void free_ts_dates(tsa_t *ts){
501503
if (ts->d_lsp != NULL){ free((void*)ts->d_lsp); ts->d_lsp = NULL;}
502504
if (ts->d_pol != NULL){ free((void*)ts->d_pol); ts->d_pol = NULL;}
503505

506+
if (ts->bandnames_tsi != NULL){ free_2D((void**)ts->bandnames_tsi, ni); ts->bandnames_tsi = NULL;}
507+
504508
return;
505509
}
506510

507511

508-
/** This function compiles the date arrays
512+
/** This function compiles the date & bandname arrays
509513
--- ard: ARD
510514
--- ts: pointer to instantly useable TSA image arrays
511515
--- phl: HL parameters
512516
--- nt: number of ARD products over time
513517
--- ni: number of interpolated products over time
514518
+++ Return: void
515519
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/
516-
void compile_ts_dates(ard_t *ard, tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni){
520+
void compile_ts_metadata(ard_t *ard, tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni){
517521
int t, k;
518522
date_t date;
523+
char sensor[NPOW_04];
519524

520525

521526
init_date(&date);
522527
set_date(&date, 2000, 1, 1);
523528

524-
alloc_ts_dates(ts, phl, nt, nr, ni);
529+
alloc_ts_metadata(ts, phl, nt, nr, ni);
525530

526531
if (nt > 0){
527532
for (t=0; t<nt; t++){
@@ -543,10 +548,13 @@ date_t date;
543548
for (t=0; t<ni; t++){
544549
if (phl->tsa.tsi.method == _INT_NONE_){
545550
date = get_brick_date(ard[t].DAT, 0);
551+
get_brick_sensor(ard[t].DAT, 0, sensor, NPOW_04);
546552
} else {
547553
set_date_ce(&date, phl->date_range[_MIN_].ce + t*phl->tsa.tsi.step);
554+
copy_string(sensor, NPOW_04, "BLEND");
548555
}
549556
copy_date(&date, &ts->d_tsi[t]);
557+
copy_string(ts->bandnames_tsi[t], NPOW_04, sensor);
550558
}
551559
}
552560

@@ -896,7 +904,7 @@ brick_compile_info_t *info = NULL;
896904
printf("%d compiling TSA product errors.\n", error);
897905
for (o=0; o<nprod; o++) free_brick(TSA[o]);
898906
free((void*)TSA);
899-
free_ts_dates(ts);
907+
free_ts_metadata(ts, ni);
900908
return NULL;
901909
}
902910

@@ -1039,7 +1047,7 @@ short nodata;
10391047
for (idx=0; idx<phl->tsa.n; idx++){
10401048

10411049
// generate data arrays
1042-
compile_ts_dates(ard, &ts, phl, nt, nr, ni);
1050+
compile_ts_metadata(ard, &ts, phl, nt, nr, ni);
10431051

10441052
// initialize UDFs
10451053
init_pyp(NULL, &ts, _HL_TSA_, phl->tsa.index_name[idx], 1, ni, &phl->tsa.pyp);
@@ -1080,7 +1088,7 @@ short nodata;
10801088

10811089

10821090
// clean date arrays
1083-
free_ts_dates(&ts);
1091+
free_ts_metadata(&ts, ni);
10841092

10851093
// terminate UDFs
10861094
term_pyp(&phl->tsa.pyp);

src/higher-level/tsa-hl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ typedef struct {
6363
date_t *d_tss, *d_nrt, *d_tsi;
6464
date_t *d_fby, *d_fbq, *d_fbm, *d_fbw, *d_fbd;
6565
date_t *d_lsp, *d_pol;
66+
char **bandnames_tsi;
6667
} tsa_t;
6768

6869
#include "../higher-level/index-hl.h"

0 commit comments

Comments
 (0)