Skip to content

Commit 2121f5e

Browse files
committed
finished the development of adding cold flexible mode, allowing users to input the multiple bands as they defined (nbands <= 10)
1 parent f474854 commit 2121f5e

19 files changed

+4833
-1835
lines changed

src/cxx/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (BUILD_SCCD)
2424
# set_target_properties(GLMnet PROPERTIES LINKER_LANGUAGE Fortran)
2525

2626
# Add other C sources
27-
list(APPEND sccd_sources "cold.c" "input.c" "2d_array.c" "utilities.c" "misc.c" "multirobust.c" "output.c" "s_ccd.c" "KFAS.c" "lbfgs.c" "distribution_math.c")
27+
list(APPEND sccd_sources "cold.c" "input.c" "2d_array.c" "utilities.c" "misc.c" "multirobust.c" "output.c" "s_ccd.c" "KFAS.c" "lbfgs.c" "distribution_math.c" "cold_flex.c")
2828
## Create C++ library. Specify include dirs and link libs as normal
2929
#add_library(${SCCD_MODULE_NAME} SHARED ${sccd_sources})
3030

@@ -53,7 +53,7 @@ else() # build standalone program that accepts csv as input, mainly for testing
5353
set_target_properties(GLMnet PROPERTIES LINKER_LANGUAGE Fortran)
5454

5555
# Add other C sources
56-
list(APPEND sccd_sources "cold.c" "input.c" "2d_array.c" "utilities.c" "misc.c" "multirobust.c" "output.c" "s_ccd.c" "KFAS.c" "lbfgs.c" "distribution_math.c" "sccd-desktop.c")
56+
list(APPEND sccd_sources "cold.c" "input.c" "2d_array.c" "utilities.c" "misc.c" "multirobust.c" "output.c" "s_ccd.c" "KFAS.c" "lbfgs.c" "distribution_math.c" "cold_flex.c" "sccd-desktop.c")
5757
## Create C++ library. Specify include dirs and link libs as normal
5858

5959
add_executable(${SCCD_MODULE_NAME} ${sccd_sources})

src/cxx/cold.c

