Skip to content

Commit 5e44f3a

Browse files
committed
remove image tool folder to simplify installation procedure, and add more comments
1 parent 3346cd6 commit 5e44f3a

12 files changed

+73
-3816
lines changed

prepare_ard.log

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INFO:__main__:AutoPrepareDataARD starts: 2024-11-22 03:01:34

requirements/runtime.txt

+2-7
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,5 @@ astropy>=5.1 ; python_version < '3.11' and python_version >= '3.10' # P
2828
astropy>=5.1 ; python_version < '3.10' and python_version >= '3.9' # Python 3.9
2929
astropy>=5.1 ; python_version < '3.9' and python_version >= '3.8' # Python 3.8
3030

31-
32-
# rasterio>=1.3
33-
34-
# Note:
35-
# gdal is also required, but needs to be installed separately
36-
# due to depending on an external package index.
37-
# see gdal.txt
31+
rasterio>=1.4 ; python_version >= '3.9'
32+
rasterio>=1.3 ; python_version < '3.9' and python_version >= '3.8'

src/cxx/test.py

-13
This file was deleted.

src/python/pycold/colds.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .common import SccdOutput
1111
from ._param_validation import (
1212
validate_parameter_constraints,
13+
Integral,
1314
Interval,
1415
Real,
1516
check_consistent_length,
@@ -402,8 +403,8 @@ def sccd_detect(
402403
b_pinpoint: bool, output pinpoint break where pinpoint is an overdetection of break using conse =3
403404
and threshold = gate_tcg, which are used to simulate the situation of NRT scenario and
404405
for training a machine-learning model
405-
gate_pcg: the gate change probability threshold for defining anomaly
406-
state_intervaldays: the day interval for output states (only b_output_state is True)
406+
gate_pcg: the gate change probability threshold for defining spectral anomaly (for the follow-up supervised approach)
407+
state_intervaldays: the day interval for output states
407408
b_fitting_coefs: True indicates using curve fitting to get global harmonic coefficients, otherwise use the local coefficients
408409
Returns
409410
----------

src/python/pycold/common.py

+55-47
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from collections import namedtuple
33
from dataclasses import dataclass, field
44

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
1010

1111
reccg_dt = np.dtype(
1212
[
@@ -15,29 +15,40 @@
1515
("t_break", np.int32), # time when the first break (change) is observed
1616
("pos", np.int32), # the location of each time series model
1717
("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
2638
]
27-
) # the magnitude of change difference between model prediction
28-
# and observation for each spectral band)
39+
)
2940

3041

3142
SccdOutput = namedtuple("SccdOutput", "position rec_cg min_rmse nrt_mode nrt_model nrt_queue")
3243

3344
sccd_dt = np.dtype(
3445
[
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
4152
],
4253
align=True,
4354
)
@@ -46,16 +57,16 @@
4657

4758
nrtmodel_dt = np.dtype(
4859
[
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
5970
("conse_last", np.ubyte),
6071
],
6172
align=True,
@@ -66,10 +77,10 @@
6677
[
6778
("t_break", np.int32),
6879
("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),
7384
],
7485
align=True,
7586
)
@@ -82,12 +93,9 @@
8293
("t_break", np.int32), # time when the first break (change) is observed
8394
("pos", np.int32), # the location of each time series model
8495
("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
9199
("rmse", np.float32, TOTAL_BAND_FLEX), # RMSE for each time series model for each spectral band
92100
("magnitude", np.float32, TOTAL_BAND_FLEX),
93101
]
@@ -111,8 +119,8 @@
111119
[
112120
("t_start_since1982", np.short),
113121
("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),
116124
("covariance", np.float32, (TOTAL_BAND_FLEX_NRT, 36)),
117125
("nrt_coefs", np.float32, (TOTAL_BAND_FLEX_NRT, SCCD_NUM_C)),
118126
("H", np.float32, TOTAL_BAND_FLEX_NRT),
@@ -129,10 +137,10 @@
129137
[
130138
("t_break", np.int32),
131139
("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),
136144
],
137145
align=True,
138146
)

src/python/pycold/imagetool/__init__.py

Whitespace-only changes.

src/python/pycold/imagetool/config.yaml

-10
This file was deleted.

0 commit comments

Comments
 (0)