satcube 0.1.29__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.
satcube-0.1.29/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024, Cesar Aybar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,222 @@
1
+ Metadata-Version: 2.1
2
+ Name: satcube
3
+ Version: 0.1.29
4
+ Summary: A Python package to create cloud-free monthly composites by fusing Landsat and Sentinel-2 data.
5
+ Home-page: https://github.com/IPL-UV/satcube
6
+ Author: Cesar Aybar
7
+ Author-email: fcesar.aybar@uv.es
8
+ Requires-Python: >=3.9
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Provides-Extra: full
15
+ Requires-Dist: cubexpress (==0.1.25)
16
+ Requires-Dist: mlstac (>=0.4.5)
17
+ Requires-Dist: phicloudmask (>=0.0.2)
18
+ Requires-Dist: requests (>=2.26.0)
19
+ Requires-Dist: satalign (==0.1.16)
20
+ Requires-Dist: scikit-learn (>=1.2.0)
21
+ Requires-Dist: segmentation-models-pytorch (>=0.3.0)
22
+ Requires-Dist: sen2sr (>=0.8.5)
23
+ Requires-Dist: torch (>=2.0.0) ; extra == "full"
24
+ Requires-Dist: tqdm (>=4.67.1)
25
+ Requires-Dist: xarray (>=2023.7.0)
26
+ Project-URL: Documentation, https://ipl-uv.github.io/satcube/
27
+ Project-URL: Repository, https://github.com/IPL-UV/satcube
28
+ Description-Content-Type: text/markdown
29
+
30
+ #
31
+
32
+ <p align="center">
33
+ <img src="https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/banner_satcube.png" width="33%">
34
+ </p>
35
+
36
+ <p align="center">
37
+ <em>A python package for managing Sentinel-2 satellite data cubes</em> 🚀
38
+ </p>
39
+
40
+ <p align="center">
41
+ <a href='https://pypi.python.org/pypi/satcube'>
42
+ <img src='https://img.shields.io/pypi/v/satcube.svg' alt='PyPI' />
43
+ </a>
44
+ <a href="https://opensource.org/licenses/MIT" target="_blank">
45
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License">
46
+ </a>
47
+ <a href="https://github.com/psf/black" target="_blank">
48
+ <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black">
49
+ </a>
50
+ <a href="https://pycqa.github.io/isort/" target="_blank">
51
+ <img src="https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336" alt="isort">
52
+ </a>
53
+ </p>
54
+
55
+ ---
56
+
57
+ **GitHub**: [https://github.com/IPL-UV/satcube](https://github.com/IPL-UV/satcube) 🌐
58
+
59
+ **PyPI**: [https://pypi.org/project/satcube/](https://pypi.org/project/satcube/) 🛠️
60
+
61
+ ---
62
+
63
+ ## **Overview** 📊
64
+
65
+ **satcube** is a Python package designed for efficient management, processing, and analysis of Sentinel-2 satellite image cubes. It allows for downloading, cloud masking, gap filling, and super-resolving Sentinel-2 imagery, as well as creating monthly composites and performing interpolation.
66
+
67
+ ## **Key Features** ✨
68
+ - **Satellite image download**: Retrieve Sentinel-2 images from Earth Engine efficiently. 🛰️
69
+ - **Cloud masking**: Automatically remove clouds from Sentinel-2 images. ☁️
70
+ - **Gap filling**: Fill missing data using methods like linear interpolation and histogram matching. 🧩
71
+ - **Super-resolution**: Apply super-resolution models to enhance image quality. 🔍
72
+ - **Monthly composites**: Aggregate images into monthly composites with various statistical methods. 📅
73
+ - **Temporal smoothing**: Smooth reflectance values across time using interpolation techniques. 📈
74
+ ## **Installation** ⚙️
75
+
76
+ Install the latest version from PyPI:
77
+
78
+ ```bash
79
+ pip install satcube
80
+ ```
81
+
82
+ ## **How to use** 🛠️
83
+
84
+ ### **Basic usage: working with sentinel-2 data** 🌍
85
+
86
+ #### **Load libraries**
87
+
88
+ ```python
89
+ import ee
90
+ import satcube
91
+ ```
92
+
93
+ #### **Authenticate and initialize earth engine**
94
+
95
+ ```python
96
+ ee.Authenticate()
97
+ ee.Initialize(project="ee-csaybar-real")
98
+ ```
99
+ #### **Download model weights**
100
+ ```python
101
+ outpath = satcube.download_weights(path="weights")
102
+ ```
103
+
104
+ #### **Create a satellite dataCube**
105
+ ```python
106
+ datacube = satcube.SatCube(
107
+ coordinates=(-77.68598590138802,-8.888223962022263),
108
+ sensor=satcube.Sentinel2(weight_path=outpath, edge_size=384),
109
+ output_dir="wendy01",
110
+ max_workers=12,
111
+ device="cuda",
112
+ )
113
+ ```
114
+
115
+
116
+ ### **Query and process sentinel-2 data** 🛰️
117
+
118
+ #### **Query the sentinel-2 image collection**
119
+
120
+ ```python
121
+ # Query the Sentinel-2 image collection
122
+ table_query = datacube.metadata_s2()
123
+
124
+ # Filter images based on cloud cover and remove duplicates
125
+ table_query_subset = table_query[table_query["cs_cdf"] > 0.30]
126
+ table_query_subset = table_query_subset.drop_duplicates(subset="img_date")
127
+ mgrs_tile_max = table_query_subset["mgrs_title"].value_counts().idxmax()
128
+ table_query_subset = table_query_subset[table_query_subset["mgrs_title"] == mgrs_tile_max]
129
+ ```
130
+
131
+ #### **Download sentinel-2 images**
132
+
133
+ ```python
134
+ table_download = datacube.download_s2_image(table_query_subset)
135
+ ```
136
+ #### **Cloud masking**
137
+
138
+ ```python
139
+ # Remove clouds from the images
140
+ table_nocloud = datacube.cloudmasking_s2(table_download)
141
+ table_nocloud = table_nocloud[table_nocloud["cloud_cover"] < 0.75]
142
+ table_nocloud.reset_index(drop=True, inplace=True)
143
+ ```
144
+
145
+ #### **Gap filling**
146
+
147
+ ```python
148
+ # Fill missing data in the images
149
+ table_nogaps = datacube.gapfilling_s2(table_nocloud)
150
+ table_nogaps = table_nogaps[table_nogaps["match_error"] < 0.1]
151
+ ```
152
+ ### **Monthly composites and image smoothing 📅**
153
+
154
+ #### **Create monthly composites**
155
+
156
+ ```python
157
+ # Generate monthly composites
158
+ table_composites = datacube.monthly_composites_s2(
159
+ table_nogaps, agg_method="median", date_range=("2016-01-01", "2024-07-31")
160
+ )
161
+ ```
162
+
163
+ #### **Interpolate missing data**
164
+
165
+ ```python
166
+ # Interpolate missing months if necessary
167
+ table_interpolate = datacube.interpolate_s2(table=table_composites)
168
+ ```
169
+
170
+ #### **Smooth reflectance values**
171
+
172
+ ```python
173
+ # Smooth reflectance values across time
174
+ table_smooth = datacube.smooth_s2(table=table_interpolate)
175
+ ```
176
+
177
+ ### **Super-resolution and visualization** 📐
178
+
179
+
180
+
181
+ #### **Super-resolution**
182
+
183
+ ```python
184
+ # Apply super-resolution to the image cube
185
+ # table_final = datacube.super_s2(table_smooth)
186
+ ```
187
+
188
+
189
+ #### **Display images**
190
+
191
+ ```python
192
+ # Display the images from the data cube
193
+ datacube.display_images(table=table_smooth)
194
+ ```
195
+
196
+ #### **Create a GIF**
197
+
198
+ ```python
199
+ # !apt-get install imagemagick
200
+ import os
201
+ os.system("convert -delay 20 -loop 0 wendy01/z_s2_07_smoothed_png/temp_07*.png animation.gif")
202
+
203
+ from IPython.display import Image
204
+ Image(filename='animation.gif', width=500)
205
+ ```
206
+
207
+ <p align="center">
208
+ <img src="https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/gif_satcube.gif" width="100%">
209
+ </p>
210
+
211
+ #### **Smooth reflectance values**
212
+
213
+ ```python
214
+ # Smooth reflectance values across time
215
+ table_smooth = datacube.smooth_s2(table=table_interpolate)
216
+ ```
217
+
218
+ ## **Supported features and filters** ✨
219
+
220
+ - **Cloud masking:** Efficient removal of clouds from satellite images.
221
+ - **Resampling methods:** Various methods for resampling and aligning imagery.
222
+ - **Super-resolution:** ONNX-based models for improving image resolution.
@@ -0,0 +1,193 @@
1
+ #
2
+
3
+ <p align="center">
4
+ <img src="https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/banner_satcube.png" width="33%">
5
+ </p>
6
+
7
+ <p align="center">
8
+ <em>A python package for managing Sentinel-2 satellite data cubes</em> 🚀
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href='https://pypi.python.org/pypi/satcube'>
13
+ <img src='https://img.shields.io/pypi/v/satcube.svg' alt='PyPI' />
14
+ </a>
15
+ <a href="https://opensource.org/licenses/MIT" target="_blank">
16
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License">
17
+ </a>
18
+ <a href="https://github.com/psf/black" target="_blank">
19
+ <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black">
20
+ </a>
21
+ <a href="https://pycqa.github.io/isort/" target="_blank">
22
+ <img src="https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336" alt="isort">
23
+ </a>
24
+ </p>
25
+
26
+ ---
27
+
28
+ **GitHub**: [https://github.com/IPL-UV/satcube](https://github.com/IPL-UV/satcube) 🌐
29
+
30
+ **PyPI**: [https://pypi.org/project/satcube/](https://pypi.org/project/satcube/) 🛠️
31
+
32
+ ---
33
+
34
+ ## **Overview** 📊
35
+
36
+ **satcube** is a Python package designed for efficient management, processing, and analysis of Sentinel-2 satellite image cubes. It allows for downloading, cloud masking, gap filling, and super-resolving Sentinel-2 imagery, as well as creating monthly composites and performing interpolation.
37
+
38
+ ## **Key Features** ✨
39
+ - **Satellite image download**: Retrieve Sentinel-2 images from Earth Engine efficiently. 🛰️
40
+ - **Cloud masking**: Automatically remove clouds from Sentinel-2 images. ☁️
41
+ - **Gap filling**: Fill missing data using methods like linear interpolation and histogram matching. 🧩
42
+ - **Super-resolution**: Apply super-resolution models to enhance image quality. 🔍
43
+ - **Monthly composites**: Aggregate images into monthly composites with various statistical methods. 📅
44
+ - **Temporal smoothing**: Smooth reflectance values across time using interpolation techniques. 📈
45
+ ## **Installation** ⚙️
46
+
47
+ Install the latest version from PyPI:
48
+
49
+ ```bash
50
+ pip install satcube
51
+ ```
52
+
53
+ ## **How to use** 🛠️
54
+
55
+ ### **Basic usage: working with sentinel-2 data** 🌍
56
+
57
+ #### **Load libraries**
58
+
59
+ ```python
60
+ import ee
61
+ import satcube
62
+ ```
63
+
64
+ #### **Authenticate and initialize earth engine**
65
+
66
+ ```python
67
+ ee.Authenticate()
68
+ ee.Initialize(project="ee-csaybar-real")
69
+ ```
70
+ #### **Download model weights**
71
+ ```python
72
+ outpath = satcube.download_weights(path="weights")
73
+ ```
74
+
75
+ #### **Create a satellite dataCube**
76
+ ```python
77
+ datacube = satcube.SatCube(
78
+ coordinates=(-77.68598590138802,-8.888223962022263),
79
+ sensor=satcube.Sentinel2(weight_path=outpath, edge_size=384),
80
+ output_dir="wendy01",
81
+ max_workers=12,
82
+ device="cuda",
83
+ )
84
+ ```
85
+
86
+
87
+ ### **Query and process sentinel-2 data** 🛰️
88
+
89
+ #### **Query the sentinel-2 image collection**
90
+
91
+ ```python
92
+ # Query the Sentinel-2 image collection
93
+ table_query = datacube.metadata_s2()
94
+
95
+ # Filter images based on cloud cover and remove duplicates
96
+ table_query_subset = table_query[table_query["cs_cdf"] > 0.30]
97
+ table_query_subset = table_query_subset.drop_duplicates(subset="img_date")
98
+ mgrs_tile_max = table_query_subset["mgrs_title"].value_counts().idxmax()
99
+ table_query_subset = table_query_subset[table_query_subset["mgrs_title"] == mgrs_tile_max]
100
+ ```
101
+
102
+ #### **Download sentinel-2 images**
103
+
104
+ ```python
105
+ table_download = datacube.download_s2_image(table_query_subset)
106
+ ```
107
+ #### **Cloud masking**
108
+
109
+ ```python
110
+ # Remove clouds from the images
111
+ table_nocloud = datacube.cloudmasking_s2(table_download)
112
+ table_nocloud = table_nocloud[table_nocloud["cloud_cover"] < 0.75]
113
+ table_nocloud.reset_index(drop=True, inplace=True)
114
+ ```
115
+
116
+ #### **Gap filling**
117
+
118
+ ```python
119
+ # Fill missing data in the images
120
+ table_nogaps = datacube.gapfilling_s2(table_nocloud)
121
+ table_nogaps = table_nogaps[table_nogaps["match_error"] < 0.1]
122
+ ```
123
+ ### **Monthly composites and image smoothing 📅**
124
+
125
+ #### **Create monthly composites**
126
+
127
+ ```python
128
+ # Generate monthly composites
129
+ table_composites = datacube.monthly_composites_s2(
130
+ table_nogaps, agg_method="median", date_range=("2016-01-01", "2024-07-31")
131
+ )
132
+ ```
133
+
134
+ #### **Interpolate missing data**
135
+
136
+ ```python
137
+ # Interpolate missing months if necessary
138
+ table_interpolate = datacube.interpolate_s2(table=table_composites)
139
+ ```
140
+
141
+ #### **Smooth reflectance values**
142
+
143
+ ```python
144
+ # Smooth reflectance values across time
145
+ table_smooth = datacube.smooth_s2(table=table_interpolate)
146
+ ```
147
+
148
+ ### **Super-resolution and visualization** 📐
149
+
150
+
151
+
152
+ #### **Super-resolution**
153
+
154
+ ```python
155
+ # Apply super-resolution to the image cube
156
+ # table_final = datacube.super_s2(table_smooth)
157
+ ```
158
+
159
+
160
+ #### **Display images**
161
+
162
+ ```python
163
+ # Display the images from the data cube
164
+ datacube.display_images(table=table_smooth)
165
+ ```
166
+
167
+ #### **Create a GIF**
168
+
169
+ ```python
170
+ # !apt-get install imagemagick
171
+ import os
172
+ os.system("convert -delay 20 -loop 0 wendy01/z_s2_07_smoothed_png/temp_07*.png animation.gif")
173
+
174
+ from IPython.display import Image
175
+ Image(filename='animation.gif', width=500)
176
+ ```
177
+
178
+ <p align="center">
179
+ <img src="https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/gif_satcube.gif" width="100%">
180
+ </p>
181
+
182
+ #### **Smooth reflectance values**
183
+
184
+ ```python
185
+ # Smooth reflectance values across time
186
+ table_smooth = datacube.smooth_s2(table=table_interpolate)
187
+ ```
188
+
189
+ ## **Supported features and filters** ✨
190
+
191
+ - **Cloud masking:** Efficient removal of clouds from satellite images.
192
+ - **Resampling methods:** Various methods for resampling and aligning imagery.
193
+ - **Super-resolution:** ONNX-based models for improving image resolution.
@@ -0,0 +1,65 @@
1
+ [tool.poetry]
2
+ name = "satcube"
3
+ version = "0.1.29"
4
+ description = "A Python package to create cloud-free monthly composites by fusing Landsat and Sentinel-2 data."
5
+ authors = ["Cesar Aybar <fcesar.aybar@uv.es>"]
6
+ repository = "https://github.com/IPL-UV/satcube"
7
+ documentation = "https://ipl-uv.github.io/satcube/"
8
+ readme = "README.md"
9
+ packages = [{ include = "satcube" }]
10
+
11
+ [tool.poetry.dependencies]
12
+ python = ">=3.9"
13
+ cubexpress = "0.1.25"
14
+ mlstac = ">=0.4.5"
15
+ satalign = "0.1.16"
16
+ segmentation-models-pytorch = ">=0.3.0"
17
+ phicloudmask = ">=0.0.2"
18
+ scikit-learn = ">=1.2.0"
19
+ requests = ">=2.26.0"
20
+ xarray = ">=2023.7.0"
21
+ tqdm = ">=4.67.1"
22
+ torch = ">=2.0.0"
23
+ sen2sr = ">=0.8.5"
24
+
25
+ [tool.poetry.extras]
26
+ full = ["torch"]
27
+
28
+ # --- tooling fixes ----------------------------------------------------------
29
+ [tool.mypy]
30
+ files = ["satcube"]
31
+ disallow_untyped_defs = true
32
+ disallow_any_unimported = true
33
+ no_implicit_optional = true
34
+ check_untyped_defs = true
35
+ warn_return_any = true
36
+ warn_unused_ignores = true
37
+ show_error_codes = true
38
+
39
+ [tool.ruff]
40
+ target-version = "py310"
41
+ line-length = 120
42
+ fix = true
43
+
44
+ [tool.ruff.lint]
45
+ select = ["YTT","S","B","A","C4","T10","SIM","I","C90","E","W","F","PGH","UP","RUF","TRY"]
46
+ ignore = [
47
+ "E501",
48
+ "E731",
49
+ "RUF002",
50
+ "SIM108",
51
+ "RUF059",
52
+ "TRY003",
53
+ "C901",
54
+ "TRY300",
55
+ "S112",
56
+ "S110",
57
+ "SIM101",
58
+ "S101",
59
+ "RUF003",
60
+ ]
61
+
62
+ [tool.ruff.lint.per-file-ignores]
63
+ "__init__.py" = ["F401", "E402"]
64
+ "_quiet.py" = ["E402"]
65
+ "utils.py" = ["S101"]
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+
3
+ import importlib as _importlib
4
+
5
+ _importlib.import_module("satcube._quiet")
6
+ from satcube.download import metadata # noqa: E402
7
+ from satcube.objects import SatCubeMetadata # noqa: E402
8
+
9
+ from_directory = SatCubeMetadata.from_directory
10
+
11
+ __all__ = ["SatCubeMetadata", "from_directory", "metadata"]
12
+
13
+ try:
14
+ from importlib.metadata import version
15
+
16
+ __version__ = version("satcube")
17
+ except Exception:
18
+ __version__ = "0.0.0-dev"