Pydantic models for OGC Environmental Data (EDR) API
Project description
OGC Environmental Data Retrieval (EDR) API Pydantic
This repository contains the edr-pydantic Python package. It provides Pydantic models for the OGC Environmental Data Retrieval (EDR) API. This can, for example, be used to help develop an EDR API using FastAPI.
Install
pip install edr-pydantic
Or to install from source:
pip install git+https://github.com/KNMI/edr-pydantic.git
Usage
from edr_pydantic.collections import Collection
from edr_pydantic.data_queries import EDRQuery, EDRQueryLink
from edr_pydantic.extent import Extent, Spatial
from edr_pydantic.link import Link
from edr_pydantic.observed_property import ObservedProperty
from edr_pydantic.parameter import Parameter
from edr_pydantic.unit import Unit
from edr_pydantic.variables import Variables
c = Collection(
id="hrly_obs",
title="Hourly Site Specific observations",
description="Observation data for UK observing sites",
extent=Extent(
spatial=Spatial(
bbox=[
[-15.0, 48.0, 5.0, 62.0]
],
crs="WGS84"
)
),
links=[
Link(
href="https://example.org/uk-hourly-site-specific-observations",
rel="service-doc"
)
],
data_queries={
'position': EDRQuery(
link=EDRQueryLink(
href="https://example.org/edr/collections/hrly_obs/position?coords={coords}",
rel="data",
variables=Variables(
query_type="position",
output_formats=[
"CoverageJSON"
]
)
)
)
},
parameter_names={
"Wind Direction": Parameter(
unit=Unit(
label="degree true"
),
observedProperty=ObservedProperty(
id="https://codes.wmo.int/common/quantity-kind/_windDirection",
label="Wind Direction"
)
)
}
)
print(c.model_dump_json(indent=2, exclude_none=True))
Will print
{
"id": "hrly_obs",
"title": "Hourly Site Specific observations",
"description": "Observation data for UK observing sites",
"links": [
{
"href": "https://example.org/uk-hourly-site-specific-observations",
"rel": "service-doc"
}
],
"extent": {
"spatial": {
"bbox": [
[
-15.0,
48.0,
5.0,
62.0
]
],
"crs": "WGS84"
}
},
"data_queries": {
"position": {
"link": {
"href": "https://example.org/edr/collections/hrly_obs/position?coords={coords}",
"rel": "data",
"variables": {
"query_type": "position",
"output_formats": [
"CoverageJSON"
]
}
}
}
},
"parameter_names": {
"Wind Direction": {
"type": "Parameter",
"unit": {
"label": "degree true"
},
"observedProperty": {
"id": "https://codes.wmo.int/common/quantity-kind/_windDirection",
"label": "Wind Direction"
}
}
}
}
Contributing
Make an editable install from within the repository root
pip install -e '.[test]'
Running tests
pytest tests/
Real world usage
This library is used to build an Environmental Data Retrieval (EDR) API, serving observation data from surface weather data station data from the KNMI. See the KNMI Data Platform.
TODOs
Help is wanted in the following areas to fully implement the EDR spec:
- See TODOs in code listing various small inconsistencies in the spec
- In various places there could be more validation on content
License
Apache License, Version 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file edr_pydantic-0.1.1.tar.gz.
File metadata
- Download URL: edr_pydantic-0.1.1.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc5d41e000798ab66cd33fa622db77a04267eaf61c42b92b736743003fc138bc
|
|
| MD5 |
9a9949e93f7ff4bff6b1db692b3dacaa
|
|
| BLAKE2b-256 |
4b374f5e7d5d1c013f6016c3b752a6b706d863e1833d04322620227f22b4ad2d
|
File details
Details for the file edr_pydantic-0.1.1-py3-none-any.whl.
File metadata
- Download URL: edr_pydantic-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a9f0e2179f8c37f0bd637e5b4c2d8f2e61b55e3590710771a90ee0e6526f3b9
|
|
| MD5 |
055687d13fbcf5f6df6a28673e521e3c
|
|
| BLAKE2b-256 |
f7e0988cb681e710bbc132b3687f722979771855ba52b5a395ec479fd4945b02
|