API Reference¶
Download¶
pixelverse.download.sentinel1
¶
Retrieve and process Sentinel-1 Ground Range Detected (GRD) data.
get_s1_monthly_time_series
¶
get_s1_monthly_time_series(
bbox: tuple[
int | float, int | float, int | float, int | float
],
year: int,
stac_host: str = "https://planetarycomputer.microsoft.com/api/stac/v1",
) -> xarray.Dataset
Fetch Sentinel-1 imagery for a bounding box and return average monthly values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
tuple[float]
|
Bounding box coordinates (min_lon, min_lat, max_lon, max_lat). |
required |
year
|
int
|
Year for which to fetch the imagery. |
required |
stac_host
|
str
|
STAC host URL. Defaults to Microsoft Planetary Computer. |
'https://planetarycomputer.microsoft.com/api/stac/v1'
|
Returns:
| Type | Description |
|---|---|
xarray.Dataset
|
An xarray Dataset containing a time series of Sentinel-1, with the lowest cloud cover image per month selected. |
Source code in src/pixelverse/download/sentinel1.py
linear_to_decibel
¶
Transform VV or VH values from linear to decibel scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataarray
|
xarray.DataArray
|
Input DataArray with VV or VH values in linear scale. |
required |
Returns:
| Type | Description |
|---|---|
xarray.DataArray
|
DataArray with values converted to decibel scale using 10 * log_10(x). |
Source code in src/pixelverse/download/sentinel1.py
process_s1_dataset
¶
Process the Sentinel-1 xarray.Dataset by converting VV and VH bands from linear to decibel scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dset
|
xarray.Dataset
|
Input xarray Dataset containing 'vv' and 'vh' bands. |
required |
Returns:
| Type | Description |
|---|---|
xarray.Dataset
|
Processed xarray Dataset with 'vv_processed' and 'vh_processed' bands. |
Source code in src/pixelverse/download/sentinel1.py
pixelverse.download.sentinel2
¶
Retrieve and process Sentinel-2 Collection 1 Level 2A multispectral data.
fill_missing_months_and_format
¶
Fill missing months in the time series by forward filling previous data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dset
|
xarray.Dataset
|
Input xarray Dataset with a time dimension representing months.
Expected to be the output of |
required |
Returns:
| Type | Description |
|---|---|
xarray.Dataset
|
An xarray Dataset wit day of year data variable added and missing months filled. |
Source code in src/pixelverse/download/sentinel2.py
get_s2_time_series
¶
get_s2_time_series(
bbox: tuple[
int | float, int | float, int | float, int | float
],
year: int,
stac_host: str = "https://earth-search.aws.element84.com/v1",
cloudcover_max: int = 20,
) -> xarray.Dataset
Fetch Sentinel-2 imagery for a bounding box for each month of a specified year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
tuple[float]
|
Bounding box coordinates (min_lon, min_lat, max_lon, max_lat). |
required |
year
|
int
|
Year for which to fetch the imagery. |
required |
stac_host
|
str
|
STAC host URL. Defaults to Earth Search AWS. |
'https://earth-search.aws.element84.com/v1'
|
cloudcover_max
|
int
|
Maximum cloud cover percentage for filtering images. Defaults to 50. |
20
|
Returns:
| Type | Description |
|---|---|
xarray.Dataset
|
An xarray Dataset containing a time series of Sentinel-2, with the lowest cloud cover image per month selected. |
Source code in src/pixelverse/download/sentinel2.py
Embedding creation¶
pixelverse.generate_embeddings
¶
Embeddings generation and quantization functions.
generate_embeddings
¶
generate_embeddings(
s2_dset: xarray.Dataset,
model_name: str = "tessera_s2_encoder",
) -> xarray.Dataset
Generate embeddings for a given Sentinel-2 dataset using the specified model.
Note: MPV function designed to work with small areas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s2_dset
|
xarray.Dataset
|
Sentinel-2 dataset containing spectral bands and temporal information. |
required |
model_name
|
str
|
Name of the model to use for generating embeddings. Default is "tessera_s2_encoder". |
'tessera_s2_encoder'
|
Returns:
| Type | Description |
|---|---|
xarray.Dataset
|
Dataset containing generated embeddings with spatial coordinates and CRS information. |
Source code in src/pixelverse/generate_embeddings.py
quantize_embeddings
¶
Quantize embeddings from float32 to int8 to save space (4x compression).
Normalizes each feature independently to the int8 range [-128, 127]. The quantized embeddings can be used directly for similarity comparisons and other operations without dequantization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
embeddings
|
xarray.DataArray
|
Float32 embeddings with shape (feature, y, x) |
required |
Returns:
| Type | Description |
|---|---|
xarray.Dataset
|
Dataset containing quantized int8 embeddings with 'embedding' variable and spatial coordinates preserved |