Skip to content

Commit

Permalink
Merge branch 'sensor-names' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfrantz committed Jul 19, 2024
2 parents 621b493 + 7e033c4 commit cad30c7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion misc/force-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.12-dev:::2024-07-19_09:27:42
3.7.12-dev:::2024-07-19_12:05:02
2 changes: 1 addition & 1 deletion src/higher-level/py-udf-hl.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ char bandname[NPOW_10];
year_[t] = ts->d_tsi[t].year;
month_[t] = ts->d_tsi[t].month;
day_[t] = ts->d_tsi[t].day;
copy_string(sensor_, NPOW_04, "BLEND");
copy_string(sensor_, NPOW_04, ts->bandnames_tsi[t]);
sensor_ += NPOW_04;
}

Expand Down
4 changes: 2 additions & 2 deletions src/higher-level/r-udf-hl.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ SEXP sensors, bandnames;
for (t=0; t<nt; t++){
INTEGER(years)[t] = ts->d_tsi[t].year;
INTEGER(months)[t] = ts->d_tsi[t].month;
INTEGER(days)[t] = ts->d_tsi[t].day;
SET_STRING_ELT(sensors, t, mkChar("BLENDED"));
INTEGER(days)[t] = ts->d_tsi[t].day;
SET_STRING_ELT(sensors, t, mkChar(ts->bandnames_tsi[t]));
}

SET_STRING_ELT(bandnames, 0, mkChar(idx_name));
Expand Down
36 changes: 22 additions & 14 deletions src/higher-level/tsa-hl.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ typedef struct {
enum { _full_, _stats_, _inter_, _nrt_, _year_, _quarter_, _month_, _week_, _day_, _lsp_, _pol_, _trd_, _cat_, _udf_};


void alloc_ts_dates(tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni);
void free_ts_dates(tsa_t *ts);
void compile_ts_dates(ard_t *ard, tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni);
void alloc_ts_metadata(tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni);
void free_ts_metadata(tsa_t *ts, int ni);
void compile_ts_metadata(ard_t *ard, tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni);
brick_t *compile_tsa_brick(brick_t *ard, int idx, brick_compile_info_t *info, par_hl_t *phl);
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);

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


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


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

if (ni > 0) alloc_2D((void***)&ts->bandnames_tsi, ni, NPOW_04, sizeof(char)); else ts->bandnames_tsi = NULL;

return;
}


/** This function frees the date arrays
/** This function frees the date & bandname arrays
--- ts: pointer to instantly useable TSA image arrays
+++ Return: void
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/
void free_ts_dates(tsa_t *ts){
void free_ts_metadata(tsa_t *ts, int ni){


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

if (ts->bandnames_tsi != NULL){ free_2D((void**)ts->bandnames_tsi, ni); ts->bandnames_tsi = NULL;}

return;
}


/** This function compiles the date arrays
/** This function compiles the date & bandname arrays
--- ard: ARD
--- ts: pointer to instantly useable TSA image arrays
--- phl: HL parameters
--- nt: number of ARD products over time
--- ni: number of interpolated products over time
+++ Return: void
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/
void compile_ts_dates(ard_t *ard, tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni){
void compile_ts_metadata(ard_t *ard, tsa_t *ts, par_hl_t *phl, int nt, int nr, int ni){
int t, k;
date_t date;
char sensor[NPOW_04];


init_date(&date);
set_date(&date, 2000, 1, 1);

alloc_ts_dates(ts, phl, nt, nr, ni);
alloc_ts_metadata(ts, phl, nt, nr, ni);

if (nt > 0){
for (t=0; t<nt; t++){
Expand All @@ -543,10 +548,13 @@ date_t date;
for (t=0; t<ni; t++){
if (phl->tsa.tsi.method == _INT_NONE_){
date = get_brick_date(ard[t].DAT, 0);
get_brick_sensor(ard[t].DAT, 0, sensor, NPOW_04);
} else {
set_date_ce(&date, phl->date_range[_MIN_].ce + t*phl->tsa.tsi.step);
copy_string(sensor, NPOW_04, "BLEND");
}
copy_date(&date, &ts->d_tsi[t]);
copy_string(ts->bandnames_tsi[t], NPOW_04, sensor);
}
}

Expand Down Expand Up @@ -896,7 +904,7 @@ brick_compile_info_t *info = NULL;
printf("%d compiling TSA product errors.\n", error);
for (o=0; o<nprod; o++) free_brick(TSA[o]);
free((void*)TSA);
free_ts_dates(ts);
free_ts_metadata(ts, ni);
return NULL;
}

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

// generate data arrays
compile_ts_dates(ard, &ts, phl, nt, nr, ni);
compile_ts_metadata(ard, &ts, phl, nt, nr, ni);

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


// clean date arrays
free_ts_dates(&ts);
free_ts_metadata(&ts, ni);

// terminate UDFs
term_pyp(&phl->tsa.pyp);
Expand Down
1 change: 1 addition & 0 deletions src/higher-level/tsa-hl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ typedef struct {
date_t *d_tss, *d_nrt, *d_tsi;
date_t *d_fby, *d_fbq, *d_fbm, *d_fbw, *d_fbd;
date_t *d_lsp, *d_pol;
char **bandnames_tsi;
} tsa_t;

#include "../higher-level/index-hl.h"
Expand Down

0 comments on commit cad30c7

Please sign in to comment.