Name | covjson-pydantic JSON |
Version |
0.5.0
JSON |
| download |
home_page | None |
Summary | The Pydantic models for CoverageJSON |
upload_time | 2024-11-22 10:30:07 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
covjson
pydantic
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# CoverageJSON Pydantic
<p>
<a href="https://github.com/knmi/covjson-pydantic/actions?query=workflow%3ACI" target="_blank">
<img src="https://github.com/knmi/covjson-pydantic/workflows/CI/badge.svg" alt="Test">
</a>
<a href="https://codecov.io/gh/knmi/covjson-pydantic" target="_blank">
<img src="https://codecov.io/gh/knmi/covjson-pydantic/branch/master/graph/badge.svg" alt="Coverage">
</a>
<a href="https://pypi.org/project/covjson-pydantic" target="_blank">
<img src="https://img.shields.io/pypi/v/covjson-pydantic?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://pypistats.org/packages/covjson-pydantic" target="_blank">
<img src="https://img.shields.io/pypi/dm/covjson-pydantic.svg" alt="Downloads">
</a>
<a href="https://github.com/knmi/covjson-pydantic/blob/master/LICENSE" target="_blank">
<img src="https://img.shields.io/github/license/knmi/covjson-pydantic.svg" alt="License">
</a>
</p>
This repository contains the coveragejson-pydantic Python package. It provides [Pydantic](https://pydantic-docs.helpmanual.io/) models for [CoverageJSON](https://covjson.org/). This can, for example, be used to develop an API using FastAPI serving or receiving CoverageJSON.
## Install
```shell
pip install covjson-pydantic
```
Or you can install directly from source:
```shell
pip install git+https://github.com/KNMI/covjson-pydantic.git
```
## Usage
```python
from datetime import datetime, timezone
from pydantic import AwareDatetime
from covjson_pydantic.coverage import Coverage
from covjson_pydantic.domain import Domain, Axes, ValuesAxis, DomainType
from covjson_pydantic.ndarray import NdArrayFloat
c = Coverage(
domain=Domain(
domainType=DomainType.point_series,
axes=Axes(
x=ValuesAxis[float](values=[1.23]),
y=ValuesAxis[float](values=[4.56]),
t=ValuesAxis[AwareDatetime](values=[datetime(2024, 8, 1, tzinfo=timezone.utc)]),
),
),
ranges={
"temperature": NdArrayFloat(axisNames=["x", "y", "t"], shape=[1, 1, 1], values=[42.0])
}
)
print(c.model_dump_json(exclude_none=True, indent=4))
```
Will print
```json
{
"type": "Coverage",
"domain": {
"type": "Domain",
"domainType": "PointSeries",
"axes": {
"x": {
"values": [
1.23
]
},
"y": {
"values": [
4.56
]
},
"t": {
"values": [
"2024-08-01T00:00:00Z"
]
}
}
},
"ranges": {
"temperature": {
"type": "NdArray",
"dataType": "float",
"axisNames": [
"x",
"y",
"t"
],
"shape": [
1,
1,
1
],
"values": [
42.0
]
}
}
}
```
## Contributing
Make an editable installation from within the repository root
```shell
pip install -e '.[test]'
```
### Running tests
```shell
pytest tests/
```
### Linting and typing
Linting and typing (mypy) is done using [pre-commit](https://pre-commit.com) hooks.
```shell
pip install pre-commit
pre-commit install
pre-commit run
```
## Related packages
* [edr-pydantic](https://github.com/KNMI/edr-pydantic) - Pydantic data models for the Environmental Data Retrieval (EDR) API
* [geojson-pydantic](https://github.com/developmentseed/geojson-pydantic) - Pydantic data models for the GeoJSON spec
## Real world usage
This library is used to build an OGC Environmental Data Retrieval (EDR) API, serving automatic weather data station data from The Royal Netherlands Meteorological Institute (KNMI). See the [KNMI Data Platform EDR API](https://developer.dataplatform.knmi.nl/edr-api).
## TODOs
Help is wanted in the following areas to fully implement the CovJSON spec:
* The polygon based domain types are not supported.
* The `Section` domain type is not supported.
* Not all requirements in the spec relating different fields are implemented.
## License
Apache License, Version 2.0
Raw data
{
"_id": null,
"home_page": null,
"name": "covjson-pydantic",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "covjson, Pydantic",
"author": null,
"author_email": "KNMI Data Platform Team <opendata@knmi.nl>",
"download_url": "https://files.pythonhosted.org/packages/96/b5/8d96bc1ef9dc835b99c11c98d9203761dfbb7aac9dc8600e27204ecca4b5/covjson_pydantic-0.5.0.tar.gz",
"platform": null,
"description": "# CoverageJSON Pydantic\n\n<p>\n <a href=\"https://github.com/knmi/covjson-pydantic/actions?query=workflow%3ACI\" target=\"_blank\">\n <img src=\"https://github.com/knmi/covjson-pydantic/workflows/CI/badge.svg\" alt=\"Test\">\n </a>\n <a href=\"https://codecov.io/gh/knmi/covjson-pydantic\" target=\"_blank\">\n <img src=\"https://codecov.io/gh/knmi/covjson-pydantic/branch/master/graph/badge.svg\" alt=\"Coverage\">\n </a>\n <a href=\"https://pypi.org/project/covjson-pydantic\" target=\"_blank\">\n <img src=\"https://img.shields.io/pypi/v/covjson-pydantic?color=%2334D058&label=pypi%20package\" alt=\"Package version\">\n </a>\n <a href=\"https://pypistats.org/packages/covjson-pydantic\" target=\"_blank\">\n <img src=\"https://img.shields.io/pypi/dm/covjson-pydantic.svg\" alt=\"Downloads\">\n </a>\n <a href=\"https://github.com/knmi/covjson-pydantic/blob/master/LICENSE\" target=\"_blank\">\n <img src=\"https://img.shields.io/github/license/knmi/covjson-pydantic.svg\" alt=\"License\">\n </a>\n</p>\n\n\nThis repository contains the coveragejson-pydantic Python package. It provides [Pydantic](https://pydantic-docs.helpmanual.io/) models for [CoverageJSON](https://covjson.org/). This can, for example, be used to develop an API using FastAPI serving or receiving CoverageJSON.\n\n## Install\n```shell\npip install covjson-pydantic\n```\n\nOr you can install directly from source:\n\n```shell\npip install git+https://github.com/KNMI/covjson-pydantic.git\n```\n\n## Usage\n\n```python\nfrom datetime import datetime, timezone\nfrom pydantic import AwareDatetime\nfrom covjson_pydantic.coverage import Coverage\nfrom covjson_pydantic.domain import Domain, Axes, ValuesAxis, DomainType\nfrom covjson_pydantic.ndarray import NdArrayFloat\n\nc = Coverage(\n domain=Domain(\n domainType=DomainType.point_series,\n axes=Axes(\n x=ValuesAxis[float](values=[1.23]),\n y=ValuesAxis[float](values=[4.56]),\n t=ValuesAxis[AwareDatetime](values=[datetime(2024, 8, 1, tzinfo=timezone.utc)]),\n ),\n ),\n ranges={\n \"temperature\": NdArrayFloat(axisNames=[\"x\", \"y\", \"t\"], shape=[1, 1, 1], values=[42.0])\n }\n)\n\nprint(c.model_dump_json(exclude_none=True, indent=4))\n```\nWill print\n```json\n{\n \"type\": \"Coverage\",\n \"domain\": {\n \"type\": \"Domain\",\n \"domainType\": \"PointSeries\",\n \"axes\": {\n \"x\": {\n \"values\": [\n 1.23\n ]\n },\n \"y\": {\n \"values\": [\n 4.56\n ]\n },\n \"t\": {\n \"values\": [\n \"2024-08-01T00:00:00Z\"\n ]\n }\n }\n },\n \"ranges\": {\n \"temperature\": {\n \"type\": \"NdArray\",\n \"dataType\": \"float\",\n \"axisNames\": [\n \"x\",\n \"y\",\n \"t\"\n ],\n \"shape\": [\n 1,\n 1,\n 1\n ],\n \"values\": [\n 42.0\n ]\n }\n }\n}\n```\n\n## Contributing\n\nMake an editable installation from within the repository root\n\n```shell\npip install -e '.[test]'\n```\n\n### Running tests\n\n```shell\npytest tests/\n```\n\n### Linting and typing\n\nLinting and typing (mypy) is done using [pre-commit](https://pre-commit.com) hooks.\n\n```shell\npip install pre-commit\npre-commit install\npre-commit run\n```\n\n## Related packages\n\n* [edr-pydantic](https://github.com/KNMI/edr-pydantic) - Pydantic data models for the Environmental Data Retrieval (EDR) API\n* [geojson-pydantic](https://github.com/developmentseed/geojson-pydantic) - Pydantic data models for the GeoJSON spec\n\n## Real world usage\n\nThis library is used to build an OGC Environmental Data Retrieval (EDR) API, serving automatic weather data station data from The Royal Netherlands Meteorological Institute (KNMI). See the [KNMI Data Platform EDR API](https://developer.dataplatform.knmi.nl/edr-api).\n\n## TODOs\nHelp is wanted in the following areas to fully implement the CovJSON spec:\n* The polygon based domain types are not supported.\n* The `Section` domain type is not supported.\n* Not all requirements in the spec relating different fields are implemented.\n\n## License\n\nApache License, Version 2.0\n",
"bugtrack_url": null,
"license": null,
"summary": "The Pydantic models for CoverageJSON",
"version": "0.5.0",
"project_urls": {
"Source": "https://github.com/knmi/covjson-pydantic"
},
"split_keywords": [
"covjson",
" pydantic"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6f46900c01abffed3e94a0311bf961413da254a2c8b254fff1f34e8bd3cdf014",
"md5": "bf24c74da8cd7ec3f8bfc64da2c2575a",
"sha256": "5330e218f86aaef1c1aa372c7a88376d5b9464a6617239d8cb31bb2c1fcad20d"
},
"downloads": -1,
"filename": "covjson_pydantic-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bf24c74da8cd7ec3f8bfc64da2c2575a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 13904,
"upload_time": "2024-11-22T10:30:06",
"upload_time_iso_8601": "2024-11-22T10:30:06.773196Z",
"url": "https://files.pythonhosted.org/packages/6f/46/900c01abffed3e94a0311bf961413da254a2c8b254fff1f34e8bd3cdf014/covjson_pydantic-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "96b58d96bc1ef9dc835b99c11c98d9203761dfbb7aac9dc8600e27204ecca4b5",
"md5": "47c5683f3630f039cc7a9d22a331b8f1",
"sha256": "18f5b57b63525d9c06bce50bc8bf47bc6503693a2bf72e8efae33606690c3a16"
},
"downloads": -1,
"filename": "covjson_pydantic-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "47c5683f3630f039cc7a9d22a331b8f1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 20030,
"upload_time": "2024-11-22T10:30:07",
"upload_time_iso_8601": "2024-11-22T10:30:07.765540Z",
"url": "https://files.pythonhosted.org/packages/96/b5/8d96bc1ef9dc835b99c11c98d9203761dfbb7aac9dc8600e27204ecca4b5/covjson_pydantic-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 10:30:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "knmi",
"github_project": "covjson-pydantic",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "covjson-pydantic"
}