+24-25
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,26 @@ Date Programmer Reason
8383
11/14/2018 Su Ye Original Development
8484
******************************************************************************/
8585
int cold(
86-
int64_t *buf_b, /* I: Landsat blue spectral time series.The dimension is (n_obs, 7). Invalid (qa is filled value (255)) must be removed */
87-
int64_t *buf_g, /* I: Landsat green spectral time series.The dimension is (n_obs, 7). Invalid (qa is filled value (255)) must be removed */
88-
int64_t *buf_r, /* I: Landsat red spectral time series.The dimension is (n_obs, 7). Invalid (qa is filled value (255)) must be removed */
89-
int64_t *buf_n, /* I: Landsat NIR spectral time series.The dimension is (n_obs, 7). Invalid (qa is filled value (255)) must be removed */
90-
int64_t *buf_s1, /* I: Landsat swir1 spectral time series.The dimension is (n_obs, 7). Invalid (qa is filled value (255)) must be removed */
91-
int64_t *buf_s2, /* I: Landsat swir2 spectral time series.The dimension is (n_obs, 7). Invalid (qa is filled value (255)) must be removed */
92-
int64_t *buf_t, /* I: Landsat thermal spectral time series.The dimension is (n_obs, 7). Invalid (qa is filled value (255)) must be removed */
93-
int64_t *fmask_buf, /* I: the time series of cfmask values. 0 - clear; 1 - water; 2 - shadow; 3 - snow; 4 - cloud */
94-
int64_t *valid_date_array, /* I: valid date as matlab serial date form (counting from Jan 0, 0000). Note ordinal date in python is from (Jan 1th, 0001) */
95-
int valid_num_scenes, /* I: number of valid scenes */
96-
int pos, /* I: the position id of pixel */
97-
double tcg, /* I: threshold of change threshold */
98-
int conse, /* I: consecutive observation number */
99-
bool b_outputCM, /* I: indicate if outputting change magnitudes for object-based cold, for cold only, it is the false */
100-
int starting_date, /* I: (optional) the starting date of the whole dataset to enable reconstruct CM_date, all pixels for a tile should have the same date, only for b_outputCM is True */
101-
bool b_c2, /* I: a temporal parameter to indicate if collection 2. C2 needs ignoring thermal band due to the current low quality */
102-
Output_t *rec_cg, /* O: outputted structure for CCDC results */
103-
int *num_fc, /* O: number of fitting curves */
104-
int CM_OUTPUT_INTERVAL,
86+
int64_t *buf_b, /* I: Landsat blue spectral time series. Invalid (qa is filled value (255)) must be removed */
87+
int64_t *buf_g, /* I: Landsat green spectral time series. Invalid (qa is filled value (255)) must be removed */
88+
int64_t *buf_r, /* I: Landsat red spectral time series. Invalid (qa is filled value (255)) must be removed */
89+
int64_t *buf_n, /* I: Landsat NIR spectral time series. Invalid (qa is filled value (255)) must be removed */
90+
int64_t *buf_s1, /* I: Landsat swir1 spectral time series. Invalid (qa is filled value (255)) must be removed */
91+
int64_t *buf_s2, /* I: Landsat swir2 spectral time series. Invalid (qa is filled value (255)) must be removed */
92+
int64_t *buf_t, /* I: Landsat thermal spectral time series. Invalid (qa is filled value (255)) must be removed */
93+
int64_t *fmask_buf, /* I: the time series of cfmask values. 0 - clear; 1 - water; 2 - shadow; 3 - snow; 4 - cloud */
94+
int64_t *valid_date_array, /* I: valid date as matlab serial date form (counting from Jan 0, 0000). Note ordinal date in python is from (Jan 1th, 0001) */
95+
int valid_num_scenes, /* I: number of valid scenes */
96+
int pos, /* I: the position id of pixel */
97+
double tcg, /* I: threshold of change threshold */
98+
int conse, /* I: consecutive observation number */
99+
bool b_outputCM, /* I: indicate if outputting change magnitudes for object-based cold, for cold only, it is the false */
100+
int starting_date, /* I: (optional) the starting date of the whole dataset to enable reconstruct CM_date, all pixels for a tile should have the same date, only for b_outputCM is True */
101+
bool b_c2, /* I: a temporal parameter to indicate if collection 2. C2 needs ignoring thermal band due to the current low quality */
102+
Output_t *rec_cg, /* O: outputted structure for CCDC results */
103+
int *num_fc, /* O: number of fitting curves */
104+
int CM_OUTPUT_INTERVAL, /* I: (optional) change magnitude output interval */
105105
short int *CM_outputs, /* I/O: (optional) maximum change magnitudes at every CM_OUTPUT_INTERVAL days, only for b_outputCM is True*/
106-
// unsigned char* CMdirection_outputs, /* I/O: direction of change magnitudes at every CM_OUTPUT_INTERVAL days, only for b_outputCM is True*/
107106
short int *CM_outputs_date, /* I/O: (optional) dates for maximum change magnitudes at every CM_OUTPUT_INTERVAL days, only for b_outputCM is True*/
108107
double gap_days /* I: the day number of gap to define i_dense; it is useful for the cases that gap is in the middle of time series */
109108
)
@@ -659,7 +658,7 @@ int stand_procedure_fixeddays(
659658

660659
status = auto_mask(clrx, clry, i_start - 1, i + conse_min - 1,
661660
(float)(clrx[i + conse_min - 1] - clrx[i_start - 1]) / NUM_YEARS,
662-
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids);
661+
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids, 2, 5);
663662
// printf("ddstep2 auto_mask finished \n");
664663
if (status != SUCCESS)
665664
{
@@ -2285,7 +2284,7 @@ int stand_procedure_fixeddays(
22852284

22862285
status = auto_mask(clrx, clry, i_start - 1, end - 1,
22872286
(float)(clrx[end - 1] - clrx[i_start - 1]) / NUM_YEARS,
2288-
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids);
2287+
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids, 2, 5);
22892288
if (status != SUCCESS)
22902289
RETURN_ERROR("ERROR calling auto_mask at the end of time series",
22912290
FUNC_NAME, FAILURE);
@@ -2991,7 +2990,7 @@ int stand_procedure(
29912990

29922991
status = auto_mask(clrx, clry, i_start - 1, i + adj_conse - 1,
29932992
(float)(clrx[i + adj_conse - 1] - clrx[i_start - 1]) / NUM_YEARS,
2994-
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids);
2993+
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids, 2, 5);
29952994
// printf("ddstep2 auto_mask finished \n");
29962995
if (status != SUCCESS)
29972996
{
@@ -4482,7 +4481,7 @@ int stand_procedure(
44824481

44834482
status = auto_mask(clrx, clry, i_start - 1, end - 1,
44844483
(float)(clrx[end - 1] - clrx[i_start - 1]) / NUM_YEARS,
4485-
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids);
4484+
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids, 2, 5);
44864485
if (status != SUCCESS)
44874486
RETURN_ERROR("ERROR calling auto_mask at the end of time series",
44884487
FUNC_NAME, FAILURE);
@@ -5523,7 +5522,7 @@ int obcold_reconstruction_procedure(
55235522
/****************************************************/
55245523
status = auto_mask(clrx, clry, i_last_break, i_break_tmp - 1,
55255524
(float)(clrx[i_break_tmp - 1] - clrx[i_last_break] + 1) / NUM_YEARS,
5526-
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids);
5525+
min_rmse[1], min_rmse[4], (float)T_CONST, bl_ids, 2, 5);
55275526
// printf("auto_mask finished \n");
55285527
if (status != SUCCESS)
55295528
{

0 commit comments

Comments
 (0)