prisma-sat 0.1.0__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.
- prisma_sat-0.1.0/MANIFEST.in +10 -0
- prisma_sat-0.1.0/PKG-INFO +341 -0
- prisma_sat-0.1.0/README.md +311 -0
- prisma_sat-0.1.0/prisma_pilot/__init__.py +33 -0
- prisma_sat-0.1.0/prisma_pilot/auth.py +260 -0
- prisma_sat-0.1.0/prisma_pilot/cli.py +314 -0
- prisma_sat-0.1.0/prisma_pilot/config.py +63 -0
- prisma_sat-0.1.0/prisma_pilot/downloader.py +339 -0
- prisma_sat-0.1.0/prisma_pilot/search.py +373 -0
- prisma_sat-0.1.0/prisma_sat/__init__.py +42 -0
- prisma_sat-0.1.0/prisma_sat/cli.py +11 -0
- prisma_sat-0.1.0/prisma_sat.egg-info/PKG-INFO +341 -0
- prisma_sat-0.1.0/prisma_sat.egg-info/SOURCES.txt +18 -0
- prisma_sat-0.1.0/prisma_sat.egg-info/dependency_links.txt +1 -0
- prisma_sat-0.1.0/prisma_sat.egg-info/entry_points.txt +4 -0
- prisma_sat-0.1.0/prisma_sat.egg-info/requires.txt +10 -0
- prisma_sat-0.1.0/prisma_sat.egg-info/top_level.txt +2 -0
- prisma_sat-0.1.0/pyproject.toml +62 -0
- prisma_sat-0.1.0/sample_aoi.geojson +30 -0
- prisma_sat-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include pyproject.toml
|
|
3
|
+
include sample_aoi.geojson
|
|
4
|
+
recursive-include prisma_pilot *.py
|
|
5
|
+
recursive-include prisma_sat *.py
|
|
6
|
+
exclude .env*
|
|
7
|
+
recursive-exclude * .env*
|
|
8
|
+
recursive-exclude * __pycache__
|
|
9
|
+
recursive-exclude * *.py[co]
|
|
10
|
+
recursive-exclude tests *
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prisma-sat
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automated Python client and CLI to search, order, and download ASI PRISMA hyperspectral satellite data by AOI.
|
|
5
|
+
Author-email: Lokesh Shukla <lokesh.skshukla@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lokeshsk/prisma-sat
|
|
8
|
+
Project-URL: Repository, https://github.com/lokeshsk/prisma-sat
|
|
9
|
+
Project-URL: Issues, https://github.com/lokeshsk/prisma-sat/issues
|
|
10
|
+
Keywords: prisma,hyperspectral,satellite,earth-observation,remote-sensing,asi,geospatial
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: h5py>=3.8.0
|
|
22
|
+
Requires-Dist: numpy>=1.22.0
|
|
23
|
+
Requires-Dist: rasterio>=1.3.0
|
|
24
|
+
Requires-Dist: requests>=2.28.0
|
|
25
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
26
|
+
Requires-Dist: shapely>=2.0.0
|
|
27
|
+
Requires-Dist: websockets>=11.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
30
|
+
|
|
31
|
+
# prisma-sat: PRISMA Hyperspectral Data Acquisition Pipeline & CLI
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/prisma-sat/)
|
|
34
|
+
[](https://opensource.org/licenses/MIT)
|
|
35
|
+
[](https://www.python.org/downloads/)
|
|
36
|
+
|
|
37
|
+
An automated Python toolkit and CLI to search, order, and download Italian Space Agency (**ASI PRISMA**) hyperspectral satellite data for any Area of Interest (AOI) provided in **GeoJSON** or **Bounding Box (bbox)** format.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Quick Install
|
|
42
|
+
|
|
43
|
+
Install directly via `pip` or `uv`:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install prisma-sat
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This installs both the command-line utility `prisma-sat` and Python library imports (`import prisma_sat` / `import prisma_pilot`).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Table of Contents
|
|
54
|
+
|
|
55
|
+
1. [Understanding PRISMA vs. Sentinel Data Model](#1-understanding-prisma-vs-sentinel-data-model)
|
|
56
|
+
2. [Credentials Setup (.env)](#2-credentials-setup-env)
|
|
57
|
+
3. [CLI Quickstart & Workflow](#3-cli-quickstart--workflow)
|
|
58
|
+
- [Step 1: Check Completed Orders](#step-1-check-completed-orders)
|
|
59
|
+
- [Step 2: Search PRISMA Catalog by Bounding Box](#step-2-search-prisma-catalog-by-bounding-box)
|
|
60
|
+
- [Step 3: Search PRISMA Catalog by GeoJSON](#step-3-search-prisma-catalog-by-geojson)
|
|
61
|
+
- [Step 4: Search Using HTTP Protocol Fallback](#step-4-search-using-http-protocol-fallback)
|
|
62
|
+
- [Step 5: Submit a Processing Order for Raw Scenes](#step-5-submit-a-processing-order-for-raw-scenes)
|
|
63
|
+
- [Step 6: Download Completed Products](#step-6-download-completed-products)
|
|
64
|
+
4. [Complete CLI Command Reference](#4-complete-cli-command-reference)
|
|
65
|
+
5. [Python API / SDK Usage](#5-python-api--sdk-usage)
|
|
66
|
+
6. [Product Levels & HDF5 Data Cube Structure](#6-product-levels--hdf5-data-cube-structure)
|
|
67
|
+
7. [Publishing to PyPI](#7-publishing-to-pypi)
|
|
68
|
+
8. [Troubleshooting & FAQ](#8-troubleshooting--faq)
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 1. Understanding PRISMA vs. Sentinel Data Model
|
|
73
|
+
|
|
74
|
+
Unlike Sentinel-2 (which systematically pre-processes the globe and hosts instant-download GeoTIFFs), **PRISMA operates on an On-Demand Processing model**:
|
|
75
|
+
|
|
76
|
+
- **Catalog searches return Level 0 (`PRS_L0__EO`)**: The catalog indexes all raw satellite passes.
|
|
77
|
+
- **Processing is on-demand**: To get analysis-ready data (e.g., Level-2D geocoded surface reflectance), an order must be submitted to ASI's HPC processing cluster.
|
|
78
|
+
- **Turnaround time**: Processing takes between **20 to 45 minutes** depending on cluster load.
|
|
79
|
+
- **Direct download**: A product can only be downloaded immediately if it was already processed in your account history (or once a newly submitted order reaches `COMPLETED` status).
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 2. Credentials Setup (.env)
|
|
84
|
+
|
|
85
|
+
Set your PRISMA portal credentials in an environment file or environment variables:
|
|
86
|
+
|
|
87
|
+
```env
|
|
88
|
+
PRISMA_USER=your_username
|
|
89
|
+
PRISMA_PASS=your_password
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Locations automatically discovered by `prisma-sat`:
|
|
93
|
+
1. Current working directory: `./.env`
|
|
94
|
+
2. User config directory: `~/.config/prisma_sat/.env` (or `~/.prisma_sat/.env`)
|
|
95
|
+
3. Passed explicitly via CLI: `prisma-sat --env-file /path/to/.env ...`
|
|
96
|
+
4. Standard shell environment variables (`export PRISMA_USER="..."`)
|
|
97
|
+
|
|
98
|
+
On the first run, the tool uses headless Chrome via DevTools Protocol (CDP) to log in to the WSO2 Identity Server, approve OAuth consent, and cache the session cookies at `~/.cache/prisma_pilot/session.json`. Subsequent runs execute in **~2 seconds** without opening a browser.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 3. CLI Quickstart & Workflow
|
|
103
|
+
|
|
104
|
+
### Step 1: Check Completed Orders
|
|
105
|
+
|
|
106
|
+
Before requesting new processing, check if any scenes over your target area have already been processed and are ready for immediate download:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
prisma-sat orders
|
|
110
|
+
# or: python download_prisma.py orders
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Output:**
|
|
114
|
+
```
|
|
115
|
+
User Order History (8 total orders):
|
|
116
|
+
----------------------------------------------------------------------------------------
|
|
117
|
+
Order ID | Processor | Status | Acquisition Date | Production Date
|
|
118
|
+
----------------------------------------------------------------------------------------
|
|
119
|
+
extref_162267 | L2C | COMPLETED | 2025-10-06 06:02:00 | 2026-11-23 07:56:15
|
|
120
|
+
extref_162264 | L2C | COMPLETED | 2026-11-10 05:58:39 | 2026-11-23 04:49:50
|
|
121
|
+
extref_162010 | L2D | COMPLETED | 2026-09-07 05:55:28 | 2026-11-20 04:58:20
|
|
122
|
+
extref_162009 | L2D | COMPLETED | 2026-11-10 05:58:43 | 2026-11-20 04:57:29
|
|
123
|
+
extref_161673 | L1_A_EO | COMPLETED | 2026-01-30 06:02:12 | 2026-11-18 09:27:50
|
|
124
|
+
----------------------------------------------------------------------------------------
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### Step 2: Search PRISMA Catalog by Bounding Box
|
|
130
|
+
|
|
131
|
+
Search for scenes intersecting a bounding box `[min_lon, min_lat, max_lon, max_lat]` in WGS84:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
prisma-sat search \
|
|
135
|
+
--bbox 72.2 22.8 72.8 23.2 \
|
|
136
|
+
--max-cloud 20 \
|
|
137
|
+
--start-date 2021-01-01 \
|
|
138
|
+
--limit 5
|
|
139
|
+
```
|
|
140
|
+
--limit 10
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**With date filtering:**
|
|
144
|
+
```bash
|
|
145
|
+
./.venv/bin/python download_prisma.py search \
|
|
146
|
+
--bbox 72.2 22.8 72.8 23.2 \
|
|
147
|
+
--start-date 2023-01-01 \
|
|
148
|
+
--end-date 2026-12-31 \
|
|
149
|
+
--max-cloud 10
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### Step 3: Search PRISMA Catalog by GeoJSON
|
|
155
|
+
|
|
156
|
+
Search using a GeoJSON file containing a polygon or feature collection:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
./.venv/bin/python download_prisma.py search \
|
|
160
|
+
--geojson sample_aoi.geojson \
|
|
161
|
+
--max-cloud 15 \
|
|
162
|
+
--limit 10
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### Step 4: Search Using HTTP Protocol Fallback
|
|
168
|
+
|
|
169
|
+
To test using `http://` endpoints first (with automatic, seamless fallback to `https://` if the server demands TLS):
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
./.venv/bin/python download_prisma.py search \
|
|
173
|
+
--bbox 72.2 22.8 72.8 23.2 \
|
|
174
|
+
--http \
|
|
175
|
+
--max-cloud 20
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
*The script tries `http://` first, detects that PRISMA requires TLS for authenticated queries, preserves your session cookies, and completes over `https://`.*
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### Step 5: Submit a Processing Order for Raw Scenes
|
|
183
|
+
|
|
184
|
+
If a scene is not yet processed, trigger a processing order for Level 2D (orthorectified surface reflectance):
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
./.venv/bin/python download_prisma.py run \
|
|
188
|
+
--geojson sample_aoi.geojson \
|
|
189
|
+
--max-cloud 10 \
|
|
190
|
+
--processor L2D \
|
|
191
|
+
--order-if-needed
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Once submitted, monitor progress with `./.venv/bin/python download_prisma.py orders` until status is `COMPLETED` (~20–45 min).
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### Step 6: Download Completed Products
|
|
199
|
+
|
|
200
|
+
Download a product package by clean ID or direct URL:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Download by product ID and extract the HDF5 (.he5) data cube
|
|
204
|
+
./.venv/bin/python download_prisma.py download \
|
|
205
|
+
--id PRS_L1_STD_OFFL_20260130060212_20260130060216_0001 \
|
|
206
|
+
--output ./downloads
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Options:**
|
|
210
|
+
- `--output ./my_dir`: Custom download folder (defaults to `./downloads`).
|
|
211
|
+
- `--no-extract`: Keep only the `.zip` archive without unpacking `.he5`.
|
|
212
|
+
- `--http`: Attempt download over HTTP protocol first.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 5. Complete CLI Command Reference
|
|
217
|
+
|
|
218
|
+
### Synopsis
|
|
219
|
+
```text
|
|
220
|
+
download_prisma.py [-h] [--output OUTPUT] [--http] {search,orders,download,run} ...
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Commands
|
|
224
|
+
|
|
225
|
+
| Subcommand | Purpose | Key Arguments |
|
|
226
|
+
| :--- | :--- | :--- |
|
|
227
|
+
| `search` | Discover acquisitions intersecting AOI | `--bbox`, `--geojson`, `--max-cloud`, `--start-date`, `--end-date`, `--limit`, `--http` |
|
|
228
|
+
| `orders` | List account order history & status | `--http` |
|
|
229
|
+
| `download` | Download specific product file | `--id <id_or_url>`, `--output`, `--no-extract`, `--http` |
|
|
230
|
+
| `run` | Search AOI and download best match | `--bbox` / `--geojson`, `--download-first`, `--order-if-needed`, `--processor` |
|
|
231
|
+
|
|
232
|
+
### Parameter Details
|
|
233
|
+
|
|
234
|
+
- `--bbox MIN_LON MIN_LAT MAX_LON MAX_LAT`: Four coordinates in decimal degrees (WGS84).
|
|
235
|
+
- `--geojson PATH`: Path to a `.geojson` or `.json` file.
|
|
236
|
+
- `--max-cloud FLOAT`: Maximum cloud coverage percentage (e.g. `20` for $\le 20\%$).
|
|
237
|
+
- `--start-date YYYY-MM-DD`: Earliest acquisition timestamp.
|
|
238
|
+
- `--end-date YYYY-MM-DD`: Latest acquisition timestamp.
|
|
239
|
+
- `--limit INT`: Maximum number of acquisitions to display.
|
|
240
|
+
- `--processor {L1, L2B, L2C, L2D}`: Target processing level (default: `L2D`).
|
|
241
|
+
- `--http`: Attempt HTTP protocol first with intelligent HTTPS fallback.
|
|
242
|
+
- `--no-extract`: Disable automatic extraction of `.he5` files from downloaded `.zip`.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 6. Python API / SDK Usage
|
|
247
|
+
|
|
248
|
+
You can also import and use the pipeline directly in your Python code:
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
from prisma_pilot import parse_aoi, search_prisma, get_user_orders, download_product
|
|
252
|
+
|
|
253
|
+
# 1. Parse AOI from Bounding Box or GeoJSON
|
|
254
|
+
aoi = parse_aoi([72.2, 22.8, 72.8, 23.2])
|
|
255
|
+
# or: aoi = parse_aoi("sample_aoi.geojson")
|
|
256
|
+
|
|
257
|
+
# 2. Search PRISMA Catalog
|
|
258
|
+
scenes = search_prisma(
|
|
259
|
+
aoi=aoi,
|
|
260
|
+
max_cloud=15.0,
|
|
261
|
+
start_date="2022-01-01",
|
|
262
|
+
use_http=True # Tries HTTP first with automatic HTTPS fallback
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
print(f"Found {len(scenes)} matching acquisitions:")
|
|
266
|
+
for s in scenes[:5]:
|
|
267
|
+
print(f" {s['clean_id']} | Date: {s['start_time']} | Cloud: {s['cloud_cover']}%")
|
|
268
|
+
|
|
269
|
+
# 3. Check Order History
|
|
270
|
+
orders = get_user_orders()
|
|
271
|
+
for o in orders:
|
|
272
|
+
print(f" Order: {o['externalOrderId']} | Level: {o['processorName']} | Status: {o['status']}")
|
|
273
|
+
|
|
274
|
+
# 4. Download a Product
|
|
275
|
+
result = download_product(
|
|
276
|
+
product_id_or_url="PRS_L1_STD_OFFL_20260130060212_20260130060216_0001",
|
|
277
|
+
output_dir="./downloads",
|
|
278
|
+
extract=True # Automatically unpacks .he5
|
|
279
|
+
)
|
|
280
|
+
print("Downloaded:", result["zip_path"])
|
|
281
|
+
print("HDF5 Cube:", result["he5_path"])
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 7. Product Levels & HDF5 Data Cube Structure
|
|
287
|
+
|
|
288
|
+
### Processing Levels
|
|
289
|
+
|
|
290
|
+
- **`PRS_L0__EO`**: Raw satellite telemetry (stored in archive).
|
|
291
|
+
- **`L1_A_EO`**: Top-Of-Atmosphere (TOA) calibrated radiance.
|
|
292
|
+
- **`L2B`**: Ground surface reflectance and atmospheric parameters.
|
|
293
|
+
- **`L2C`**: Bottom-Of-Atmosphere (BOA) surface reflectance (standard geometry).
|
|
294
|
+
- **`L2D`**: Geocoded Bottom-Of-Atmosphere surface reflectance orthorectified with DEM (recommended).
|
|
295
|
+
|
|
296
|
+
### Structure of Extracted `.he5`
|
|
297
|
+
|
|
298
|
+
The extracted HDF-EOS5 file contains three co-registered cubes:
|
|
299
|
+
|
|
300
|
+
```text
|
|
301
|
+
HDFEOS/SWATHS/
|
|
302
|
+
├── PRS_L1_HRC (Panchromatic Camera)
|
|
303
|
+
│ └── 5-meter spatial resolution (6000 x 6000 pixels)
|
|
304
|
+
├── PRS_L1_HCO (Hyperspectral SWIR)
|
|
305
|
+
│ └── 173 spectral bands (943 nm to 2497 nm, 30m resolution)
|
|
306
|
+
└── PRS_L1_HCO (Hyperspectral VNIR)
|
|
307
|
+
└── 66 spectral bands (406 nm to 977 nm, 30m resolution)
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 8. Publishing to PyPI
|
|
313
|
+
|
|
314
|
+
To build and publish `prisma-sat` to PyPI:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
# 1. Build the distribution wheel and source tarball
|
|
318
|
+
uv build
|
|
319
|
+
|
|
320
|
+
# 2. Upload to PyPI (using an API token from pypi.org)
|
|
321
|
+
uv publish --token pypi-AgEIcHlwaS5vcmc...
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Or using `twine`:
|
|
325
|
+
```bash
|
|
326
|
+
pip install twine
|
|
327
|
+
twine upload dist/*
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## 9. Troubleshooting & FAQ
|
|
333
|
+
|
|
334
|
+
### Q: Why does the catalog return `PRS_L0__EO` instead of L2D?
|
|
335
|
+
> PRISMA archives data at Level 0. To get Level 1, 2C, or 2D, submit an order with `--order-if-needed --processor L2D`. Processing takes 20–45 minutes.
|
|
336
|
+
|
|
337
|
+
### Q: How long is the login session valid?
|
|
338
|
+
> Session tokens are cached in `~/.cache/prisma_pilot/session.json`. If expired, the tool automatically re-authenticates via headless Chrome CDP in the background.
|
|
339
|
+
|
|
340
|
+
### Q: What happens when using `--http`?
|
|
341
|
+
> The tool explicitly attempts `http://prisma.asi.it`. The ASI Apache server rejects unencrypted HTTP requests for authenticated endpoints with HTTP 401. The tool detects this, protects your session cookies from corruption, logs the fallback, and completes over HTTPS.
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# prisma-sat: PRISMA Hyperspectral Data Acquisition Pipeline & CLI
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/prisma-sat/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
|
|
7
|
+
An automated Python toolkit and CLI to search, order, and download Italian Space Agency (**ASI PRISMA**) hyperspectral satellite data for any Area of Interest (AOI) provided in **GeoJSON** or **Bounding Box (bbox)** format.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Quick Install
|
|
12
|
+
|
|
13
|
+
Install directly via `pip` or `uv`:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install prisma-sat
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This installs both the command-line utility `prisma-sat` and Python library imports (`import prisma_sat` / `import prisma_pilot`).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Table of Contents
|
|
24
|
+
|
|
25
|
+
1. [Understanding PRISMA vs. Sentinel Data Model](#1-understanding-prisma-vs-sentinel-data-model)
|
|
26
|
+
2. [Credentials Setup (.env)](#2-credentials-setup-env)
|
|
27
|
+
3. [CLI Quickstart & Workflow](#3-cli-quickstart--workflow)
|
|
28
|
+
- [Step 1: Check Completed Orders](#step-1-check-completed-orders)
|
|
29
|
+
- [Step 2: Search PRISMA Catalog by Bounding Box](#step-2-search-prisma-catalog-by-bounding-box)
|
|
30
|
+
- [Step 3: Search PRISMA Catalog by GeoJSON](#step-3-search-prisma-catalog-by-geojson)
|
|
31
|
+
- [Step 4: Search Using HTTP Protocol Fallback](#step-4-search-using-http-protocol-fallback)
|
|
32
|
+
- [Step 5: Submit a Processing Order for Raw Scenes](#step-5-submit-a-processing-order-for-raw-scenes)
|
|
33
|
+
- [Step 6: Download Completed Products](#step-6-download-completed-products)
|
|
34
|
+
4. [Complete CLI Command Reference](#4-complete-cli-command-reference)
|
|
35
|
+
5. [Python API / SDK Usage](#5-python-api--sdk-usage)
|
|
36
|
+
6. [Product Levels & HDF5 Data Cube Structure](#6-product-levels--hdf5-data-cube-structure)
|
|
37
|
+
7. [Publishing to PyPI](#7-publishing-to-pypi)
|
|
38
|
+
8. [Troubleshooting & FAQ](#8-troubleshooting--faq)
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 1. Understanding PRISMA vs. Sentinel Data Model
|
|
43
|
+
|
|
44
|
+
Unlike Sentinel-2 (which systematically pre-processes the globe and hosts instant-download GeoTIFFs), **PRISMA operates on an On-Demand Processing model**:
|
|
45
|
+
|
|
46
|
+
- **Catalog searches return Level 0 (`PRS_L0__EO`)**: The catalog indexes all raw satellite passes.
|
|
47
|
+
- **Processing is on-demand**: To get analysis-ready data (e.g., Level-2D geocoded surface reflectance), an order must be submitted to ASI's HPC processing cluster.
|
|
48
|
+
- **Turnaround time**: Processing takes between **20 to 45 minutes** depending on cluster load.
|
|
49
|
+
- **Direct download**: A product can only be downloaded immediately if it was already processed in your account history (or once a newly submitted order reaches `COMPLETED` status).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 2. Credentials Setup (.env)
|
|
54
|
+
|
|
55
|
+
Set your PRISMA portal credentials in an environment file or environment variables:
|
|
56
|
+
|
|
57
|
+
```env
|
|
58
|
+
PRISMA_USER=your_username
|
|
59
|
+
PRISMA_PASS=your_password
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Locations automatically discovered by `prisma-sat`:
|
|
63
|
+
1. Current working directory: `./.env`
|
|
64
|
+
2. User config directory: `~/.config/prisma_sat/.env` (or `~/.prisma_sat/.env`)
|
|
65
|
+
3. Passed explicitly via CLI: `prisma-sat --env-file /path/to/.env ...`
|
|
66
|
+
4. Standard shell environment variables (`export PRISMA_USER="..."`)
|
|
67
|
+
|
|
68
|
+
On the first run, the tool uses headless Chrome via DevTools Protocol (CDP) to log in to the WSO2 Identity Server, approve OAuth consent, and cache the session cookies at `~/.cache/prisma_pilot/session.json`. Subsequent runs execute in **~2 seconds** without opening a browser.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 3. CLI Quickstart & Workflow
|
|
73
|
+
|
|
74
|
+
### Step 1: Check Completed Orders
|
|
75
|
+
|
|
76
|
+
Before requesting new processing, check if any scenes over your target area have already been processed and are ready for immediate download:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
prisma-sat orders
|
|
80
|
+
# or: python download_prisma.py orders
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Output:**
|
|
84
|
+
```
|
|
85
|
+
User Order History (8 total orders):
|
|
86
|
+
----------------------------------------------------------------------------------------
|
|
87
|
+
Order ID | Processor | Status | Acquisition Date | Production Date
|
|
88
|
+
----------------------------------------------------------------------------------------
|
|
89
|
+
extref_162267 | L2C | COMPLETED | 2025-10-06 06:02:00 | 2026-11-23 07:56:15
|
|
90
|
+
extref_162264 | L2C | COMPLETED | 2026-11-10 05:58:39 | 2026-11-23 04:49:50
|
|
91
|
+
extref_162010 | L2D | COMPLETED | 2026-09-07 05:55:28 | 2026-11-20 04:58:20
|
|
92
|
+
extref_162009 | L2D | COMPLETED | 2026-11-10 05:58:43 | 2026-11-20 04:57:29
|
|
93
|
+
extref_161673 | L1_A_EO | COMPLETED | 2026-01-30 06:02:12 | 2026-11-18 09:27:50
|
|
94
|
+
----------------------------------------------------------------------------------------
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### Step 2: Search PRISMA Catalog by Bounding Box
|
|
100
|
+
|
|
101
|
+
Search for scenes intersecting a bounding box `[min_lon, min_lat, max_lon, max_lat]` in WGS84:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
prisma-sat search \
|
|
105
|
+
--bbox 72.2 22.8 72.8 23.2 \
|
|
106
|
+
--max-cloud 20 \
|
|
107
|
+
--start-date 2021-01-01 \
|
|
108
|
+
--limit 5
|
|
109
|
+
```
|
|
110
|
+
--limit 10
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**With date filtering:**
|
|
114
|
+
```bash
|
|
115
|
+
./.venv/bin/python download_prisma.py search \
|
|
116
|
+
--bbox 72.2 22.8 72.8 23.2 \
|
|
117
|
+
--start-date 2023-01-01 \
|
|
118
|
+
--end-date 2026-12-31 \
|
|
119
|
+
--max-cloud 10
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### Step 3: Search PRISMA Catalog by GeoJSON
|
|
125
|
+
|
|
126
|
+
Search using a GeoJSON file containing a polygon or feature collection:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
./.venv/bin/python download_prisma.py search \
|
|
130
|
+
--geojson sample_aoi.geojson \
|
|
131
|
+
--max-cloud 15 \
|
|
132
|
+
--limit 10
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### Step 4: Search Using HTTP Protocol Fallback
|
|
138
|
+
|
|
139
|
+
To test using `http://` endpoints first (with automatic, seamless fallback to `https://` if the server demands TLS):
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
./.venv/bin/python download_prisma.py search \
|
|
143
|
+
--bbox 72.2 22.8 72.8 23.2 \
|
|
144
|
+
--http \
|
|
145
|
+
--max-cloud 20
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
*The script tries `http://` first, detects that PRISMA requires TLS for authenticated queries, preserves your session cookies, and completes over `https://`.*
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### Step 5: Submit a Processing Order for Raw Scenes
|
|
153
|
+
|
|
154
|
+
If a scene is not yet processed, trigger a processing order for Level 2D (orthorectified surface reflectance):
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
./.venv/bin/python download_prisma.py run \
|
|
158
|
+
--geojson sample_aoi.geojson \
|
|
159
|
+
--max-cloud 10 \
|
|
160
|
+
--processor L2D \
|
|
161
|
+
--order-if-needed
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Once submitted, monitor progress with `./.venv/bin/python download_prisma.py orders` until status is `COMPLETED` (~20–45 min).
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### Step 6: Download Completed Products
|
|
169
|
+
|
|
170
|
+
Download a product package by clean ID or direct URL:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Download by product ID and extract the HDF5 (.he5) data cube
|
|
174
|
+
./.venv/bin/python download_prisma.py download \
|
|
175
|
+
--id PRS_L1_STD_OFFL_20260130060212_20260130060216_0001 \
|
|
176
|
+
--output ./downloads
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Options:**
|
|
180
|
+
- `--output ./my_dir`: Custom download folder (defaults to `./downloads`).
|
|
181
|
+
- `--no-extract`: Keep only the `.zip` archive without unpacking `.he5`.
|
|
182
|
+
- `--http`: Attempt download over HTTP protocol first.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 5. Complete CLI Command Reference
|
|
187
|
+
|
|
188
|
+
### Synopsis
|
|
189
|
+
```text
|
|
190
|
+
download_prisma.py [-h] [--output OUTPUT] [--http] {search,orders,download,run} ...
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Commands
|
|
194
|
+
|
|
195
|
+
| Subcommand | Purpose | Key Arguments |
|
|
196
|
+
| :--- | :--- | :--- |
|
|
197
|
+
| `search` | Discover acquisitions intersecting AOI | `--bbox`, `--geojson`, `--max-cloud`, `--start-date`, `--end-date`, `--limit`, `--http` |
|
|
198
|
+
| `orders` | List account order history & status | `--http` |
|
|
199
|
+
| `download` | Download specific product file | `--id <id_or_url>`, `--output`, `--no-extract`, `--http` |
|
|
200
|
+
| `run` | Search AOI and download best match | `--bbox` / `--geojson`, `--download-first`, `--order-if-needed`, `--processor` |
|
|
201
|
+
|
|
202
|
+
### Parameter Details
|
|
203
|
+
|
|
204
|
+
- `--bbox MIN_LON MIN_LAT MAX_LON MAX_LAT`: Four coordinates in decimal degrees (WGS84).
|
|
205
|
+
- `--geojson PATH`: Path to a `.geojson` or `.json` file.
|
|
206
|
+
- `--max-cloud FLOAT`: Maximum cloud coverage percentage (e.g. `20` for $\le 20\%$).
|
|
207
|
+
- `--start-date YYYY-MM-DD`: Earliest acquisition timestamp.
|
|
208
|
+
- `--end-date YYYY-MM-DD`: Latest acquisition timestamp.
|
|
209
|
+
- `--limit INT`: Maximum number of acquisitions to display.
|
|
210
|
+
- `--processor {L1, L2B, L2C, L2D}`: Target processing level (default: `L2D`).
|
|
211
|
+
- `--http`: Attempt HTTP protocol first with intelligent HTTPS fallback.
|
|
212
|
+
- `--no-extract`: Disable automatic extraction of `.he5` files from downloaded `.zip`.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 6. Python API / SDK Usage
|
|
217
|
+
|
|
218
|
+
You can also import and use the pipeline directly in your Python code:
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from prisma_pilot import parse_aoi, search_prisma, get_user_orders, download_product
|
|
222
|
+
|
|
223
|
+
# 1. Parse AOI from Bounding Box or GeoJSON
|
|
224
|
+
aoi = parse_aoi([72.2, 22.8, 72.8, 23.2])
|
|
225
|
+
# or: aoi = parse_aoi("sample_aoi.geojson")
|
|
226
|
+
|
|
227
|
+
# 2. Search PRISMA Catalog
|
|
228
|
+
scenes = search_prisma(
|
|
229
|
+
aoi=aoi,
|
|
230
|
+
max_cloud=15.0,
|
|
231
|
+
start_date="2022-01-01",
|
|
232
|
+
use_http=True # Tries HTTP first with automatic HTTPS fallback
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
print(f"Found {len(scenes)} matching acquisitions:")
|
|
236
|
+
for s in scenes[:5]:
|
|
237
|
+
print(f" {s['clean_id']} | Date: {s['start_time']} | Cloud: {s['cloud_cover']}%")
|
|
238
|
+
|
|
239
|
+
# 3. Check Order History
|
|
240
|
+
orders = get_user_orders()
|
|
241
|
+
for o in orders:
|
|
242
|
+
print(f" Order: {o['externalOrderId']} | Level: {o['processorName']} | Status: {o['status']}")
|
|
243
|
+
|
|
244
|
+
# 4. Download a Product
|
|
245
|
+
result = download_product(
|
|
246
|
+
product_id_or_url="PRS_L1_STD_OFFL_20260130060212_20260130060216_0001",
|
|
247
|
+
output_dir="./downloads",
|
|
248
|
+
extract=True # Automatically unpacks .he5
|
|
249
|
+
)
|
|
250
|
+
print("Downloaded:", result["zip_path"])
|
|
251
|
+
print("HDF5 Cube:", result["he5_path"])
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## 7. Product Levels & HDF5 Data Cube Structure
|
|
257
|
+
|
|
258
|
+
### Processing Levels
|
|
259
|
+
|
|
260
|
+
- **`PRS_L0__EO`**: Raw satellite telemetry (stored in archive).
|
|
261
|
+
- **`L1_A_EO`**: Top-Of-Atmosphere (TOA) calibrated radiance.
|
|
262
|
+
- **`L2B`**: Ground surface reflectance and atmospheric parameters.
|
|
263
|
+
- **`L2C`**: Bottom-Of-Atmosphere (BOA) surface reflectance (standard geometry).
|
|
264
|
+
- **`L2D`**: Geocoded Bottom-Of-Atmosphere surface reflectance orthorectified with DEM (recommended).
|
|
265
|
+
|
|
266
|
+
### Structure of Extracted `.he5`
|
|
267
|
+
|
|
268
|
+
The extracted HDF-EOS5 file contains three co-registered cubes:
|
|
269
|
+
|
|
270
|
+
```text
|
|
271
|
+
HDFEOS/SWATHS/
|
|
272
|
+
├── PRS_L1_HRC (Panchromatic Camera)
|
|
273
|
+
│ └── 5-meter spatial resolution (6000 x 6000 pixels)
|
|
274
|
+
├── PRS_L1_HCO (Hyperspectral SWIR)
|
|
275
|
+
│ └── 173 spectral bands (943 nm to 2497 nm, 30m resolution)
|
|
276
|
+
└── PRS_L1_HCO (Hyperspectral VNIR)
|
|
277
|
+
└── 66 spectral bands (406 nm to 977 nm, 30m resolution)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 8. Publishing to PyPI
|
|
283
|
+
|
|
284
|
+
To build and publish `prisma-sat` to PyPI:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# 1. Build the distribution wheel and source tarball
|
|
288
|
+
uv build
|
|
289
|
+
|
|
290
|
+
# 2. Upload to PyPI (using an API token from pypi.org)
|
|
291
|
+
uv publish --token pypi-AgEIcHlwaS5vcmc...
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Or using `twine`:
|
|
295
|
+
```bash
|
|
296
|
+
pip install twine
|
|
297
|
+
twine upload dist/*
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## 9. Troubleshooting & FAQ
|
|
303
|
+
|
|
304
|
+
### Q: Why does the catalog return `PRS_L0__EO` instead of L2D?
|
|
305
|
+
> PRISMA archives data at Level 0. To get Level 1, 2C, or 2D, submit an order with `--order-if-needed --processor L2D`. Processing takes 20–45 minutes.
|
|
306
|
+
|
|
307
|
+
### Q: How long is the login session valid?
|
|
308
|
+
> Session tokens are cached in `~/.cache/prisma_pilot/session.json`. If expired, the tool automatically re-authenticates via headless Chrome CDP in the background.
|
|
309
|
+
|
|
310
|
+
### Q: What happens when using `--http`?
|
|
311
|
+
> The tool explicitly attempts `http://prisma.asi.it`. The ASI Apache server rejects unencrypted HTTP requests for authenticated endpoints with HTTP 401. The tool detects this, protects your session cookies from corruption, logs the fallback, and completes over HTTPS.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
PRISMA Pilot Toolkit
|
|
3
|
+
====================
|
|
4
|
+
Standalone pilot for ASI PRISMA Hyperspectral Satellite data:
|
|
5
|
+
- Authentication & Session Management (WSO2 OAuth2 & Session Caching)
|
|
6
|
+
- Spatial AOI Parsing (GeoJSON files/dicts and Bounding Box arrays/strings)
|
|
7
|
+
- Solr Spatial Catalog Discovery
|
|
8
|
+
- Resilient streaming download pipeline with Range resumption and HDF5 extraction
|
|
9
|
+
- Processing order dispatch and order history tracking
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from prisma_pilot.config import config
|
|
13
|
+
from prisma_pilot.auth import get_authenticated_session, verify_session, ensure_authorized
|
|
14
|
+
from prisma_pilot.search import AOI, parse_aoi, search_prisma, get_user_orders
|
|
15
|
+
from prisma_pilot.downloader import download_product, download_stream, order_processing, validate_file_integrity, extract_prisma_archive
|
|
16
|
+
|
|
17
|
+
__version__ = "0.1.0"
|
|
18
|
+
__all__ = [
|
|
19
|
+
"config",
|
|
20
|
+
"get_authenticated_session",
|
|
21
|
+
"verify_session",
|
|
22
|
+
"ensure_authorized",
|
|
23
|
+
"AOI",
|
|
24
|
+
"parse_aoi",
|
|
25
|
+
"search_prisma",
|
|
26
|
+
"get_user_orders",
|
|
27
|
+
"download_product",
|
|
28
|
+
"download_stream",
|
|
29
|
+
"order_processing",
|
|
30
|
+
"validate_file_integrity",
|
|
31
|
+
"extract_prisma_archive",
|
|
32
|
+
]
|
|
33
|
+
|