-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Xarray sub-package #1013
Open
vincentsarago
wants to merge
5
commits into
main
Choose a base branch
from
feature/add-xarray-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,292
−3
Open
Add Xarray sub-package #1013
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
SUBPACKAGE_DIRS=( | ||
"core" | ||
"xarray" | ||
"mosaic" | ||
"application" | ||
"extensions" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## titiler.xarray | ||
|
||
Adds support for Xarray Dataset (NetCDF/Zarr) in Titiler. | ||
|
||
## Installation | ||
|
||
```bash | ||
$ python -m pip install -U pip | ||
|
||
# From Pypi | ||
$ python -m pip install titiler.xarray | ||
|
||
# Or from sources | ||
$ git clone https://github.com/developmentseed/titiler.git | ||
$ cd titiler && python -m pip install -e src/titiler/core -e src/titiler/xarray | ||
``` | ||
|
||
## How To | ||
|
||
```python | ||
from fastapi import FastAPI | ||
from titiler.xarray.factory import TilerFactory | ||
|
||
# Create a FastAPI application | ||
app = FastAPI( | ||
description="A lightweight Cloud Optimized GeoTIFF tile server", | ||
) | ||
|
||
# Create a set of MosaicJSON endpoints | ||
endpoint = TilerFactory() | ||
|
||
# Register the Mosaic endpoints to the application | ||
app.include_router(endpoint.router) | ||
``` | ||
|
||
## Package structure | ||
|
||
``` | ||
titiler/ | ||
└── xarray/ | ||
├── tests/ - Tests suite | ||
└── titiler/xarray/ - `xarray` namespace package | ||
├── dependencies.py - titiler-xarray dependencies | ||
├── io.py - titiler-xarray Readers | ||
└── factory.py - endpoints factory | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
[project] | ||
name = "titiler.xarray" | ||
description = "Xarray plugin for TiTiler." | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
authors = [ | ||
{name = "Vincent Sarago", email = "[email protected]"}, | ||
{name = "Aimee Barciauskas", email = "[email protected]"}, | ||
] | ||
license = {text = "MIT"} | ||
keywords = [ | ||
"TiTiler", | ||
"Xarray", | ||
"Zarr", | ||
"NetCDF", | ||
"HDF", | ||
] | ||
classifiers = [ | ||
"Intended Audience :: Information Technology", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Topic :: Scientific/Engineering :: GIS", | ||
] | ||
dynamic = ["version"] | ||
dependencies = [ | ||
"titiler.core==0.19.0.dev", | ||
"cftime", | ||
"h5netcdf", | ||
"xarray", | ||
"rioxarray", | ||
"zarr", | ||
"fsspec", | ||
"s3fs", | ||
"aiohttp", | ||
"pandas", | ||
"httpx", | ||
] | ||
|
||
[project.optional-dependencies] | ||
test = [ | ||
"pytest", | ||
"pytest-cov", | ||
"pytest-asyncio", | ||
"httpx", | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://developmentseed.org/titiler/" | ||
Documentation = "https://developmentseed.org/titiler/" | ||
Issues = "https://github.com/developmentseed/titiler/issues" | ||
Source = "https://github.com/developmentseed/titiler" | ||
Changelog = "https://developmentseed.org/titiler/release-notes/" | ||
|
||
[build-system] | ||
requires = ["pdm-pep517"] | ||
build-backend = "pdm.pep517.api" | ||
|
||
[tool.pdm.version] | ||
source = "file" | ||
path = "titiler/xarray/__init__.py" | ||
|
||
[tool.pdm.build] | ||
includes = ["titiler/xarray"] | ||
excludes = ["tests/", "**/.mypy_cache", "**/.DS_Store"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""titiler.xarray test configuration.""" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"zarr_format": 2 | ||
} |
119 changes: 119 additions & 0 deletions
119
src/titiler/xarray/tests/fixtures/dataset_3d.zarr/.zmetadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{ | ||
"metadata": { | ||
".zattrs": {}, | ||
".zgroup": { | ||
"zarr_format": 2 | ||
}, | ||
"dataset/.zarray": { | ||
"chunks": [ | ||
1, | ||
250, | ||
500 | ||
], | ||
"compressor": { | ||
"blocksize": 0, | ||
"clevel": 5, | ||
"cname": "lz4", | ||
"id": "blosc", | ||
"shuffle": 1 | ||
}, | ||
"dtype": "<f8", | ||
"fill_value": "NaN", | ||
"filters": null, | ||
"order": "C", | ||
"shape": [ | ||
2, | ||
1000, | ||
2000 | ||
], | ||
"zarr_format": 2 | ||
}, | ||
"dataset/.zattrs": { | ||
"_ARRAY_DIMENSIONS": [ | ||
"time", | ||
"y", | ||
"x" | ||
], | ||
"valid_max": 1000.0, | ||
"valid_min": 0.0 | ||
}, | ||
"time/.zarray": { | ||
"chunks": [ | ||
2 | ||
], | ||
"compressor": { | ||
"blocksize": 0, | ||
"clevel": 5, | ||
"cname": "lz4", | ||
"id": "blosc", | ||
"shuffle": 1 | ||
}, | ||
"dtype": "<i8", | ||
"fill_value": null, | ||
"filters": null, | ||
"order": "C", | ||
"shape": [ | ||
2 | ||
], | ||
"zarr_format": 2 | ||
}, | ||
"time/.zattrs": { | ||
"_ARRAY_DIMENSIONS": [ | ||
"time" | ||
], | ||
"calendar": "proleptic_gregorian", | ||
"units": "days since 2022-01-01 00:00:00" | ||
}, | ||
"x/.zarray": { | ||
"chunks": [ | ||
2000 | ||
], | ||
"compressor": { | ||
"blocksize": 0, | ||
"clevel": 5, | ||
"cname": "lz4", | ||
"id": "blosc", | ||
"shuffle": 1 | ||
}, | ||
"dtype": "<f8", | ||
"fill_value": "NaN", | ||
"filters": null, | ||
"order": "C", | ||
"shape": [ | ||
2000 | ||
], | ||
"zarr_format": 2 | ||
}, | ||
"x/.zattrs": { | ||
"_ARRAY_DIMENSIONS": [ | ||
"x" | ||
] | ||
}, | ||
"y/.zarray": { | ||
"chunks": [ | ||
1000 | ||
], | ||
"compressor": { | ||
"blocksize": 0, | ||
"clevel": 5, | ||
"cname": "lz4", | ||
"id": "blosc", | ||
"shuffle": 1 | ||
}, | ||
"dtype": "<f8", | ||
"fill_value": "NaN", | ||
"filters": null, | ||
"order": "C", | ||
"shape": [ | ||
1000 | ||
], | ||
"zarr_format": 2 | ||
}, | ||
"y/.zattrs": { | ||
"_ARRAY_DIMENSIONS": [ | ||
"y" | ||
] | ||
} | ||
}, | ||
"zarr_consolidated_format": 1 | ||
} |
24 changes: 24 additions & 0 deletions
24
src/titiler/xarray/tests/fixtures/dataset_3d.zarr/dataset/.zarray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"chunks": [ | ||
1, | ||
250, | ||
500 | ||
], | ||
"compressor": { | ||
"blocksize": 0, | ||
"clevel": 5, | ||
"cname": "lz4", | ||
"id": "blosc", | ||
"shuffle": 1 | ||
}, | ||
"dtype": "<f8", | ||
"fill_value": "NaN", | ||
"filters": null, | ||
"order": "C", | ||
"shape": [ | ||
2, | ||
1000, | ||
2000 | ||
], | ||
"zarr_format": 2 | ||
} |
9 changes: 9 additions & 0 deletions
9
src/titiler/xarray/tests/fixtures/dataset_3d.zarr/dataset/.zattrs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"_ARRAY_DIMENSIONS": [ | ||
"time", | ||
"y", | ||
"x" | ||
], | ||
"valid_max": 1000.0, | ||
"valid_min": 0.0 | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
src/titiler/xarray/tests/fixtures/dataset_3d.zarr/time/.zarray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"chunks": [ | ||
2 | ||
], | ||
"compressor": { | ||
"blocksize": 0, | ||
"clevel": 5, | ||
"cname": "lz4", | ||
"id": "blosc", | ||
"shuffle": 1 | ||
}, | ||
"dtype": "<i8", | ||
"fill_value": null, | ||
"filters": null, | ||
"order": "C", | ||
"shape": [ | ||
2 | ||
], | ||
"zarr_format": 2 | ||
} |
7 changes: 7 additions & 0 deletions
7
src/titiler/xarray/tests/fixtures/dataset_3d.zarr/time/.zattrs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"_ARRAY_DIMENSIONS": [ | ||
"time" | ||
], | ||
"calendar": "proleptic_gregorian", | ||
"units": "days since 2022-01-01 00:00:00" | ||
} |
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: update rio-tiler to >=7.1