cubexpress 0.1.12__tar.gz → 0.1.13__tar.gz
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.
Potentially problematic release.
This version of cubexpress might be problematic. Click here for more details.
- {cubexpress-0.1.12 → cubexpress-0.1.13}/PKG-INFO +1 -1
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/__init__.py +1 -7
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/cloud_utils.py +5 -1
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/cube.py +7 -1
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/geotyping.py +1 -10
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/request.py +1 -3
- {cubexpress-0.1.12 → cubexpress-0.1.13}/pyproject.toml +1 -1
- {cubexpress-0.1.12 → cubexpress-0.1.13}/LICENSE +0 -0
- {cubexpress-0.1.12 → cubexpress-0.1.13}/README.md +0 -0
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/cache.py +0 -0
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/conversion.py +0 -0
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/downloader.py +0 -0
- {cubexpress-0.1.12 → cubexpress-0.1.13}/cubexpress/geospatial.py +0 -0
|
@@ -3,11 +3,9 @@ from cubexpress.geotyping import RasterTransform, Request, RequestSet, Geotransf
|
|
|
3
3
|
from cubexpress.cloud_utils import s2_table
|
|
4
4
|
from cubexpress.cube import get_cube
|
|
5
5
|
from cubexpress.request import table_to_requestset
|
|
6
|
+
import importlib.metadata
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
# pyproj
|
|
10
|
-
# Export the functions
|
|
11
9
|
__all__ = [
|
|
12
10
|
"lonlat2rt",
|
|
13
11
|
"RasterTransform",
|
|
@@ -19,8 +17,4 @@ __all__ = [
|
|
|
19
17
|
"s2_table",
|
|
20
18
|
"table_to_requestset"
|
|
21
19
|
]
|
|
22
|
-
|
|
23
|
-
# # Dynamic version import
|
|
24
|
-
# import importlib.metadata
|
|
25
|
-
|
|
26
20
|
# __version__ = importlib.metadata.version("cubexpress")
|
|
@@ -63,6 +63,7 @@ def _cloud_table_single_range(
|
|
|
63
63
|
.filterBounds(roi)
|
|
64
64
|
.filterDate(start, end)
|
|
65
65
|
)
|
|
66
|
+
|
|
66
67
|
ic = (
|
|
67
68
|
s2
|
|
68
69
|
.linkCollection(
|
|
@@ -71,6 +72,7 @@ def _cloud_table_single_range(
|
|
|
71
72
|
)
|
|
72
73
|
.select(["cs_cdf"])
|
|
73
74
|
)
|
|
75
|
+
|
|
74
76
|
ids_inside = (
|
|
75
77
|
ic
|
|
76
78
|
.map(
|
|
@@ -103,7 +105,9 @@ def _cloud_table_single_range(
|
|
|
103
105
|
date=lambda d: pd.to_datetime(d["id"].str[:8], format="%Y%m%d").dt.strftime("%Y-%m-%d")
|
|
104
106
|
)
|
|
105
107
|
)
|
|
108
|
+
|
|
106
109
|
df_raw["inside"] = df_raw["id"].isin(set(ids_inside)).astype(int)
|
|
110
|
+
|
|
107
111
|
df_raw['cs_cdf'] = df_raw.groupby('date').apply(
|
|
108
112
|
lambda group: group['cs_cdf'].transform(
|
|
109
113
|
lambda _: group[group['inside'] == 1]['cs_cdf'].iloc[0]
|
|
@@ -111,7 +115,7 @@ def _cloud_table_single_range(
|
|
|
111
115
|
else group['cs_cdf'].mean()
|
|
112
116
|
)
|
|
113
117
|
).reset_index(drop=True)
|
|
114
|
-
|
|
118
|
+
|
|
115
119
|
return df_raw
|
|
116
120
|
|
|
117
121
|
def s2_table(
|
|
@@ -93,7 +93,13 @@ def get_cube(
|
|
|
93
93
|
nworks=nworks
|
|
94
94
|
): row.id for _, row in dataframe.iterrows()
|
|
95
95
|
}
|
|
96
|
-
for future in tqdm(
|
|
96
|
+
for future in tqdm(
|
|
97
|
+
as_completed(futures),
|
|
98
|
+
total=len(futures),
|
|
99
|
+
desc="Downloading images",
|
|
100
|
+
unit="image",
|
|
101
|
+
leave=True
|
|
102
|
+
):
|
|
97
103
|
try:
|
|
98
104
|
future.result()
|
|
99
105
|
except Exception as exc:
|
|
@@ -301,8 +301,6 @@ class RequestSet(BaseModel):
|
|
|
301
301
|
"crsCode": meta.raster_transform.crs,
|
|
302
302
|
},
|
|
303
303
|
},
|
|
304
|
-
# "cs_cdf": int(meta.id.split("_")[-1]) / 100,
|
|
305
|
-
# "date": meta.id.split("_")[0],
|
|
306
304
|
"outname": f"{meta.id}.tif",
|
|
307
305
|
}
|
|
308
306
|
|
|
@@ -423,18 +421,16 @@ class RequestSet(BaseModel):
|
|
|
423
421
|
def validate_metadata(self) -> RequestSet:
|
|
424
422
|
"""
|
|
425
423
|
Validates that all entries have consistent and valid CRS formats.
|
|
426
|
-
|
|
424
|
+
|
|
427
425
|
Returns:
|
|
428
426
|
RasterTransformSet: The validated instance.
|
|
429
427
|
|
|
430
428
|
Raises:
|
|
431
429
|
ValueError: If any CRS is invalid or inconsistent.
|
|
432
430
|
"""
|
|
433
|
-
# 1. Pre-consistency validation (CRS, IDs, etc.)
|
|
434
431
|
crs_set: Set[str] = {meta.raster_transform.crs for meta in self.requestset}
|
|
435
432
|
validated_crs: Set[str] = set()
|
|
436
433
|
|
|
437
|
-
# Validate CRS formats
|
|
438
434
|
for crs in crs_set:
|
|
439
435
|
if crs not in validated_crs:
|
|
440
436
|
try:
|
|
@@ -443,16 +439,11 @@ class RequestSet(BaseModel):
|
|
|
443
439
|
except Exception as e:
|
|
444
440
|
raise ValueError(f"Invalid CRS format: {crs}") from e
|
|
445
441
|
|
|
446
|
-
# Validate ids, they must be unique
|
|
447
442
|
ids = {meta.id for meta in self.requestset}
|
|
448
443
|
if len(ids) != len(self.requestset):
|
|
449
444
|
raise ValueError("All entries must have unique IDs")
|
|
450
445
|
|
|
451
|
-
# Upgrade same_coordinates to True if all coordinates are the same
|
|
452
|
-
# 2. We create the dataframe
|
|
453
446
|
self._dataframe = self.create_manifests()
|
|
454
|
-
|
|
455
|
-
# 3. We validate the structure of the dataframe
|
|
456
447
|
self._validate_dataframe_schema()
|
|
457
448
|
|
|
458
449
|
return self
|
|
@@ -35,7 +35,7 @@ def table_to_requestset(
|
|
|
35
35
|
df = table.copy()
|
|
36
36
|
|
|
37
37
|
if df.empty:
|
|
38
|
-
raise ValueError("There are no images in the requested period. Please check your dates or
|
|
38
|
+
raise ValueError("There are no images in the requested period. Please check your dates, ubication or cloud coverage.")
|
|
39
39
|
|
|
40
40
|
rt = lonlat2rt(
|
|
41
41
|
lon=df.attrs["lon"],
|
|
@@ -86,10 +86,8 @@ def table_to_requestset(
|
|
|
86
86
|
)
|
|
87
87
|
else:
|
|
88
88
|
for img_id in img_ids:
|
|
89
|
-
# tile = img_id.split("_")[-1][1:]
|
|
90
89
|
reqs.append(
|
|
91
90
|
Request(
|
|
92
|
-
# id=f"{day}_{centre_hash}_{tile}_{cdf}",
|
|
93
91
|
id=f"{day}_{centre_hash}_{cdf}",
|
|
94
92
|
raster_transform=rt,
|
|
95
93
|
image=f"{df.attrs['collection']}/{img_id}",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|