|
2 | 2 | from collections import namedtuple
|
3 | 3 | from dataclasses import dataclass, field
|
4 | 4 |
|
5 |
| -DEFAULT_CONSE = 8 |
6 |
| -NRT_BAND = 6 |
7 |
| -SCCD_NUM_C = 6 |
8 |
| -TOTAL_BAND_FLEX = 10 |
9 |
| -TOTAL_BAND_FLEX_NRT = 8 |
| 5 | +SCCD_CONSE_OUTPUT = 8 # the default outputted observation number once S-CCD detects breakpoint or pinpoint, note it is not the conse for identifying breakpoints/pinpoints |
| 6 | +NRT_BAND = 6 # the default S-CCD band number |
| 7 | +SCCD_NUM_C = 6 # the S-CCD harmonic model coefficient number |
| 8 | +TOTAL_BAND_FLEX = 10 # the maximum band input for flexible mode of COLD |
| 9 | +TOTAL_BAND_FLEX_NRT = 8 # the maximum band input for flexible mode of S-CCD |
10 | 10 |
|
11 | 11 | reccg_dt = np.dtype(
|
12 | 12 | [
|
|
15 | 15 | ("t_break", np.int32), # time when the first break (change) is observed
|
16 | 16 | ("pos", np.int32), # the location of each time series model
|
17 | 17 | ("num_obs", np.int32), # the number of "good" observations used for model estimation
|
18 |
| - # the quality of the model estimation (what model is used, what process is used) |
19 |
| - ("category", np.short), |
20 |
| - # the probability of a pixel that have undergone change (between 0 and 100) |
21 |
| - ("change_prob", np.short), |
22 |
| - # coefficients for each time series model for each spectral band |
23 |
| - ("coefs", np.float32, (7, 8)), |
24 |
| - ("rmse", np.float32, 7), # RMSE for each time series model for each spectral band |
25 |
| - ("magnitude", np.float32, 7), |
| 18 | + ("category", np.short), # the quality of the model estimation as a two-digit number (what model is used, what process is used) |
| 19 | + # first digit: |
| 20 | + # 0: normal model (no change) |
| 21 | + # 1: change at the beginning of time series model |
| 22 | + # 2: change at the end of time series model |
| 23 | + # 3: disturbance change in the middle |
| 24 | + # 4: fmask fail scenario |
| 25 | + # 5: permanent snow scenario |
| 26 | + # 6: outside user mask |
| 27 | + # second digit: |
| 28 | + # 1: model has only constant term |
| 29 | + # 4: model has 4 coefs |
| 30 | + # 6: model has 6 coefs |
| 31 | + # 8: model has 8 coefs*/ |
| 32 | + # for example, 8 represents "normal model + 8 coefficients" |
| 33 | + ("change_prob", np.short), # the probability of a pixel that have undergone change (between 0 and 100) |
| 34 | + ("coefs", np.float32, (7, 8)), # coefficients for each time series model for seven spectral band, seven bands follow the order of "blue, green, red, nir, swir1, swir2, thermal" |
| 35 | + # seven row has 8 coefficients representing a 'annual-semiannual-trimode' harmonic model |
| 36 | + ("rmse", np.float32, 7), # RMSE for each time series model for each seven band |
| 37 | + ("magnitude", np.float32, 7), # the magnitude of difference between model prediction and observation for each spectral band |
26 | 38 | ]
|
27 |
| -) # the magnitude of change difference between model prediction |
28 |
| -# and observation for each spectral band) |
| 39 | +) |
29 | 40 |
|
30 | 41 |
|
31 | 42 | SccdOutput = namedtuple("SccdOutput", "position rec_cg min_rmse nrt_mode nrt_model nrt_queue")
|
32 | 43 |
|
33 | 44 | sccd_dt = np.dtype(
|
34 | 45 | [
|
35 |
| - ("t_start", np.int32), |
36 |
| - ("t_break", np.int32), |
37 |
| - ("num_obs", np.int32), |
38 |
| - ("coefs", np.float32, (NRT_BAND, SCCD_NUM_C)), |
39 |
| - ("rmse", np.float32, NRT_BAND), |
40 |
| - ("magnitude", np.float32, NRT_BAND), |
| 46 | + ("t_start", np.int32), # ordenal date for the start of the time-series segment |
| 47 | + ("t_break", np.int32), # ordenal date for the break of the time-series segment |
| 48 | + ("num_obs", np.int32), # the number of "good" observations used for model estimation |
| 49 | + ("coefs", np.float32, (NRT_BAND, SCCD_NUM_C)), # coefficients for each time series model for six spectral band |
| 50 | + ("rmse", np.float32, NRT_BAND), # RMSE for each time series model for each seven band |
| 51 | + ("magnitude", np.float32, NRT_BAND), # the magnitude of difference between model prediction and observation for each spectral band |
41 | 52 | ],
|
42 | 53 | align=True,
|
43 | 54 | )
|
|
46 | 57 |
|
47 | 58 | nrtmodel_dt = np.dtype(
|
48 | 59 | [
|
49 |
| - ("t_start_since1982", np.short), |
50 |
| - ("num_obs", np.short), |
51 |
| - ("obs", np.short, (NRT_BAND, DEFAULT_CONSE)), |
52 |
| - ("obs_date_since1982", np.short, DEFAULT_CONSE), |
53 |
| - ("covariance", np.float32, (NRT_BAND, 36)), |
54 |
| - ("nrt_coefs", np.float32, (NRT_BAND, SCCD_NUM_C)), |
55 |
| - ("H", np.float32, NRT_BAND), |
56 |
| - ("rmse_sum", np.uint32, NRT_BAND), |
57 |
| - ("norm_cm", np.short), |
58 |
| - ("cm_angle", np.short), |
| 60 | + ("t_start_since1982", np.short), # the date number since 1982-1-1 for the start of the time-series segment, equal to ordinal date + 723546 |
| 61 | + ("num_obs", np.short), # the number of "good" observations used for model estimation |
| 62 | + ("obs", np.short, (NRT_BAND, SCCD_CONSE_OUTPUT)), # eight multispectral observations at tail (6 * 8) |
| 63 | + ("obs_date_since1982", np.short, SCCD_CONSE_OUTPUT), # eight observation dates (counted since 1982-1-1) at tail (6 * 8) |
| 64 | + ("covariance", np.float32, (NRT_BAND, 36)), # covariance matrix for six bands (6 * 36) |
| 65 | + ("nrt_coefs", np.float32, (NRT_BAND, SCCD_NUM_C)), # the current nrt_coefs (6 * 6) |
| 66 | + ("H", np.float32, NRT_BAND), # the cobservation uncertainties (6 * 1) |
| 67 | + ("rmse_sum", np.uint32, NRT_BAND), # the sum of RMSE (6 * 1) |
| 68 | + ("norm_cm", np.short), # the normalized change magnitude |
| 69 | + ("cm_angle", np.short), # the included change angle |
59 | 70 | ("conse_last", np.ubyte),
|
60 | 71 | ],
|
61 | 72 | align=True,
|
|
66 | 77 | [
|
67 | 78 | ("t_break", np.int32),
|
68 | 79 | ("coefs", np.float32, (NRT_BAND, SCCD_NUM_C)),
|
69 |
| - ("obs", np.short, (NRT_BAND, DEFAULT_CONSE)), |
70 |
| - ("obs_date_since1982", np.short, DEFAULT_CONSE), |
71 |
| - ("norm_cm", np.short, DEFAULT_CONSE), |
72 |
| - ("cm_angle", np.short, DEFAULT_CONSE), |
| 80 | + ("obs", np.short, (NRT_BAND, SCCD_CONSE_OUTPUT)), |
| 81 | + ("obs_date_since1982", np.short, SCCD_CONSE_OUTPUT), |
| 82 | + ("norm_cm", np.short, SCCD_CONSE_OUTPUT), |
| 83 | + ("cm_angle", np.short, SCCD_CONSE_OUTPUT), |
73 | 84 | ],
|
74 | 85 | align=True,
|
75 | 86 | )
|
|
82 | 93 | ("t_break", np.int32), # time when the first break (change) is observed
|
83 | 94 | ("pos", np.int32), # the location of each time series model
|
84 | 95 | ("num_obs", np.int32), # the number of "good" observations used for model estimation
|
85 |
| - # the quality of the model estimation (what model is used, what process is used) |
86 |
| - ("category", np.short), |
87 |
| - # the probability of a pixel that have undergone change (between 0 and 100) |
88 |
| - ("change_prob", np.short), |
89 |
| - # coefficients for each time series model for each spectral band |
90 |
| - ("coefs", np.float32, (TOTAL_BAND_FLEX, 8)), |
| 96 | + ("category", np.short), # the quality of the model estimation (what model is used, what process is used) |
| 97 | + ("change_prob", np.short), # the probability of a pixel that have undergone change (between 0 and 100) |
| 98 | + ("coefs", np.float32, (TOTAL_BAND_FLEX, 8)), # coefficients for each time series model for each spectral band |
91 | 99 | ("rmse", np.float32, TOTAL_BAND_FLEX), # RMSE for each time series model for each spectral band
|
92 | 100 | ("magnitude", np.float32, TOTAL_BAND_FLEX),
|
93 | 101 | ]
|
|
111 | 119 | [
|
112 | 120 | ("t_start_since1982", np.short),
|
113 | 121 | ("num_obs", np.short),
|
114 |
| - ("obs", np.short, (TOTAL_BAND_FLEX_NRT, DEFAULT_CONSE)), |
115 |
| - ("obs_date_since1982", np.short, DEFAULT_CONSE), |
| 122 | + ("obs", np.short, (TOTAL_BAND_FLEX_NRT, SCCD_CONSE_OUTPUT)), |
| 123 | + ("obs_date_since1982", np.short, SCCD_CONSE_OUTPUT), |
116 | 124 | ("covariance", np.float32, (TOTAL_BAND_FLEX_NRT, 36)),
|
117 | 125 | ("nrt_coefs", np.float32, (TOTAL_BAND_FLEX_NRT, SCCD_NUM_C)),
|
118 | 126 | ("H", np.float32, TOTAL_BAND_FLEX_NRT),
|
|
129 | 137 | [
|
130 | 138 | ("t_break", np.int32),
|
131 | 139 | ("coefs", np.float32, (TOTAL_BAND_FLEX_NRT, SCCD_NUM_C)),
|
132 |
| - ("obs", np.short, (TOTAL_BAND_FLEX_NRT, DEFAULT_CONSE)), |
133 |
| - ("obs_date_since1982", np.short, DEFAULT_CONSE), |
134 |
| - ("norm_cm", np.short, DEFAULT_CONSE), |
135 |
| - ("cm_angle", np.short, DEFAULT_CONSE), |
| 140 | + ("obs", np.short, (TOTAL_BAND_FLEX_NRT, SCCD_CONSE_OUTPUT)), |
| 141 | + ("obs_date_since1982", np.short, SCCD_CONSE_OUTPUT), |
| 142 | + ("norm_cm", np.short, SCCD_CONSE_OUTPUT), |
| 143 | + ("cm_angle", np.short, SCCD_CONSE_OUTPUT), |
136 | 144 | ],
|
137 | 145 | align=True,
|
138 | 146 | )
|
|
0 commit comments