nrt-data 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nrt/data/__init__.py ADDED
@@ -0,0 +1,308 @@
1
+ # Copyright (C) 2024 European Union (Joint Research Centre)
2
+ #
3
+ # Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
4
+ # the European Commission - subsequent versions of the EUPL (the "Licence");
5
+ # You may not use this work except in compliance with the Licence.
6
+ # You may obtain a copy of the Licence at:
7
+ #
8
+ # https://joinup.ec.europa.eu/software/page/eupl
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the Licence is distributed on an "AS IS" basis,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the Licence for the specific language governing permissions and
14
+ # limitations under the Licence.
15
+
16
+ import os
17
+ import json
18
+ import warnings
19
+
20
+ import xarray as xr
21
+ import rasterio
22
+ import fiona
23
+ import pooch
24
+
25
+ # Import for backward compatibility and deprecation warnings
26
+ from .simulate import make_ts as _make_ts
27
+ from .simulate import make_cube_parameters as _make_cube_parameters
28
+ from .simulate import make_cube as _make_cube
29
+
30
+
31
+ DATA_DIR = os.path.abspath(os.path.dirname(__file__))
32
+
33
+ GOODBOY = pooch.create(
34
+ path=pooch.os_cache("nrt-validate"),
35
+ base_url="https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/FOREST/NRT/NRT-DATA/VER1-0/",
36
+ registry={
37
+ "sentinel2_cube_subset_romania_10m.nc": None,
38
+ "sentinel2_cube_subset_romania_20m.nc": None,
39
+ "tree_cover_density_2018_romania.tif": None,
40
+ "germany_stratification.tif": None,
41
+ "germany_sample_points.fgb": None
42
+ }
43
+ )
44
+
45
+
46
+ def _load(f, return_meta=False, **kwargs):
47
+ """Load a file using Pooch
48
+
49
+ Args:
50
+ f (str): File basename
51
+ return_meta (bool): If True, return metadata along with the
52
+ array (for .tif and .fgb files). Default is False.
53
+ **kwargs: Keyword arguments for xarray when loading nc files
54
+
55
+ Returns:
56
+ Dataset, array, dictionary, or tuple depending on the file
57
+ type and options.
58
+ """
59
+ file_path = GOODBOY.fetch(f)
60
+ if f.endswith('.nc'):
61
+ return xr.open_dataset(file_path, **kwargs)
62
+ elif f.endswith('.tif'):
63
+ with rasterio.open(file_path) as src:
64
+ array = src.read(1)
65
+ if return_meta:
66
+ meta = src.meta
67
+ return array, meta
68
+ return array
69
+ elif f.endswith('.fgb'):
70
+ with fiona.open(file_path) as src:
71
+ data = list(src) # Read all features into a list
72
+ if return_meta:
73
+ meta = src.meta
74
+ return data, meta
75
+ return data
76
+
77
+
78
+ def romania_10m(**kwargs):
79
+ """Sentinel 2 datacube of a small forested area in Romania at 10 m resolution
80
+
81
+ Examples:
82
+ >>> from nrt import data
83
+
84
+ >>> s2_cube = data.romania_10m()
85
+ >>> # Compute NDVI
86
+ >>> s2_cube['ndvi'] = (s2_cube.B8 - s2_cube.B4) / (s2_cube.B8 + s2_cube.B4)
87
+ >>> # Filter clouds
88
+ >>> s2_cube = s2_cube.where(s2_cube.SCL.isin([4,5,7]))
89
+ """
90
+ return _load('sentinel2_cube_subset_romania_10m.nc', **kwargs)
91
+
92
+
93
+ def romania_20m(**kwargs):
94
+ """Sentinel 2 datacube of a small forested area in Romania at 20 m resolution
95
+
96
+ Examples:
97
+ >>> from nrt import data
98
+
99
+ >>> s2_cube = data.romania_20m()
100
+ >>> # Compute NDVI
101
+ >>> s2_cube['ndvi'] = (s2_cube.B8A - s2_cube.B4) / (s2_cube.B8A + s2_cube.B4)
102
+ >>> # Filter clouds
103
+ >>> s2_cube = s2_cube.where(s2_cube.SCL.isin([4,5,7]))
104
+ """
105
+ return _load('sentinel2_cube_subset_romania_20m.nc', **kwargs)
106
+
107
+
108
+ def germany_zarr(**kwargs):
109
+ """Sentinel 2 datacube of a forest area affected by Bark Beetle in Germany
110
+
111
+ The data covers an area of 400 km\ :sup:`2` located East of the city Cologne
112
+ in the North Rhine-Westphalia state of Germany. It spans a five year period
113
+ from 2018 to 2022 and includes the sentinel bands B02, B03, B04, B08, B11,
114
+ B12 and SCL. Native 10m resolution is preserved for the visible and near-infrared
115
+ bands while B11, B12 and SCL were resampled to 10m from their original 20m resolution.
116
+ The data is organized as an online zarr store on the JRC's Open Data Repository,
117
+ so that running the ``germany_zarr()`` function only creates a symbolic representation
118
+ of the dataset (dask based). Lazy chunks can be eagerly loaded by invoking the
119
+ ``.compute()`` method. Beware that loading the entire dataset may take a fairly
120
+ long time due to its size (4.8 GB).
121
+ Note that although data is stored as int16, the scaling factor is automatically
122
+ applied to convert spectral channels to unscaled surface reflectance values
123
+ and the corresponding data variables are casted to float64. No data pixels are
124
+ also automatically converted to ``np.nan``
125
+
126
+ Args:
127
+ **kwargs: Additional keyword arguments passed to ``xarray.open_zarr()``
128
+
129
+ Examples:
130
+ >>> import sys
131
+ >>> from nrt import data
132
+ >>> ds = data.germany_zarr()
133
+ >>> print(ds)
134
+ <xarray.Dataset>
135
+ Dimensions: (time: 172, y: 2000, x: 2000)
136
+ Coordinates:
137
+ spatial_ref int32 ...
138
+ * time (time) datetime64[ns] 2018-02-14T10:31:31.026000 ... 2022-12...
139
+ * x (x) float64 4.133e+06 4.133e+06 ... 4.153e+06 4.153e+06
140
+ * y (y) float64 3.113e+06 3.113e+06 ... 3.093e+06 3.093e+06
141
+ Data variables:
142
+ B02 (time, y, x) float32 dask.array<chunksize=(10, 100, 100), meta=np.ndarray>
143
+ B03 (time, y, x) float32 dask.array<chunksize=(10, 100, 100), meta=np.ndarray>
144
+ B04 (time, y, x) float32 dask.array<chunksize=(10, 100, 100), meta=np.ndarray>
145
+ B08 (time, y, x) float32 dask.array<chunksize=(10, 100, 100), meta=np.ndarray>
146
+ B11 (time, y, x) float32 dask.array<chunksize=(10, 100, 100), meta=np.ndarray>
147
+ B12 (time, y, x) float32 dask.array<chunksize=(10, 100, 100), meta=np.ndarray>
148
+ SCL (time, y, x) uint8 dask.array<chunksize=(10, 100, 100), meta=np.ndarray>
149
+ >>> # Load a subset in memory
150
+ >>> print(sys.getsizeof(ds.B02.data))
151
+ 80
152
+ >>> ds_sub = ds.isel(x=slice(100,110), y=slice(200,210), time=slice(10,20)).compute()
153
+ >>> print(sys.getsizeof(ds_sub.B02.data))
154
+ 2144
155
+
156
+ Returns:
157
+ xarray.Dataset: A dask based Dataset of dimension ``(time: 172, y: 2000, x: 2000)``
158
+ with 7 data variables.
159
+ """
160
+ ds = xr.open_zarr('https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/FOREST/NRT/NRT-DATA/VER1-0/germany.zarr',
161
+ **kwargs)
162
+ return ds
163
+
164
+
165
+ def germany_stratification(return_meta=False):
166
+ """Simple rule based classification of forest dynamics for germany_zarr
167
+
168
+ Raster layer in the EPSG:3035 CRS, spatially aligned with the
169
+ ``germany_zarr`` data cube. The classification is based on a simple
170
+ rule-based approach applied to a pair of manually selected cloud-free time
171
+ steps (2019-06-27 and 2022-06-16). NDVI and the second SWIR band are used to
172
+ distinguish various tree cover dynamics, based on the assumption that healthy
173
+ forests are generally green in summer (indicated by high NDVI values) and dark
174
+ in the SWIR region. "Unhealthy" forests, such as standing dead trees following
175
+ a bark beetle attack, may still be dark in the SWIR region but with lower
176
+ greenness. Non-forested land lacks these combined characteristics.
177
+
178
+ Note that this approach is relatively simple and, as a result, produces an
179
+ imperfect classification. Although there may be some confusion between land
180
+ cover elements that are difficult to discriminate solely based on NDVI and
181
+ SWIR values, the layer is well-suited for purposes such as stratification in a
182
+ stratified sampling design.
183
+
184
+ Classes are encoded as follows::
185
+
186
+ 1: Non-forested land
187
+ 2: Stable Forest (Constantly green and dark in the SWIR region)
188
+ 3: Forest Cover Loss (Conversion from healthy forest to non-forested land)
189
+ 4: Forest Canopy Dieback (Loss of greenness but still dark in SWIR)
190
+ 5: Salvage Logging (From 'unhealthy' forest to non-forested land)
191
+
192
+ Returns:
193
+ numpy.ndarray or (numpy.ndarray, dict): 2D array with encoded 2019-2022
194
+ tree cover dynamics or (data, metadata) if ``return_meta`` is True.
195
+ """
196
+ return _load('germany_stratification.tif', return_meta=return_meta)
197
+
198
+
199
+ def germany_sample_points(return_meta=False):
200
+ """Feature collection of 300 sample points from the Germany test area.
201
+
202
+ These points represent pixel centers sampled using a reclassified version
203
+ of the ``germany_stratification`` layer. In this reclassification, all
204
+ disturbance strata were combined into a single stratum, resulting in
205
+ stratified random sampling. An equal allocation method was employed,
206
+ with 100 samples per stratum.
207
+
208
+ The feature collection includes a ``stratum`` property with values 1, 2,
209
+ or 3, representing different strata:
210
+
211
+ - 1: Non-forested stratum (2,333,767 pixels)
212
+ - 2: Stable forest stratum (972,184 pixels)
213
+ - 3: Disturbed forest stratum (694,049 pixels)
214
+
215
+ Args:
216
+ return_meta (bool, optional): If True, returns both the feature collection
217
+ and associated metadata. Defaults to False.
218
+
219
+ Examples:
220
+ >>> from nrt import data
221
+ >>> fc = data.germany_sample_points()
222
+ >>> set([feat['properties']['stratum'] for feat in fc])
223
+ {1,2,3}
224
+ >>> len(fc)
225
+ 300
226
+
227
+ Returns:
228
+ list or tuple: If `return_meta` is False, returns a list containing the
229
+ feature collection of sample points. If `return_meta` is True, returns
230
+ a tuple of (feature collection, metadata).
231
+ """
232
+ return _load('germany_sample_points.fgb', return_meta=return_meta)
233
+
234
+
235
+ def romania_forest_cover_percentage(return_meta=False):
236
+ """Subset of Copernicus HR layer tree cover percentage - 20 m - Romania
237
+
238
+ Returns:
239
+ numpy.ndarray or (numpy.ndarray, dict): The data or (data, metadata)
240
+ if ``return_meta`` is True.
241
+ """
242
+ return _load('tree_cover_density_2018_romania.tif', return_meta=return_meta)
243
+
244
+
245
+ def mre_crit_table():
246
+ """Contains a dictionary equivalent to strucchange's ``mreCritValTable``
247
+ The key 'sig_level' is a list of the available pre-computed significance
248
+ (1-alpha) values.
249
+
250
+ The other keys contain nested dictionaries, where the keys are the
251
+ available relative window sizes (0.25, 0.5, 1), the second keys are the
252
+ available periods (2, 4, 6, 8, 10) and the third keys are the functional
253
+ types ("max", "range").
254
+
255
+ Example:
256
+ >>> from nrt import data
257
+ >>> crit_table = data.mre_crit_table()
258
+ >>> win_size = 0.5
259
+ >>> period = 10
260
+ >>> functional = "max"
261
+ >>> alpha=0.025
262
+ >>> crit_values = crit_table.get(str(win_size))\
263
+ .get(str(period))\
264
+ .get(functional)
265
+ >>> sig_level = crit_table.get('sig_levels')
266
+ >>> crit_level = np.interp(1-alpha, sig_level, crit_values)
267
+ """
268
+ with open(os.path.join(DATA_DIR, "mreCritValTable.json")) as crit:
269
+ crit_table = json.load(crit)
270
+ return crit_table
271
+
272
+
273
+ def make_ts(*args, **kwargs):
274
+ warnings.warn(
275
+ "The function 'make_ts' has been moved to 'nrt.data.simulate'. "
276
+ "Please update your imports to 'from nrt.data.simulate import make_ts'. "
277
+ "This import path will be deprecated in future versions.",
278
+ DeprecationWarning,
279
+ stacklevel=2
280
+ )
281
+ return _make_ts(*args, **kwargs)
282
+
283
+
284
+ def make_cube_parameters(*args, **kwargs):
285
+ warnings.warn(
286
+ "The function 'make_cube_parameters' has been moved to 'nrt.data.simulate'. "
287
+ "Please update your imports to 'from nrt.data.simulate import make_cube_parameters'. "
288
+ "This import path will be deprecated in future versions.",
289
+ DeprecationWarning,
290
+ stacklevel=2
291
+ )
292
+ return _make_cube_parameters(*args, **kwargs)
293
+
294
+
295
+ def make_cube(*args, **kwargs):
296
+ warnings.warn(
297
+ "The function 'make_cube' has been moved to 'nrt.data.simulate'. "
298
+ "Please update your imports to 'from nrt.data.simulate import make_cube'. "
299
+ "This import path will be deprecated in future versions.",
300
+ DeprecationWarning,
301
+ stacklevel=2
302
+ )
303
+ return _make_cube(*args, **kwargs)
304
+
305
+
306
+ if __name__ == "__main__":
307
+ import doctest
308
+ doctest.testmod()
@@ -0,0 +1 @@
1
+ {"0.25":{"2":{"max":[1.22762665817831,1.23066970866923,1.23276485917986,1.23564055536802,1.23847794049457,1.24198076615651,1.24481637165883,1.24879019056867,1.25239505325696,1.25498907533676,1.25822933229468,1.26223904797321,1.26596555529583,1.26923998208695,1.27264091504165,1.27603992297831,1.27959232745831,1.28485863206623,1.28918350549942,1.29311889830519,1.2977431610724,1.30293027348104,1.30709536503133,1.31158624473196,1.31737646083926,1.32335166269351,1.32786358742455,1.33350696717069,1.33919230324655,1.34492551588986,1.35027274948328,1.35619676871919,1.36259049396895,1.36957894266347,1.37645783098199,1.38428233380854,1.39194501572598,1.40100798604519,1.41166991783875,1.42087734975763,1.4332629474243,1.44359950240666,1.45511231203346,1.47160701884111,1.48885977022345,1.50729964467061,1.53175586508601,1.56038054799786,1.60458840049086,1.67397676536158],"range":[1.81954446481909,1.82344798626059,1.82661414686887,1.83012286026358,1.83360988469104,1.83715307775979,1.84056756023769,1.84447094408104,1.84879237475351,1.85298319721727,1.85760168211944,1.86229547366417,1.86607380226072,1.87015100669539,1.87434883360663,1.87862404267598,1.88404478043788,1.88874302055418,1.89345950619256,1.8990209037878,1.90449669183086,1.91062464756646,1.91580988964948,1.92155884964439,1.92769261345449,1.93415193190404,1.94041179292859,1.94569298705534,1.95291260429275,1.96021400157099,1.96856019678075,1.97628019027419,1.98582433124427,1.99338282123118,2.00352123592733,2.01261514315571,2.02281840175644,2.03218988260106,2.04365141141769,2.05775961499134,2.07290455593282,2.08573018151457,2.10381247226301,2.12274034143787,2.14594597496256,2.16901291630049,2.2006775007979,2.23584782620152,2.28952131979675,2.36288190456084]},"4":{"max":[1.33623105388957,1.33879059030532,1.34146823757119,1.34417861992375,1.3465859785707,1.34920669388068,1.35202040971813,1.35462026215463,1.35719673301301,1.36049997713998,1.36372549810846,1.36667883846684,1.37052411847341,1.37374212322454,1.37657697158592,1.38022128723907,1.38394338302155,1.38769333359217,1.39048392473728,1.39408189315686,1.39843637731271,1.40284080982133,1.40734331669295,1.41189572366036,1.41597082120943,1.42022026752427,1.42524057175581,1.43085920948697,1.43555358483841,1.44053121853627,1.44543973881029,1.45089202071443,1.45602813899372,1.46278181190807,1.46985441198876,1.47696589701722,1.48523183187464,1.4928335139521,1.50095115109795,1.51067508324004,1.51983679278537,1.53269740247647,1.54440348055754,1.55910620044073,1.5757207179645,1.59695604364839,1.61812223040947,1.64940524297012,1.68594331412298,1.74550948894458],"range":[2.08412863196499,2.08700050605196,2.09015587299808,2.09314772413788,2.0962118341186,2.09917174136122,2.10278041385553,2.10664115359282,2.11051021733345,2.11386339871615,2.11800614299258,2.12153141721421,2.12493922632193,2.128940723382,2.13256639487202,2.13624534724997,2.13987494438998,2.14428962586375,2.1488466247166,2.15289915148653,2.15772291958247,2.16275539625543,2.16754418014273,2.17340107059304,2.17804833913143,2.18292605491209,2.18834249521883,2.19418031959385,2.19974183639896,2.20602030124108,2.21275319960549,2.21975099503959,2.22754034101027,2.23584860470238,2.24643285315134,2.25447222697549,2.26355487832797,2.27330215278724,2.28338923866037,2.29629889010986,2.30968297534757,2.32120188794181,2.33947210810481,2.35476341812366,2.37402027796209,2.39199360336253,2.41528158657702,2.44577623701494,2.48767372335248,2.56385789438856]},"6":{"max":[1.34108685187662,1.34391583752137,1.34624172867029,1.34839917683048,1.35109583245859,1.35376511356222,1.35614865096182,1.3589153034203,1.36194735830278,1.36523574166444,1.36827681119024,1.37164275186352,1.37460434441364,1.37781526603652,1.38115250250291,1.38474992975096,1.38801205099788,1.39091294470053,1.39464610643847,1.39872249131114,1.40265414814487,1.40676218000241,1.41145745016112,1.41537372778588,1.41936982775548,1.42362459481656,1.42868230819686,1.4335263612056,1.43825178128014,1.44291380981225,1.44812318488765,1.45314333050063,1.45889808672432,1.46547805028961,1.47234905574779,1.48040430543862,1.48742657759599,1.49494270557386,1.50325247631427,1.51196972918776,1.52159988186384,1.5338376447881,1.54538029292232,1.56033776761057,1.57658154293077,1.59797111384019,1.61839672202083,1.64940524297012,1.68594331412298,1.74550948894458],"range":[2.11180746892218,2.11463521114668,2.11795938985215,2.1209477515762,2.12367749118468,2.12700564954345,2.13022885738685,2.13331413213671,2.13638901650338,2.13957142023227,2.14278319617785,2.14654037225162,2.15025122444992,2.15350620192262,2.15790353284222,2.16174960354069,2.16591902110115,2.16962692628423,2.17482006047446,2.17837241804329,2.1823519062029,2.18644278886306,2.19144615710786,2.19619036546802,2.20084587599274,2.20594262058077,2.21151932219498,2.21677557521056,2.22390405782033,2.22946798441255,2.23600560246166,2.24357296278298,2.25145401752516,2.25788606932308,2.26592510857528,2.27469446859609,2.28180217420085,2.2921810700707,2.30360483959548,2.31424301355248,2.32622597282216,2.34133705551313,2.35451543226751,2.3703340530465,2.38788822898856,2.40714432279085,2.43114641843066,2.4603445009744,2.50193957388617,2.57715648650667]},"8":{"max":[1.34165681503561,1.34413752134022,1.34645624006547,1.34885191571363,1.35155402000607,1.35398617621481,1.35634491518239,1.35923481408015,1.36226456490384,1.36560026937241,1.3685046029885,1.37214926058743,1.37477725947058,1.37813432738452,1.38154788481536,1.38507423359833,1.3883679478361,1.39117348693852,1.39508146109301,1.39885993994357,1.40307434720965,1.40727611318749,1.41163904123871,1.4155821439226,1.4195616504863,1.42380433491698,1.42884928919173,1.43362752470632,1.43839225150709,1.44297415629377,1.44822824145847,1.45326230316142,1.45899173457736,1.46554748937219,1.47245299778231,1.48055874421042,1.48752188622688,1.49506819639025,1.50344238684623,1.51198649641834,1.52162850629023,1.53408167478549,1.54554689692936,1.56033776761057,1.57658154293077,1.59797111384019,1.61839672202083,1.64940524297012,1.68594331412298,1.74550948894458],"range":[2.12023606594727,2.12271312238526,2.12570983180643,2.12870146970024,2.13138278881771,2.13432755770033,2.1372173309577,2.14015064852228,2.14337274683089,2.14667091866216,2.15023732394521,2.15330108915549,2.15708559803071,2.16079879827035,2.16479117991533,2.16837711066996,2.17272178924074,2.17696276396447,2.1805518769006,2.18427980386643,2.18816464030844,2.19270005873997,2.19756475040665,2.20137135641134,2.20646049986697,2.21235424451003,2.2172520230591,2.22390448303944,2.22912572338386,2.23559446368185,2.24184595886197,2.25014852708459,2.25560261704792,2.26371913853653,2.27108474517556,2.27872967620606,2.28581023227752,2.29638970067853,2.30840554880696,2.31802794634901,2.33015160144847,2.34413894973114,2.35701974551271,2.37415798162602,2.38941664405227,2.41044813125293,2.43262481616013,2.46153747539832,2.50347160121869,2.57724178592687]},"10":{"max":[1.34182451007628,1.34439131451376,1.34660319011975,1.34915116589537,1.35178587051693,1.35417886044462,1.3566836167395,1.35948739899674,1.36256898537193,1.36577231193638,1.36886320957607,1.37237427017584,1.37485167515552,1.37831535555367,1.38175120511989,1.38537793038039,1.38847324240149,1.39145597087778,1.39532955755002,1.39911228012838,1.40318773259415,1.40748954375846,1.41181372331003,1.41569840195645,1.41977723105019,1.4238186195231,1.42895669363032,1.43363936425424,1.43840514935644,1.44307576181773,1.44823608804569,1.45331084387002,1.45902908335449,1.46557816998587,1.4725305386567,1.48057636069157,1.48759284416558,1.49517101820054,1.50384229730937,1.5120839046915,1.52164497279622,1.53436454805016,1.54556159000357,1.56036062897291,1.57673206447201,1.59797111384019,1.61839672202083,1.64940524297012,1.68594331412298,1.74550948894458],"range":[2.12320823869064,2.12592798765015,2.12893373691857,2.13144740982465,2.13436228911229,2.13712065817205,2.1399242164402,2.14299416667874,2.14639323126965,2.14981626879143,2.15289921726444,2.15654036991459,2.15983848157569,2.16354643287978,2.16725752708834,2.17091203976378,2.17575002492038,2.17949319057116,2.18278067782414,2.18658263069226,2.190831628588,2.19529666017785,2.19953592798011,2.20420219844996,2.20976171342769,2.21435123608395,2.2197417573013,2.22572782807263,2.23161827669412,2.23785128970986,2.24596536134365,2.25167806496759,2.2577705279316,2.26532559641099,2.27275118676399,2.27988920935585,2.2875555808519,2.29875120806278,2.31018232789398,2.31960844363455,2.33282714628515,2.34615425435877,2.35894608057624,2.37549525619605,2.39125032964919,2.41133838110484,2.43270772115341,2.46165670661943,2.50348125220136,2.57980707025258]}},"0.5":{"2":{"max":[1.68732328328598,1.69160084179475,1.69633389358351,1.70158435524857,1.70551689505972,1.71107257285131,1.71626606143193,1.72019347712026,1.72583651612689,1.73080136283287,1.73632152412507,1.74196445041873,1.74739377676382,1.75350003177274,1.75880466474247,1.76547247515605,1.77251787804276,1.77940231593083,1.78802901378588,1.79524119452131,1.8022227519734,1.80915784114738,1.81682673045196,1.82485724271212,1.83334265228127,1.84186416555787,1.85177121092134,1.8612108588202,1.86950504404675,1.87858666618536,1.88695252785603,1.8992710039668,1.90998994145834,1.92044406545023,1.93325881936299,1.9484641220537,1.96135719471953,1.97830731677393,1.9933493336296,2.01053594213232,2.03146339358619,2.05289581866667,2.07310241616824,2.09696385947528,2.12151951630359,2.15191486007068,2.20039670238309,2.24711394446681,2.30800393871034,2.43457585062277],"range":[2.22591384652163,2.230802774778,2.23546239454496,2.24093729493409,2.24691132720936,2.25207640253111,2.25711848954445,2.26257788410066,2.26937879553809,2.27632863034704,2.28251384825922,2.28894633683292,2.29685201489767,2.30389287635647,2.31063580959909,2.31859472417178,2.32501638954249,2.33313304952541,2.34154552719839,2.34991415430168,2.35768939575221,2.36697288397517,2.37513621128066,2.38436361932194,2.39357722791474,2.40318935014295,2.41413112282927,2.4244069353319,2.43654883505762,2.44592536388882,2.46069640068571,2.47210217933256,2.4840140754345,2.49911162022067,2.51378903741398,2.52759903878667,2.54230191786081,2.55918000535822,2.57599709125068,2.59563563116634,2.61318658431308,2.63291187767,2.65856886383863,2.68503700708307,2.72286852313628,2.76045743240488,2.80467421534113,2.85714775503752,2.92796133814304,3.05951223403142]},"4":{"max":[1.8863309010041,1.89023763912529,1.89505055324671,1.8996872069726,1.90396104830582,1.90830710813031,1.91295018738968,1.91751604106457,1.92212903036675,1.92796698329961,1.93324324569141,1.93918038241824,1.945610384202,1.95099093303112,1.95723350782807,1.96320972852135,1.9696910872405,1.97536757884356,1.98148833656383,1.98760402287577,1.99470655040184,2.0014831952455,2.00990617784639,2.01800884070615,2.02639046609307,2.03402198587187,2.04207854563661,2.05201428309035,2.05894590307482,2.06609460804903,2.07553346343271,2.0856485989476,2.09526908882824,2.10508945592555,2.11499858552887,2.12644605226194,2.13860160003387,2.15176436484615,2.16599721679536,2.18452237446875,2.20116995886405,2.21810904347873,2.24107971112342,2.26412295727692,2.29053194168806,2.32051977467861,2.35590430637147,2.40898177256112,2.46453707538155,2.56886151964252],"range":[2.68085534937008,2.68643863041128,2.6908988918078,2.69650886566693,2.70257736700686,2.70764593946809,2.71175246283891,2.71747293878633,2.72158437361444,2.72700672699383,2.73143146695321,2.73662193058728,2.74255386879242,2.74847912565621,2.75486166036281,2.76108741679843,2.76740716652912,2.77281938161961,2.78146634553457,2.78919143813695,2.79537030239242,2.8018198049733,2.81000737272204,2.816280430848,2.82471539156299,2.83367986040498,2.84211298312772,2.85132825760796,2.86018746220032,2.87016882462401,2.87997938070164,2.88943946991531,2.89804253908169,2.9110858685435,2.92335162528936,2.93603541766261,2.94784398937913,2.96328163704208,2.98056223715893,2.99937796371285,3.0182300362712,3.04038284733522,3.06024780786437,3.0852877919825,3.1159742587899,3.15044469079801,3.19153065337011,3.24774185664101,3.3196532347537,3.43871361596793]},"6":{"max":[1.8995844505951,1.90372282728502,1.90786349815282,1.91210039341598,1.91648497862793,1.92091285840255,1.92625368162383,1.93110016008493,1.93617083100785,1.94187011880212,1.9472427855027,1.95211092153476,1.95776813619084,1.96349092943121,1.96961608411167,1.97448554973337,1.98048061846908,1.9857239603702,1.99228524462093,1.99798543677965,2.00481875821914,2.01232512752593,2.01966763484381,2.02771381041308,2.03511516275574,2.04266224216936,2.05212705707684,2.05842768327946,2.06555482615441,2.07404845300542,2.08244751617481,2.09215841827476,2.10175646231178,2.11155420066774,2.12143821941805,2.13384118696042,2.14418189402044,2.15661675767253,2.17327200492716,2.1907977153029,2.20853516508261,2.2243689090344,2.24653424911614,2.26914429720656,2.29470772538911,2.32525489078505,2.35818246901503,2.41186736779604,2.46579678405964,2.57025529149703],"range":[2.7404583562364,2.74526328117409,2.75000903381165,2.75490767733301,2.76002132079635,2.76440130873053,2.76901022857535,2.77309254859561,2.77940949186345,2.78498660911762,2.78984130595265,2.79429396217219,2.79938476001166,2.80552173719103,2.81162363606233,2.81625314022632,2.82239472432692,2.82852361821702,2.83588674056336,2.84236578638002,2.84889368703037,2.85554284587873,2.8623506962233,2.87000837096465,2.87687892185265,2.88476905540689,2.8914629666975,2.89960930083652,2.90985178497341,2.91882734915283,2.92927064293427,2.93850099550798,2.94821658960953,2.95824780664208,2.97187662595487,2.98479878169254,2.9992405304303,3.01354138074149,3.02679737077833,3.04371755117878,3.05823594582161,3.07725324893338,3.10116360405558,3.12653746256097,3.15188312762002,3.18540446077727,3.22402527362553,3.28059758452937,3.33859742296181,3.45501953729566]},"8":{"max":[1.90129850983572,1.90516570855328,1.90937175063387,1.91371639502306,1.91794056113743,1.92232123912668,1.92759911760505,1.9324758882332,1.93770964117028,1.94330305432,1.94888292783326,1.95353915653814,1.95924434085755,1.96487051905954,1.97057577644158,1.97560947773326,1.98147802794651,1.98700655564388,1.9931159110948,1.99891607446647,2.00650282065195,2.0132566361031,2.020550829367,2.02869455951327,2.03595001884676,2.04423035024309,2.05317292848793,2.05914487796479,2.06609364605974,2.07470796502465,2.0828482466276,2.09253295606338,2.10192808009171,2.11163306195199,2.12152134245074,2.13393551264924,2.14420431912788,2.15693361041496,2.17354493026062,2.19114045202173,2.20875377365514,2.22491132803164,2.24671042441639,2.2694870882164,2.29516159555825,2.32552183073452,2.35917428857408,2.41186736779604,2.46579678405964,2.57025529149703],"range":[2.76014777604291,2.76418733961071,2.76815169091552,2.77167598773252,2.77655954928124,2.78146097026088,2.78631355742898,2.79087061339873,2.7953816403936,2.80000445263785,2.80525351999,2.81091249083076,2.81568046806229,2.82118924879503,2.82650893062054,2.83352040487738,2.83862963483524,2.84569765572058,2.85153844900335,2.85708296541044,2.86285717062948,2.87000840600416,2.87641710595494,2.88420384308174,2.89077617284757,2.89783163216231,2.90711675054827,2.91511703592227,2.9241057797022,2.93295016488261,2.94225816715147,2.9503275218798,2.96084636824824,2.97276652793634,2.98545049021879,2.99790011832985,3.01101254640026,3.02291289323542,3.03835944621222,3.05228630855523,3.06848780845776,3.09036229828436,3.11081603217328,3.13386847901325,3.16083304895922,3.19257080115555,3.23394177340134,3.28863254640258,3.34193979691794,3.45989182936763]},"10":{"max":[1.90200317899371,1.90575941243566,1.91003224799722,1.91430116495002,1.91852119221045,1.92363924258536,1.92813013037837,1.93318354531244,1.93819181548142,1.94372394322678,1.94920727427515,1.95410938212938,1.95942574616048,1.9650693159028,1.97097369401268,1.97593043984907,1.9816070498163,1.98735507741592,1.99344303519556,1.99907859690203,2.00698531362174,2.01348511642423,2.02095905934155,2.02936696517065,2.03644766225911,2.04438785665452,2.05338145412747,2.05937675809378,2.06616171881744,2.07473789571604,2.08287027642156,2.09256864345591,2.10195202161131,2.11178013692067,2.12170170901203,2.13419420963212,2.14425304938479,2.15761471934841,2.17377124717081,2.19161080737738,2.20907282819197,2.22538374189696,2.24728555022134,2.26978232260259,2.29570318746438,2.32552183073452,2.35917428857408,2.41186736779604,2.46579678405964,2.57025529149703],"range":[2.76948388986443,2.77299763923263,2.77792434665079,2.7826132597037,2.78701514364425,2.79112022029345,2.79577904040062,2.80033862195106,2.80542656199191,2.8104560921729,2.81495535248919,2.82015982068815,2.82517243302741,2.8308412622816,2.83639345481454,2.84230287019126,2.84840763300983,2.85427720899956,2.86007218626277,2.86587077200269,2.87216039748328,2.87833139479387,2.88563012415683,2.89167193279737,2.89857506455057,2.90758394761588,2.9151394480235,2.92360879398065,2.93180030929704,2.94108080663028,2.9485745083463,2.95787033411792,2.97034997781732,2.98147800797676,2.99390722406367,3.00529013612545,3.01728703629982,3.02976740738852,3.04575081523367,3.0589198398709,3.07750042555093,3.09711099050007,3.11982681558604,3.14470691965829,3.16643520386011,3.20077739874266,3.24091911931553,3.29421724800875,3.34840712645623,3.46016442202563]}},"1":{"2":{"max":[2.22408818231127,2.23167217815961,2.2385556255275,2.246716229298,2.25495483554988,2.26367247535366,2.27198147883231,2.28029374580499,2.28997972044219,2.30139150759728,2.31039779234819,2.3203164913249,2.32921900751217,2.33930632358443,2.35063208445546,2.36239255307403,2.37368186178517,2.38399333407731,2.39655947720336,2.40900289159466,2.42051303184748,2.43187800124754,2.44213404011556,2.45546454151652,2.46823974105248,2.48305431089417,2.50014264198274,2.51277454011338,2.52729044406123,2.54412126382912,2.55992945172055,2.57990545930011,2.59954495128891,2.62226086016471,2.6432818653192,2.66757121215124,2.68912688266154,2.71615273475211,2.74499929176667,2.76956419117839,2.79961591720564,2.84219702965024,2.88262759124401,2.92385031781064,2.97162399662873,3.02945819897377,3.08704227453562,3.17273589041428,3.28942508259488,3.45472681303725],"range":[2.46391278744698,2.47126755950339,2.47789609809196,2.4855994326906,2.49370946814411,2.50169702442543,2.51084263695293,2.51772642451113,2.52686751800841,2.53508560150775,2.54523365481574,2.55414141834483,2.56274334764907,2.57155949666418,2.58116077352148,2.59032031413285,2.59843443819996,2.6083661370334,2.61986928303432,2.63050978195371,2.64203524567493,2.65184061301174,2.66228505736591,2.67463123025473,2.68841958585637,2.70066425268548,2.71215670623997,2.72562580843461,2.74020128419521,2.75495164292628,2.77105091902821,2.78812775936112,2.80696636023678,2.82392759229562,2.8449837855047,2.86469516530926,2.88840979845176,2.91285045595049,2.94147009954316,2.97010148443806,2.99880071116574,3.03252303510393,3.06745846850875,3.09882391191133,3.13698530915409,3.18523070148978,3.25840915105249,3.35961532297044,3.46123155558541,3.61269560042025]},"4":{"max":[2.70443676308234,2.71316397536365,2.72230751827108,2.73013628548337,2.73783443325526,2.74528962424803,2.7535013308307,2.76165479244638,2.76995006883156,2.77784350063502,2.78801292378179,2.79690003525357,2.80782434173153,2.81710131124371,2.82810279142842,2.83902929955712,2.84985602895211,2.85943741078032,2.872062366876,2.88195698007885,2.89422935489322,2.90588801177386,2.91830314114826,2.92889241096725,2.94165001703407,2.95537968710744,2.96828782383848,2.98345815507671,3.00088564120662,3.01450613235098,3.03021741060986,3.04514305197666,3.06318938472853,3.08204384920415,3.10118717953729,3.12137345421518,3.14629361944769,3.16975412064978,3.19871150134074,3.22557804826641,3.2528296362616,3.29448456006627,3.32824508683748,3.36800851346221,3.41346594519685,3.46025134389695,3.51542896077976,3.60624261804716,3.71816408123168,3.93535696186154],"range":[3.33072912856251,3.33758996841233,3.34574628680461,3.35164057527594,3.35975732382747,3.36698550013957,3.37452635531217,3.38044996288511,3.38753470587925,3.39580947144644,3.40358327963137,3.41177944315769,3.42016576209468,3.42949501582605,3.43823862826649,3.44841002477554,3.45809823377464,3.46817355099174,3.47605925839772,3.48805443257122,3.49820780120991,3.50949974665316,3.52156441650787,3.5320470898469,3.54431829330582,3.55624329579949,3.56779426092527,3.58056432859899,3.59261460209264,3.60610681143103,3.61867396175126,3.63386444995373,3.6475807282587,3.66506934920104,3.6854219443556,3.70113871160704,3.72372570022497,3.74548478489592,3.76725865414008,3.790024197161,3.81244484420839,3.84358747147426,3.87478305149955,3.91519863316109,3.95946737524246,4.01368527527697,4.07950269876619,4.16606856488569,4.2831799883297,4.43963845666924]},"6":{"max":[2.73714807589866,2.74320513885208,2.75022696456136,2.75779534589076,2.76609400488216,2.77292540014255,2.78258094839249,2.78995735838407,2.79796564416274,2.80837367523907,2.8162252396466,2.82544776912852,2.83581742506166,2.84607795173187,2.85653311722288,2.86615061088975,2.87507755322594,2.88546120078802,2.89647860951724,2.90646370076569,2.91830366891529,2.92793049243892,2.93994000374386,2.9513361640116,2.96290806233328,2.97653791054636,2.98956874067662,3.00281714459409,3.01767474219581,3.03164032383581,3.04573310198876,3.06270932788493,3.08105683136056,3.09911181554597,3.1186451771978,3.14357440726387,3.16175551098466,3.18896143251092,3.21409553789802,3.23793630392874,3.27400632880909,3.30948160598604,3.33991237704364,3.38231671523284,3.42383820313033,3.47339264373285,3.52934179098599,3.61938625967275,3.73434766642562,3.94102916093653],"range":[3.45640727356551,3.46306954978012,3.46973908754325,3.47590947015454,3.4838819577291,3.49160429317181,3.49766509941435,3.5051606793093,3.5131671363738,3.52077620774917,3.52768748709407,3.53425243724035,3.5423682666881,3.54921943409808,3.556952953408,3.56516503882035,3.57347180354981,3.58252656001226,3.59178947066794,3.60080824803134,3.6085046209279,3.617755939703,3.62735693507751,3.63804587000029,3.64855832140359,3.65994343278081,3.67385398834237,3.68571416063101,3.69707055350515,3.71084408067234,3.72598610436897,3.74136265913746,3.75925526443417,3.77429829895792,3.7898503817031,3.80643968787487,3.82369077242765,3.84520006282845,3.86792575376706,3.89205899556563,3.91924340950534,3.94684568892699,3.97600766790138,4.01553543357259,4.06046965038073,4.11229022121636,4.16550978799998,4.24218778199947,4.34328349142068,4.48746892796138]},"8":{"max":[2.74287924359951,2.74972282830356,2.75749248513154,2.76545067687381,2.77239828238273,2.78065638359198,2.78832963965467,2.79587781452729,2.8046128852303,2.81331080938179,2.82132245132351,2.83191307845068,2.84091691021233,2.85104635740391,2.86061643301292,2.87105813546864,2.87864303912487,2.88982113905153,2.90019387355943,2.91100628450779,2.92088700191003,2.9313669347748,2.94237254586805,2.95513502136229,2.96514551259539,2.97934036146678,2.99268186004286,3.00714447420536,3.02151497458958,3.03325532373884,3.04844221000558,3.06521651133586,3.08396500595724,3.10276276238258,3.12128659480993,3.14504206811941,3.1637257017909,3.1920229659298,3.21667996181354,3.24004966347741,3.27485973776243,3.31063124079675,3.34092246893143,3.38333599579249,3.42496818222524,3.47422654487876,3.5293634919398,3.62048050863877,3.73692000120501,3.94102916093653],"range":[3.50502362427164,3.51174962415423,3.51823129600941,3.52500056785711,3.53096083903982,3.53763539897956,3.54494855968431,3.55144998096019,3.55844801303687,3.56546708937295,3.57154342050093,3.57920520221927,3.5869781137461,3.59518899801846,3.60199425758701,3.60850469838616,3.61537720480582,3.62443760121814,3.63380685797965,3.64032646794286,3.65022038386188,3.660111750305,3.67186260083532,3.6839663778893,3.69196098017429,3.70252522625842,3.71590528460708,3.72948219592524,3.74173472804349,3.75708827810526,3.76983808354856,3.78233840784911,3.79846811098198,3.81277851449084,3.82833777617548,3.84651181684259,3.86474711547053,3.88543617489238,3.905121191569,3.93134651776682,3.95426386467871,3.97912716731566,4.01407639010318,4.05306275796484,4.09560460656332,4.14120219480324,4.19025953380752,4.26303665894324,4.36187000960325,4.51752596826224]},"10":{"max":[2.74592761324742,2.75332577427708,2.76033090809588,2.76795746388208,2.77449341898917,2.78377150533344,2.79040905895933,2.79791269784148,2.80812472032002,2.81585876288918,2.82427033701458,2.8345078182179,2.84343425522273,2.85360428459958,2.86243265700872,2.87265383703287,2.88094199122226,2.89140196762897,2.90133608008974,2.91248740560158,2.92234001556265,2.93310201832971,2.94366180788666,2.95594174585483,2.96689759268915,2.98001396428591,2.99480828166113,3.00867661799182,3.02246324396029,3.03394218534334,3.04928862144923,3.06559847575043,3.085387125668,3.10344121252328,3.12169013198376,3.14546814874483,3.16409611837069,3.19331642253382,3.21712193181301,3.24079319998886,3.27693245691716,3.31144207023956,3.34121663787019,3.38431258247793,3.42513870373182,3.47422654487876,3.5293634919398,3.62095881900556,3.73697935597481,3.94102916093653],"range":[3.53381534472487,3.53986469765005,3.54625771772862,3.55264927591488,3.55885056988873,3.56535310539566,3.57069206044516,3.57741821964149,3.58464718016958,3.5925337751768,3.59906345718385,3.60516901034419,3.61189624837151,3.61829137565987,3.62622821191613,3.63382432755621,3.6399216842664,3.64855929411662,3.65706270350488,3.66715043519786,3.67929490093814,3.68762130549175,3.69607530343335,3.70493839788555,3.71711166453008,3.72983287425351,3.7410973195177,3.75490086509486,3.76745283302738,3.77976388577323,3.79281288014532,3.80651205695025,3.81888938666319,3.83372594382547,3.84988819397064,3.86628743484644,3.8840090856432,3.90305033008578,3.92661109582333,3.94850885290388,3.97247127632687,4.00142980951883,4.03492508707269,4.07271715630041,4.11203940618518,4.15440590037256,4.20860501525314,4.28230990061588,4.38417511435477,4.53444344398332]}},"sig_levels":["0.95","0.951","0.952","0.953","0.954","0.955","0.956","0.957","0.958","0.959","0.96","0.961","0.962","0.963","0.964","0.965","0.966","0.967","0.968","0.969","0.97","0.971","0.972","0.973","0.974","0.975","0.976","0.977","0.978","0.979","0.98","0.981","0.982","0.983","0.984","0.985","0.986","0.987","0.988","0.989","0.99","0.991","0.992","0.993","0.994","0.995","0.996","0.997","0.998","0.999"]}
nrt/data/simulate.py ADDED
@@ -0,0 +1,274 @@
1
+ # Copyright (C) 2024 European Union (Joint Research Centre)
2
+ #
3
+ # Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
4
+ # the European Commission - subsequent versions of the EUPL (the "Licence");
5
+ # You may not use this work except in compliance with the Licence.
6
+ # You may obtain a copy of the Licence at:
7
+ #
8
+ # https://joinup.ec.europa.eu/software/page/eupl
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the Licence is distributed on an "AS IS" basis,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the Licence for the specific language governing permissions and
14
+ # limitations under the Licence.
15
+
16
+ import numpy as np
17
+ import xarray as xr
18
+
19
+
20
+ def make_ts(dates, break_idx=-1, intercept=0.7, amplitude=0.15, magnitude=0.25,
21
+ recovery_time=1095, sigma_noise=0.02, n_outlier=3,
22
+ outlier_value=-0.1, n_nan=3):
23
+ """Simulate a harmonic time-series with optional breakpoint, noise and outliers
24
+
25
+ The time-series is generated by adding;
26
+ - an intercept/trend component which varies depending on the phase of the time-series
27
+ (stable, recovery)
28
+ - An annual seasonal component
29
+ - Random noise drawn from a normal distribution (white noise)
30
+ Optional outliers are then added to randomly chosen observation as well as ``np.Nan`` values.
31
+ Note that the seasonal cycles simulation approach used here is rather simplistic,
32
+ using a sinusoidal model and therefore assuming symetrical and regular behaviour
33
+ around the peak of the simulated variable. Actual vegetation signal is often more
34
+ asymetrical and irregular.
35
+
36
+ Args:
37
+ dates (array-like): List or array of dates (numpy.datetime64)
38
+ break_idx (int): Breakpoint index in the date array provided. Defaults to
39
+ ``-1``, corresponding to a stable time-series
40
+ intercept (float): Intercept of the time-series
41
+ amplitude (float): Amplitude of the harmonic model (note that at every point
42
+ of the time-series, the actual model amplitude is multiplied by the intercept
43
+ magnitude (float): Break magnitude (always a drop in y value)
44
+ recovery_time (int): Time (in days) to recover the initial intersect value
45
+ following a break
46
+ sigma_noise (float): Sigma value of the normal distribution (mean = 0) from which
47
+ noise values are drawn
48
+ n_outlier (int): Number of outliers randomly assigned to observations of the
49
+ time-series
50
+ outlier_value (float): Value to assign to outliers
51
+ n_nan (int): Number of ``np.nan`` (no data) assigned to observations of the
52
+ time-series
53
+
54
+ Example:
55
+ >>> from nrt.data import simulate
56
+ >>> import numpy as np
57
+ >>> import matplotlib.pyplot as plt
58
+
59
+ >>> dates = np.arange('2018-01-01', '2022-06-15', dtype='datetime64[W]')
60
+ >>> ts = simulate.make_ts(dates=dates, break_idx=30)
61
+
62
+ >>> plt.plot(dates, ts)
63
+ >>> plt.show()
64
+
65
+ Returns:
66
+ np.ndarray: Array of simulated values of same size as ``dates``
67
+ """
68
+ dates = dates.astype('datetime64[D]')
69
+ timestamps = dates.astype(int)
70
+ ydays = (dates - dates.astype('datetime64[Y]')).astype(int) + 1
71
+ y = np.empty_like(dates, dtype=np.float64)
72
+ # Intercept array
73
+ y[:] = intercept
74
+ # Build trend segment if break
75
+ if break_idx != -1:
76
+ # Segment bounds
77
+ segment_start_y = intercept - magnitude
78
+ segment_start_timestamp = timestamps[break_idx]
79
+ segment_end_timestamp = segment_start_timestamp + recovery_time
80
+ segment_end_idx = np.abs(segment_end_timestamp - timestamps).argmin()
81
+ # Compute y values
82
+ recovery_rate = magnitude / recovery_time
83
+ days_since_break = timestamps - segment_start_timestamp
84
+ trend_segment = (recovery_rate * days_since_break + segment_start_y)[break_idx + 1:segment_end_idx + 1]
85
+ # include into y
86
+ y[break_idx + 1:segment_end_idx + 1] = trend_segment
87
+ # Seasonality
88
+ amplitude_values = amplitude * y
89
+ season = amplitude * np.sin(2 * np.pi * timestamps / 365.25 - 2)
90
+ # noise and outliers
91
+ noise = np.random.normal(0, sigma_noise, dates.size)
92
+ # Combine the 3 (trend, season, noise) components
93
+ ts = y + season + noise
94
+ # Add optional outliers and Nans
95
+ outliers_idx = np.random.choice(np.arange(0, dates.size), size=n_outlier, replace=False)
96
+ nan_idx = np.random.choice(np.arange(0, dates.size), size=n_nan)
97
+ ts[outliers_idx] = outlier_value
98
+ ts[nan_idx] = np.nan
99
+ return ts
100
+
101
+
102
+ def make_cube_parameters(shape=(100,100),
103
+ break_idx_interval=(0,100),
104
+ intercept_interval=(0.6, 0.8),
105
+ amplitude_interval=(0.12, 0.2),
106
+ magnitude_interval=(0.2, 0.3),
107
+ recovery_time_interval=(800,1400),
108
+ sigma_noise_interval=(0.02, 0.04),
109
+ n_outliers_interval=(0,5),
110
+ n_nan_interval=(0,5),
111
+ unstable_proportion=0.5):
112
+ """Create ``xarray.Dataset`` of paramters for generation of synthetic data cube
113
+
114
+ Prepares the main input required by the the ``make_cube`` function. This
115
+ intermediary step eases the creation of multiple synthetic DataArrays sharing
116
+ similar characteristics (e.g. to simulate multispectral data)
117
+
118
+ Args:
119
+ shape (tuple): A size two integer tuple giving the x,y size of the Dataset to be
120
+ generated
121
+ break_idx_interval (tuple): A tuple of two integers indicating the interval
122
+ from which the breakpoint position in the time-series is drawn. Generate
123
+ array of random values passed to the ``break_idx` argument of ``make_ts``.
124
+ Similarly to python ranges, upper bound value is excluded from the resulting
125
+ array. To produce a zero filled array ``(0,1)`` can therefore be used
126
+ TODO: add a default to allow breakpoint at any location (conflict with Nan that indicate no break)
127
+ intercept_interval (tuple): A tuple of two floats providing the interval
128
+ from which intercept is drawn. Generate array of random values passed
129
+ to the ``intercept`` argument of ``make_ts``
130
+ amplitude_interval (tuple): A tuple of two floats indicating the interval
131
+ from which the seasonal amplitude parameter is drawn. Generate array
132
+ of random values passed to the ``amplitude`` argument of ``make_ts``
133
+ magnitude_interval (tuple): A tuple of two floats indicating the interval
134
+ from which the breakpoint magnitude parameter is drawn. Generate array
135
+ of random values passed to the ``magnitude`` argument of ``make_ts``
136
+ recovery_time_interval (tuple): A tuple of two integers indicating the interval
137
+ from which the recovery time parameter (in days) is drawn. Generate array
138
+ of random values passed to the ``recovery_time` argument of ``make_ts``
139
+ sigma_noise_interval (tuple): A tuple of two floats indicating the interval
140
+ from which the white noise level is drawn. Generate array of random
141
+ values passed to the ``sigma_noise` argument of ``make_ts``
142
+ n_outliers_interval (tuple): A tuple of two integers indicating the interval
143
+ from which the number of outliers is drawn. Generate array
144
+ of random values passed to the ``n_outliers` argument of ``make_ts``
145
+ n_nan_interval (tuple): A tuple of two integers indicating the interval
146
+ from which the number of no-data observations is drawn. Generate array
147
+ of random values passed to the ``n_nan` argument of ``make_ts``
148
+ unstable_proportion (float): Proportion of time-series containing a breakpoint.
149
+ The other time-series are stable.
150
+
151
+ Returns:
152
+ xarray.Dataset: Dataset with arrays of parameters required for the generation
153
+ of synthetic time-series using the spatialized version of ``make_ts``
154
+ (see ``make_cube``)
155
+
156
+ Examples:
157
+ >>> import time
158
+ >>> import numpy as np
159
+ >>> import xarray as xr
160
+ >>> from nrt.data import simulate
161
+ >>> import matplotlib.pyplot as plt
162
+ >>> params_nir = simulate.make_cube_parameters(shape=(20,20),
163
+ ... n_outliers_interval=(0,1),
164
+ ... n_nan_interval=(0,1),
165
+ ... break_idx_interval=(50,100))
166
+ >>> params_red = params_nir.copy(deep=True)
167
+ >>> # create parameters for red, green, blue cubes by slightly adjusting intercept,
168
+ >>> # magnitude and amplitude parameters
169
+ >>> params_red['intercept'].data = np.random.uniform(0.09, 0.12, size=(20,20))
170
+ >>> params_red['magnitude'].data = np.random.uniform(-0.1, -0.03, size=(20,20))
171
+ >>> params_red['amplitude'].data = np.random.uniform(0.03, 0.07, size=(20,20))
172
+ >>> params_green = params_nir.copy(deep=True)
173
+ >>> params_green['intercept'].data = np.random.uniform(0.12, 0.20, size=(20,20))
174
+ >>> params_green['magnitude'].data = np.random.uniform(0.05, 0.1, size=(20,20))
175
+ >>> params_green['amplitude'].data = np.random.uniform(0.05, 0.08, size=(20,20))
176
+ >>> params_blue = params_nir.copy(deep=True)
177
+ >>> params_blue['intercept'].data = np.random.uniform(0.08, 0.13, size=(20,20))
178
+ >>> params_blue['magnitude'].data = np.random.uniform(-0.01, 0.01, size=(20,20))
179
+ >>> params_blue['amplitude'].data = np.random.uniform(0.02, 0.04, size=(20,20))
180
+ >>> dates = np.arange('2018-01-01', '2022-06-15', dtype='datetime64[W]')
181
+ >>> # Create cubes (DataArrays) and merge them into a sligle Dataset
182
+ >>> nir = data.make_cube(dates, name='nir', params_ds=params_nir)
183
+ >>> red = data.make_cube(dates, name='red', params_ds=params_red)
184
+ >>> green = data.make_cube(dates, name='green', params_ds=params_green)
185
+ >>> blue = data.make_cube(dates, name='blue', params_ds=params_blue)
186
+ >>> cube = xr.merge([blue, green, red, nir]).to_array()
187
+ >>> # PLot one ts
188
+ >>> cube.isel(x=5, y=5).plot(row='variable')
189
+ >>> plt.show()
190
+ """
191
+ intercept = np.random.uniform(*intercept_interval, size=shape)
192
+ amplitude = np.random.uniform(*amplitude_interval, size=shape)
193
+ magnitude = np.random.uniform(*magnitude_interval, size=shape)
194
+ recovery_time = np.random.randint(*recovery_time_interval, size=shape)
195
+ sigma_noise = np.random.uniform(*sigma_noise_interval, size=shape)
196
+ n_outlier = np.random.randint(*n_outliers_interval, size=shape)
197
+ n_nan = np.random.randint(*n_nan_interval, size=shape)
198
+ break_idx = np.random.randint(*break_idx_interval, size=shape)
199
+ # Make a proportion of these cells stable
200
+ size = np.multiply(*shape)
201
+ stable_size = size - round(unstable_proportion * size)
202
+ break_idx.ravel()[np.random.choice(size, stable_size, replace=False)] = -1
203
+ # Build Dataset of parameters
204
+ params = xr.Dataset(data_vars={'intercept': (['y', 'x'], intercept),
205
+ 'amplitude': (['y', 'x'], amplitude),
206
+ 'magnitude': (['y', 'x'], magnitude),
207
+ 'recovery_time': (['y', 'x'], recovery_time),
208
+ 'sigma_noise': (['y', 'x'], sigma_noise),
209
+ 'n_outlier': (['y', 'x'], n_outlier),
210
+ 'n_nan': (['y', 'x'], n_nan),
211
+ 'break_idx': (['y', 'x'], break_idx)},
212
+ coords={'y': np.arange(shape[0]),
213
+ 'x': np.arange(shape[1])})
214
+ return params
215
+
216
+
217
+ def make_cube(dates, params_ds, outlier_value=0.1, name='ndvi'):
218
+ """Generate a cube of synthetic time-series
219
+
220
+ See ``make_ts`` for more details on how every single time-series is generated
221
+
222
+ Args:
223
+ dates (array-like): List or array of dates (numpy.datetime64)
224
+ params_ds (xarray.Dataset): Dataset containing arrays of time-series generation
225
+ parameters. See ``make_cube_parameters`` for a helper to generate such Dataset.
226
+ Spatial dimensions of the params_ds Dataset are used for the generated cube
227
+ outlier_value (float): Value to assign to outliers
228
+ name (str): Name of the generated variable in the DataArray
229
+
230
+ Return:
231
+ xarray.DataArray: Cube of synthetic time-series generated using the paramters
232
+ provided via ``param_ds`` Dataset.
233
+
234
+ Example:
235
+ >>> import time
236
+ >>> import numpy as np
237
+ >>> from nrt.data import simulate
238
+ >>> import matplotlib.pyplot as plt
239
+ >>> dates = np.arange('2018-01-01', '2022-06-15', dtype='datetime64[W]')
240
+ >>> params_ds = simulate.make_cube_parameters(shape=(100,100),
241
+ ... n_outliers_interval=(0,5),
242
+ ... n_nan_interval=(0,7),
243
+ ... break_idx_interval=(100,dates.size - 20))
244
+ >>> cube = simulate.make_cube(dates=dates, params_ds=params_ds)
245
+ >>> # PLot one ts
246
+ >>> cube.isel(x=5, y=5).plot()
247
+ >>> plt.show()
248
+ """
249
+ nrows, ncols = params_ds.intercept.data.shape
250
+ # Vectorize function
251
+ make_ts_v = np.vectorize(make_ts, signature='(n),(),(),(),(),(),(),(),(),()->(n)')
252
+ # Create output array
253
+ out = make_ts_v(dates=dates,
254
+ break_idx=params_ds.break_idx.data,
255
+ intercept=params_ds.intercept.data,
256
+ amplitude=params_ds.amplitude.data,
257
+ magnitude=params_ds.magnitude.data,
258
+ recovery_time=params_ds.recovery_time.data,
259
+ sigma_noise=params_ds.sigma_noise.data,
260
+ n_outlier=params_ds.n_outlier.data,
261
+ outlier_value=outlier_value,
262
+ n_nan=params_ds.n_nan.data)
263
+ # Build xarray dataset
264
+ xr_cube = xr.DataArray(data=np.moveaxis(out, -1, 0),
265
+ coords={'time': dates,
266
+ 'y': np.arange(nrows),
267
+ 'x': np.arange(ncols)},
268
+ name=name)
269
+ return xr_cube
270
+
271
+ if __name__ == "__main__":
272
+ import doctest
273
+ doctest.testmod()
274
+
@@ -0,0 +1,287 @@
1
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
2
+ EUPL © the European Union 2007, 2016
3
+
4
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined
5
+ below) which is provided under the terms of this Licence. Any use of the Work,
6
+ other than as authorised under this Licence is prohibited (to the extent such
7
+ use is covered by a right of the copyright holder of the Work).
8
+
9
+ The Work is provided under the terms of this Licence when the Licensor (as
10
+ defined below) has placed the following notice immediately following the
11
+ copyright notice for the Work:
12
+
13
+ Licensed under the EUPL
14
+
15
+ or has expressed by any other means his willingness to license under the EUPL.
16
+
17
+ 1. Definitions
18
+
19
+ In this Licence, the following terms have the following meaning:
20
+
21
+ - ‘The Licence’: this Licence.
22
+
23
+ - ‘The Original Work’: the work or software distributed or communicated by the
24
+ Licensor under this Licence, available as Source Code and also as Executable
25
+ Code as the case may be.
26
+
27
+ - ‘Derivative Works’: the works or software that could be created by the
28
+ Licensee, based upon the Original Work or modifications thereof. This Licence
29
+ does not define the extent of modification or dependence on the Original Work
30
+ required in order to classify a work as a Derivative Work; this extent is
31
+ determined by copyright law applicable in the country mentioned in Article 15.
32
+
33
+ - ‘The Work’: the Original Work or its Derivative Works.
34
+
35
+ - ‘The Source Code’: the human-readable form of the Work which is the most
36
+ convenient for people to study and modify.
37
+
38
+ - ‘The Executable Code’: any code which has generally been compiled and which is
39
+ meant to be interpreted by a computer as a program.
40
+
41
+ - ‘The Licensor’: the natural or legal person that distributes or communicates
42
+ the Work under the Licence.
43
+
44
+ - ‘Contributor(s)’: any natural or legal person who modifies the Work under the
45
+ Licence, or otherwise contributes to the creation of a Derivative Work.
46
+
47
+ - ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
48
+ the Work under the terms of the Licence.
49
+
50
+ - ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
51
+ renting, distributing, communicating, transmitting, or otherwise making
52
+ available, online or offline, copies of the Work or providing access to its
53
+ essential functionalities at the disposal of any other natural or legal
54
+ person.
55
+
56
+ 2. Scope of the rights granted by the Licence
57
+
58
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
59
+ sublicensable licence to do the following, for the duration of copyright vested
60
+ in the Original Work:
61
+
62
+ - use the Work in any circumstance and for all usage,
63
+ - reproduce the Work,
64
+ - modify the Work, and make Derivative Works based upon the Work,
65
+ - communicate to the public, including the right to make available or display
66
+ the Work or copies thereof to the public and perform publicly, as the case may
67
+ be, the Work,
68
+ - distribute the Work or copies thereof,
69
+ - lend and rent the Work or copies thereof,
70
+ - sublicense rights in the Work or copies thereof.
71
+
72
+ Those rights can be exercised on any media, supports and formats, whether now
73
+ known or later invented, as far as the applicable law permits so.
74
+
75
+ In the countries where moral rights apply, the Licensor waives his right to
76
+ exercise his moral right to the extent allowed by law in order to make effective
77
+ the licence of the economic rights here above listed.
78
+
79
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
80
+ any patents held by the Licensor, to the extent necessary to make use of the
81
+ rights granted on the Work under this Licence.
82
+
83
+ 3. Communication of the Source Code
84
+
85
+ The Licensor may provide the Work either in its Source Code form, or as
86
+ Executable Code. If the Work is provided as Executable Code, the Licensor
87
+ provides in addition a machine-readable copy of the Source Code of the Work
88
+ along with each copy of the Work that the Licensor distributes or indicates, in
89
+ a notice following the copyright notice attached to the Work, a repository where
90
+ the Source Code is easily and freely accessible for as long as the Licensor
91
+ continues to distribute or communicate the Work.
92
+
93
+ 4. Limitations on copyright
94
+
95
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from
96
+ any exception or limitation to the exclusive rights of the rights owners in the
97
+ Work, of the exhaustion of those rights or of other applicable limitations
98
+ thereto.
99
+
100
+ 5. Obligations of the Licensee
101
+
102
+ The grant of the rights mentioned above is subject to some restrictions and
103
+ obligations imposed on the Licensee. Those obligations are the following:
104
+
105
+ Attribution right: The Licensee shall keep intact all copyright, patent or
106
+ trademarks notices and all notices that refer to the Licence and to the
107
+ disclaimer of warranties. The Licensee must include a copy of such notices and a
108
+ copy of the Licence with every copy of the Work he/she distributes or
109
+ communicates. The Licensee must cause any Derivative Work to carry prominent
110
+ notices stating that the Work has been modified and the date of modification.
111
+
112
+ Copyleft clause: If the Licensee distributes or communicates copies of the
113
+ Original Works or Derivative Works, this Distribution or Communication will be
114
+ done under the terms of this Licence or of a later version of this Licence
115
+ unless the Original Work is expressly distributed only under this version of the
116
+ Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
117
+ (becoming Licensor) cannot offer or impose any additional terms or conditions on
118
+ the Work or Derivative Work that alter or restrict the terms of the Licence.
119
+
120
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative
121
+ Works or copies thereof based upon both the Work and another work licensed under
122
+ a Compatible Licence, this Distribution or Communication can be done under the
123
+ terms of this Compatible Licence. For the sake of this clause, ‘Compatible
124
+ Licence’ refers to the licences listed in the appendix attached to this Licence.
125
+ Should the Licensee's obligations under the Compatible Licence conflict with
126
+ his/her obligations under this Licence, the obligations of the Compatible
127
+ Licence shall prevail.
128
+
129
+ Provision of Source Code: When distributing or communicating copies of the Work,
130
+ the Licensee will provide a machine-readable copy of the Source Code or indicate
131
+ a repository where this Source will be easily and freely available for as long
132
+ as the Licensee continues to distribute or communicate the Work.
133
+
134
+ Legal Protection: This Licence does not grant permission to use the trade names,
135
+ trademarks, service marks, or names of the Licensor, except as required for
136
+ reasonable and customary use in describing the origin of the Work and
137
+ reproducing the content of the copyright notice.
138
+
139
+ 6. Chain of Authorship
140
+
141
+ The original Licensor warrants that the copyright in the Original Work granted
142
+ hereunder is owned by him/her or licensed to him/her and that he/she has the
143
+ power and authority to grant the Licence.
144
+
145
+ Each Contributor warrants that the copyright in the modifications he/she brings
146
+ to the Work are owned by him/her or licensed to him/her and that he/she has the
147
+ power and authority to grant the Licence.
148
+
149
+ Each time You accept the Licence, the original Licensor and subsequent
150
+ Contributors grant You a licence to their contributions to the Work, under the
151
+ terms of this Licence.
152
+
153
+ 7. Disclaimer of Warranty
154
+
155
+ The Work is a work in progress, which is continuously improved by numerous
156
+ Contributors. It is not a finished work and may therefore contain defects or
157
+ ‘bugs’ inherent to this type of development.
158
+
159
+ For the above reason, the Work is provided under the Licence on an ‘as is’ basis
160
+ and without warranties of any kind concerning the Work, including without
161
+ limitation merchantability, fitness for a particular purpose, absence of defects
162
+ or errors, accuracy, non-infringement of intellectual property rights other than
163
+ copyright as stated in Article 6 of this Licence.
164
+
165
+ This disclaimer of warranty is an essential part of the Licence and a condition
166
+ for the grant of any rights to the Work.
167
+
168
+ 8. Disclaimer of Liability
169
+
170
+ Except in the cases of wilful misconduct or damages directly caused to natural
171
+ persons, the Licensor will in no event be liable for any direct or indirect,
172
+ material or moral, damages of any kind, arising out of the Licence or of the use
173
+ of the Work, including without limitation, damages for loss of goodwill, work
174
+ stoppage, computer failure or malfunction, loss of data or any commercial
175
+ damage, even if the Licensor has been advised of the possibility of such damage.
176
+ However, the Licensor will be liable under statutory product liability laws as
177
+ far such laws apply to the Work.
178
+
179
+ 9. Additional agreements
180
+
181
+ While distributing the Work, You may choose to conclude an additional agreement,
182
+ defining obligations or services consistent with this Licence. However, if
183
+ accepting obligations, You may act only on your own behalf and on your sole
184
+ responsibility, not on behalf of the original Licensor or any other Contributor,
185
+ and only if You agree to indemnify, defend, and hold each Contributor harmless
186
+ for any liability incurred by, or claims asserted against such Contributor by
187
+ the fact You have accepted any warranty or additional liability.
188
+
189
+ 10. Acceptance of the Licence
190
+
191
+ The provisions of this Licence can be accepted by clicking on an icon ‘I agree’
192
+ placed under the bottom of a window displaying the text of this Licence or by
193
+ affirming consent in any other similar way, in accordance with the rules of
194
+ applicable law. Clicking on that icon indicates your clear and irrevocable
195
+ acceptance of this Licence and all of its terms and conditions.
196
+
197
+ Similarly, you irrevocably accept this Licence and all of its terms and
198
+ conditions by exercising any rights granted to You by Article 2 of this Licence,
199
+ such as the use of the Work, the creation by You of a Derivative Work or the
200
+ Distribution or Communication by You of the Work or copies thereof.
201
+
202
+ 11. Information to the public
203
+
204
+ In case of any Distribution or Communication of the Work by means of electronic
205
+ communication by You (for example, by offering to download the Work from a
206
+ remote location) the distribution channel or media (for example, a website) must
207
+ at least provide to the public the information requested by the applicable law
208
+ regarding the Licensor, the Licence and the way it may be accessible, concluded,
209
+ stored and reproduced by the Licensee.
210
+
211
+ 12. Termination of the Licence
212
+
213
+ The Licence and the rights granted hereunder will terminate automatically upon
214
+ any breach by the Licensee of the terms of the Licence.
215
+
216
+ Such a termination will not terminate the licences of any person who has
217
+ received the Work from the Licensee under the Licence, provided such persons
218
+ remain in full compliance with the Licence.
219
+
220
+ 13. Miscellaneous
221
+
222
+ Without prejudice of Article 9 above, the Licence represents the complete
223
+ agreement between the Parties as to the Work.
224
+
225
+ If any provision of the Licence is invalid or unenforceable under applicable
226
+ law, this will not affect the validity or enforceability of the Licence as a
227
+ whole. Such provision will be construed or reformed so as necessary to make it
228
+ valid and enforceable.
229
+
230
+ The European Commission may publish other linguistic versions or new versions of
231
+ this Licence or updated versions of the Appendix, so far this is required and
232
+ reasonable, without reducing the scope of the rights granted by the Licence. New
233
+ versions of the Licence will be published with a unique version number.
234
+
235
+ All linguistic versions of this Licence, approved by the European Commission,
236
+ have identical value. Parties can take advantage of the linguistic version of
237
+ their choice.
238
+
239
+ 14. Jurisdiction
240
+
241
+ Without prejudice to specific agreement between parties,
242
+
243
+ - any litigation resulting from the interpretation of this License, arising
244
+ between the European Union institutions, bodies, offices or agencies, as a
245
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
246
+ of Justice of the European Union, as laid down in article 272 of the Treaty on
247
+ the Functioning of the European Union,
248
+
249
+ - any litigation arising between other parties and resulting from the
250
+ interpretation of this License, will be subject to the exclusive jurisdiction
251
+ of the competent court where the Licensor resides or conducts its primary
252
+ business.
253
+
254
+ 15. Applicable Law
255
+
256
+ Without prejudice to specific agreement between parties,
257
+
258
+ - this Licence shall be governed by the law of the European Union Member State
259
+ where the Licensor has his seat, resides or has his registered office,
260
+
261
+ - this licence shall be governed by Belgian law if the Licensor has no seat,
262
+ residence or registered office inside a European Union Member State.
263
+
264
+ Appendix
265
+
266
+ ‘Compatible Licences’ according to Article 5 EUPL are:
267
+
268
+ - GNU General Public License (GPL) v. 2, v. 3
269
+ - GNU Affero General Public License (AGPL) v. 3
270
+ - Open Software License (OSL) v. 2.1, v. 3.0
271
+ - Eclipse Public License (EPL) v. 1.0
272
+ - CeCILL v. 2.0, v. 2.1
273
+ - Mozilla Public Licence (MPL) v. 2
274
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
275
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
276
+ works other than software
277
+ - European Union Public Licence (EUPL) v. 1.1, v. 1.2
278
+ - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
279
+ Reciprocity (LiLiQ-R+).
280
+
281
+ The European Commission may update this Appendix to later versions of the above
282
+ licences without producing a new version of the EUPL, as long as they provide
283
+ the rights granted in Article 2 of this Licence and protect the covered Source
284
+ Code from exclusive appropriation.
285
+
286
+ All other changes or additions to this Appendix require the production of a new
287
+ EUPL version.
@@ -0,0 +1,356 @@
1
+ Metadata-Version: 2.1
2
+ Name: nrt-data
3
+ Version: 0.0.1
4
+ Summary: nrt namespace package giving access to demo and test datasets, extracted from nrt core
5
+ Author: Jonas Viehweger, Kenji Ose
6
+ Author-email: Loic Dutrieux <loic.dutrieux@ec.europa.eu>
7
+ Maintainer-email: Loic Dutrieux <loic.dutrieux@ec.europa.eu>
8
+ License: EUROPEAN UNION PUBLIC LICENCE v. 1.2
9
+ EUPL © the European Union 2007, 2016
10
+
11
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined
12
+ below) which is provided under the terms of this Licence. Any use of the Work,
13
+ other than as authorised under this Licence is prohibited (to the extent such
14
+ use is covered by a right of the copyright holder of the Work).
15
+
16
+ The Work is provided under the terms of this Licence when the Licensor (as
17
+ defined below) has placed the following notice immediately following the
18
+ copyright notice for the Work:
19
+
20
+ Licensed under the EUPL
21
+
22
+ or has expressed by any other means his willingness to license under the EUPL.
23
+
24
+ 1. Definitions
25
+
26
+ In this Licence, the following terms have the following meaning:
27
+
28
+ - ‘The Licence’: this Licence.
29
+
30
+ - ‘The Original Work’: the work or software distributed or communicated by the
31
+ Licensor under this Licence, available as Source Code and also as Executable
32
+ Code as the case may be.
33
+
34
+ - ‘Derivative Works’: the works or software that could be created by the
35
+ Licensee, based upon the Original Work or modifications thereof. This Licence
36
+ does not define the extent of modification or dependence on the Original Work
37
+ required in order to classify a work as a Derivative Work; this extent is
38
+ determined by copyright law applicable in the country mentioned in Article 15.
39
+
40
+ - ‘The Work’: the Original Work or its Derivative Works.
41
+
42
+ - ‘The Source Code’: the human-readable form of the Work which is the most
43
+ convenient for people to study and modify.
44
+
45
+ - ‘The Executable Code’: any code which has generally been compiled and which is
46
+ meant to be interpreted by a computer as a program.
47
+
48
+ - ‘The Licensor’: the natural or legal person that distributes or communicates
49
+ the Work under the Licence.
50
+
51
+ - ‘Contributor(s)’: any natural or legal person who modifies the Work under the
52
+ Licence, or otherwise contributes to the creation of a Derivative Work.
53
+
54
+ - ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
55
+ the Work under the terms of the Licence.
56
+
57
+ - ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
58
+ renting, distributing, communicating, transmitting, or otherwise making
59
+ available, online or offline, copies of the Work or providing access to its
60
+ essential functionalities at the disposal of any other natural or legal
61
+ person.
62
+
63
+ 2. Scope of the rights granted by the Licence
64
+
65
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
66
+ sublicensable licence to do the following, for the duration of copyright vested
67
+ in the Original Work:
68
+
69
+ - use the Work in any circumstance and for all usage,
70
+ - reproduce the Work,
71
+ - modify the Work, and make Derivative Works based upon the Work,
72
+ - communicate to the public, including the right to make available or display
73
+ the Work or copies thereof to the public and perform publicly, as the case may
74
+ be, the Work,
75
+ - distribute the Work or copies thereof,
76
+ - lend and rent the Work or copies thereof,
77
+ - sublicense rights in the Work or copies thereof.
78
+
79
+ Those rights can be exercised on any media, supports and formats, whether now
80
+ known or later invented, as far as the applicable law permits so.
81
+
82
+ In the countries where moral rights apply, the Licensor waives his right to
83
+ exercise his moral right to the extent allowed by law in order to make effective
84
+ the licence of the economic rights here above listed.
85
+
86
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
87
+ any patents held by the Licensor, to the extent necessary to make use of the
88
+ rights granted on the Work under this Licence.
89
+
90
+ 3. Communication of the Source Code
91
+
92
+ The Licensor may provide the Work either in its Source Code form, or as
93
+ Executable Code. If the Work is provided as Executable Code, the Licensor
94
+ provides in addition a machine-readable copy of the Source Code of the Work
95
+ along with each copy of the Work that the Licensor distributes or indicates, in
96
+ a notice following the copyright notice attached to the Work, a repository where
97
+ the Source Code is easily and freely accessible for as long as the Licensor
98
+ continues to distribute or communicate the Work.
99
+
100
+ 4. Limitations on copyright
101
+
102
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from
103
+ any exception or limitation to the exclusive rights of the rights owners in the
104
+ Work, of the exhaustion of those rights or of other applicable limitations
105
+ thereto.
106
+
107
+ 5. Obligations of the Licensee
108
+
109
+ The grant of the rights mentioned above is subject to some restrictions and
110
+ obligations imposed on the Licensee. Those obligations are the following:
111
+
112
+ Attribution right: The Licensee shall keep intact all copyright, patent or
113
+ trademarks notices and all notices that refer to the Licence and to the
114
+ disclaimer of warranties. The Licensee must include a copy of such notices and a
115
+ copy of the Licence with every copy of the Work he/she distributes or
116
+ communicates. The Licensee must cause any Derivative Work to carry prominent
117
+ notices stating that the Work has been modified and the date of modification.
118
+
119
+ Copyleft clause: If the Licensee distributes or communicates copies of the
120
+ Original Works or Derivative Works, this Distribution or Communication will be
121
+ done under the terms of this Licence or of a later version of this Licence
122
+ unless the Original Work is expressly distributed only under this version of the
123
+ Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
124
+ (becoming Licensor) cannot offer or impose any additional terms or conditions on
125
+ the Work or Derivative Work that alter or restrict the terms of the Licence.
126
+
127
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative
128
+ Works or copies thereof based upon both the Work and another work licensed under
129
+ a Compatible Licence, this Distribution or Communication can be done under the
130
+ terms of this Compatible Licence. For the sake of this clause, ‘Compatible
131
+ Licence’ refers to the licences listed in the appendix attached to this Licence.
132
+ Should the Licensee's obligations under the Compatible Licence conflict with
133
+ his/her obligations under this Licence, the obligations of the Compatible
134
+ Licence shall prevail.
135
+
136
+ Provision of Source Code: When distributing or communicating copies of the Work,
137
+ the Licensee will provide a machine-readable copy of the Source Code or indicate
138
+ a repository where this Source will be easily and freely available for as long
139
+ as the Licensee continues to distribute or communicate the Work.
140
+
141
+ Legal Protection: This Licence does not grant permission to use the trade names,
142
+ trademarks, service marks, or names of the Licensor, except as required for
143
+ reasonable and customary use in describing the origin of the Work and
144
+ reproducing the content of the copyright notice.
145
+
146
+ 6. Chain of Authorship
147
+
148
+ The original Licensor warrants that the copyright in the Original Work granted
149
+ hereunder is owned by him/her or licensed to him/her and that he/she has the
150
+ power and authority to grant the Licence.
151
+
152
+ Each Contributor warrants that the copyright in the modifications he/she brings
153
+ to the Work are owned by him/her or licensed to him/her and that he/she has the
154
+ power and authority to grant the Licence.
155
+
156
+ Each time You accept the Licence, the original Licensor and subsequent
157
+ Contributors grant You a licence to their contributions to the Work, under the
158
+ terms of this Licence.
159
+
160
+ 7. Disclaimer of Warranty
161
+
162
+ The Work is a work in progress, which is continuously improved by numerous
163
+ Contributors. It is not a finished work and may therefore contain defects or
164
+ ‘bugs’ inherent to this type of development.
165
+
166
+ For the above reason, the Work is provided under the Licence on an ‘as is’ basis
167
+ and without warranties of any kind concerning the Work, including without
168
+ limitation merchantability, fitness for a particular purpose, absence of defects
169
+ or errors, accuracy, non-infringement of intellectual property rights other than
170
+ copyright as stated in Article 6 of this Licence.
171
+
172
+ This disclaimer of warranty is an essential part of the Licence and a condition
173
+ for the grant of any rights to the Work.
174
+
175
+ 8. Disclaimer of Liability
176
+
177
+ Except in the cases of wilful misconduct or damages directly caused to natural
178
+ persons, the Licensor will in no event be liable for any direct or indirect,
179
+ material or moral, damages of any kind, arising out of the Licence or of the use
180
+ of the Work, including without limitation, damages for loss of goodwill, work
181
+ stoppage, computer failure or malfunction, loss of data or any commercial
182
+ damage, even if the Licensor has been advised of the possibility of such damage.
183
+ However, the Licensor will be liable under statutory product liability laws as
184
+ far such laws apply to the Work.
185
+
186
+ 9. Additional agreements
187
+
188
+ While distributing the Work, You may choose to conclude an additional agreement,
189
+ defining obligations or services consistent with this Licence. However, if
190
+ accepting obligations, You may act only on your own behalf and on your sole
191
+ responsibility, not on behalf of the original Licensor or any other Contributor,
192
+ and only if You agree to indemnify, defend, and hold each Contributor harmless
193
+ for any liability incurred by, or claims asserted against such Contributor by
194
+ the fact You have accepted any warranty or additional liability.
195
+
196
+ 10. Acceptance of the Licence
197
+
198
+ The provisions of this Licence can be accepted by clicking on an icon ‘I agree’
199
+ placed under the bottom of a window displaying the text of this Licence or by
200
+ affirming consent in any other similar way, in accordance with the rules of
201
+ applicable law. Clicking on that icon indicates your clear and irrevocable
202
+ acceptance of this Licence and all of its terms and conditions.
203
+
204
+ Similarly, you irrevocably accept this Licence and all of its terms and
205
+ conditions by exercising any rights granted to You by Article 2 of this Licence,
206
+ such as the use of the Work, the creation by You of a Derivative Work or the
207
+ Distribution or Communication by You of the Work or copies thereof.
208
+
209
+ 11. Information to the public
210
+
211
+ In case of any Distribution or Communication of the Work by means of electronic
212
+ communication by You (for example, by offering to download the Work from a
213
+ remote location) the distribution channel or media (for example, a website) must
214
+ at least provide to the public the information requested by the applicable law
215
+ regarding the Licensor, the Licence and the way it may be accessible, concluded,
216
+ stored and reproduced by the Licensee.
217
+
218
+ 12. Termination of the Licence
219
+
220
+ The Licence and the rights granted hereunder will terminate automatically upon
221
+ any breach by the Licensee of the terms of the Licence.
222
+
223
+ Such a termination will not terminate the licences of any person who has
224
+ received the Work from the Licensee under the Licence, provided such persons
225
+ remain in full compliance with the Licence.
226
+
227
+ 13. Miscellaneous
228
+
229
+ Without prejudice of Article 9 above, the Licence represents the complete
230
+ agreement between the Parties as to the Work.
231
+
232
+ If any provision of the Licence is invalid or unenforceable under applicable
233
+ law, this will not affect the validity or enforceability of the Licence as a
234
+ whole. Such provision will be construed or reformed so as necessary to make it
235
+ valid and enforceable.
236
+
237
+ The European Commission may publish other linguistic versions or new versions of
238
+ this Licence or updated versions of the Appendix, so far this is required and
239
+ reasonable, without reducing the scope of the rights granted by the Licence. New
240
+ versions of the Licence will be published with a unique version number.
241
+
242
+ All linguistic versions of this Licence, approved by the European Commission,
243
+ have identical value. Parties can take advantage of the linguistic version of
244
+ their choice.
245
+
246
+ 14. Jurisdiction
247
+
248
+ Without prejudice to specific agreement between parties,
249
+
250
+ - any litigation resulting from the interpretation of this License, arising
251
+ between the European Union institutions, bodies, offices or agencies, as a
252
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
253
+ of Justice of the European Union, as laid down in article 272 of the Treaty on
254
+ the Functioning of the European Union,
255
+
256
+ - any litigation arising between other parties and resulting from the
257
+ interpretation of this License, will be subject to the exclusive jurisdiction
258
+ of the competent court where the Licensor resides or conducts its primary
259
+ business.
260
+
261
+ 15. Applicable Law
262
+
263
+ Without prejudice to specific agreement between parties,
264
+
265
+ - this Licence shall be governed by the law of the European Union Member State
266
+ where the Licensor has his seat, resides or has his registered office,
267
+
268
+ - this licence shall be governed by Belgian law if the Licensor has no seat,
269
+ residence or registered office inside a European Union Member State.
270
+
271
+ Appendix
272
+
273
+ ‘Compatible Licences’ according to Article 5 EUPL are:
274
+
275
+ - GNU General Public License (GPL) v. 2, v. 3
276
+ - GNU Affero General Public License (AGPL) v. 3
277
+ - Open Software License (OSL) v. 2.1, v. 3.0
278
+ - Eclipse Public License (EPL) v. 1.0
279
+ - CeCILL v. 2.0, v. 2.1
280
+ - Mozilla Public Licence (MPL) v. 2
281
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
282
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
283
+ works other than software
284
+ - European Union Public Licence (EUPL) v. 1.1, v. 1.2
285
+ - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
286
+ Reciprocity (LiLiQ-R+).
287
+
288
+ The European Commission may update this Appendix to later versions of the above
289
+ licences without producing a new version of the EUPL, as long as they provide
290
+ the rights granted in Article 2 of this Licence and protect the covered Source
291
+ Code from exclusive appropriation.
292
+
293
+ All other changes or additions to this Appendix require the production of a new
294
+ EUPL version.
295
+
296
+ Project-URL: homepage, https://code.europa.eu/jrc-forest/nrt-data
297
+ Keywords: sentinel2,xarray,zarr,netcdf
298
+ Classifier: Programming Language :: Python :: 3
299
+ Classifier: Programming Language :: Python :: 3.9
300
+ Classifier: Programming Language :: Python :: 3.10
301
+ Classifier: Programming Language :: Python :: 3.11
302
+ Requires-Python: >=3.9
303
+ Description-Content-Type: text/x-rst
304
+ License-File: LICENSE
305
+ Requires-Dist: numpy
306
+ Requires-Dist: xarray
307
+ Requires-Dist: rasterio
308
+ Requires-Dist: fiona
309
+ Requires-Dist: rioxarray
310
+ Requires-Dist: netCDF4
311
+ Requires-Dist: zarr
312
+ Requires-Dist: aiohttp
313
+ Requires-Dist: fsspec
314
+ Requires-Dist: pooch
315
+ Provides-Extra: docs
316
+ Requires-Dist: sphinx; extra == "docs"
317
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
318
+
319
+ ********
320
+ nrt-data
321
+ ********
322
+
323
+ **nrt-data** is a companion package to `nrt <https://github.com/ec-jrc/nrt>`_, designed for near real-time monitoring of satellite image time series. It provides easy access to curated datasets for testing and demonstrating **nrt**'s capabilities.
324
+
325
+ As of ``nrt==0.2.1``, the ``data`` module has been separated from the core package to simplify maintenance and keep the core **nrt** lightweight. This package is distributed as a namespace package, ensuring backward compatibility with previous versions.
326
+
327
+ For more details, see the full documentation at `nrt-data.readthedocs.io <https://nrt-data.readthedocs.io/>`_.
328
+
329
+ Features
330
+ ========
331
+
332
+ - Access to small-sized test data in NetCDF format and associated reference data in FlatGeoBuf, managed via `Pooch <https://www.fatiando.org/pooch/latest/>`_.
333
+ - Streaming access to larger datasets stored as cloud-optimized Zarr stores.
334
+ - Synthetic data simulation functionalities.
335
+
336
+ Installation
337
+ ============
338
+
339
+ To install **nrt-data**, run:
340
+
341
+ .. code-block:: bash
342
+
343
+ pip install nrt-data
344
+
345
+ Please note that **nrt-data** can be installed independently of **nrt** but is incompatible with ``nrt<=0.2.1``. To check your current **nrt** version, run:
346
+
347
+ .. code-block:: bash
348
+
349
+ pip freeze | grep nrt
350
+
351
+ If necessary, update **nrt** by running:
352
+
353
+ .. code-block:: bash
354
+
355
+ pip install -U nrt
356
+
@@ -0,0 +1,8 @@
1
+ nrt/data/__init__.py,sha256=NJeG35xsITheO-yQxOoa-iwxrOcrxODnyQqFC33vuK8,12422
2
+ nrt/data/mreCritValTable.json,sha256=PVtAXUsZCPlPho2WQzFfvnj6BCBj8Jx64dIpLgShvl4,26151
3
+ nrt/data/simulate.py,sha256=Mvuw50e9AuVu9hagnYfFD0HuQnQBYicppg7TZrbfCD8,14514
4
+ nrt_data-0.0.1.dist-info/LICENSE,sha256=b8nnCcy_4Nd_v_okJ6mDKCvi64jkexzbSfIag7TR5mU,13827
5
+ nrt_data-0.0.1.dist-info/METADATA,sha256=lRAa3_jlKpTUq4a2F0K01fsQvsEZMQ6lp59Enob17FU,18477
6
+ nrt_data-0.0.1.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
7
+ nrt_data-0.0.1.dist-info/top_level.txt,sha256=MZT1YZNVoDJG3HQqwAmY5i310aWiOxB7GaPANWE8bfM,4
8
+ nrt_data-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (74.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ nrt