===========================================
rocc - Rate-of-change check for time series
===========================================
.. image:: https://img.shields.io/pypi/v/rocc.svg
:target: https://pypi.python.org/pypi/rocc
.. image:: https://img.shields.io/travis/openmeteo/rocc.svg
:target: https://travis-ci.org/openmeteo/rocc
.. image:: https://codecov.io/github/openmeteo/rocc/coverage.svg
:target: https://codecov.io/gh/openmeteo/rocc
:alt: Coverage
.. image:: https://pyup.io/repos/github/openmeteo/rocc/shield.svg
:target: https://pyup.io/repos/github/openmeteo/rocc/
:alt: Updates
::
from rocc import Threshold, rocc
result = rocc(
timeseries=a_htimeseries_object,
thresholds=(
Threshold("10min", 10),
Threshold("20min", 15),
Threshold("H", 40),
),
symmetric=True,
flag="MYFLAG",
)
``timeseries`` is a HTimeseries_ object. ``thresholds`` is, obviously,
a list of thresholds. ``Threshold`` is a named tuple whose items are
``delta_t`` (a pandas interval specification) and ``allowed_diff`` (a
floating point number).
The function checks whether there exist intervals during which the value
of the time series changes by more than the specified threshold. The
offending records are flagged with the specified ``flag``.
It returns a list of strings describing where the thresholds have been
exceeded.
If ``flag`` is ``None`` or the empty string, then the offending records
are not flagged, and the only result is the returned value.
Here is an example time series::
2020-10-06 14:30 24.0
2020-10-06 14:40 25.0
2020-10-06 14:50 36.0 *
2020-10-06 15:01 51.0
2020-10-06 15:21 55.0
2020-10-06 15:31 65.0
2020-10-06 15:41 75.0 *
2020-10-06 15:51 70.0
After running ``rocc()`` with the ``thresholds`` specified in the
example above, the records marked with a star will be flagged. The
record ``14:50`` will be flagged because in the preceding 10-minute
interval the value increases by 11, which is more than 10. The record
``15:41`` will be flagged because in the preceding 20-minute interval
the value increases by 20, which is more than 15. The record ``15:01``
will be unflagged; although there's a large difference since ``14:40``,
this is 21 minutes, not 20, so the 20-minute threshold of 15 does not
apply; likewise, there's a difference of 15 from ``14:50``, which does
not exceed the 20-minute threshold of 15, and while it does exceed the
10-minute threshold of 10, it's 11 minutes, not 10. There's also not any
difference larger than 40 within an hour anywhere.
The return value in this example will be a list of two strings::
"2020-10-06T14:50 +11.0 in 10min (> 10.0)"
"2020-10-06T15:41 +20.0 in 20min (> 15.0)"
The return value should only be used for consumption by humans; it is
subject to change.
If ``symmetric`` is ``True``, it is the absolute value of the change
that matters, not its direction. In this case, ``allowed_diff`` must be
positive. If ``symmetric`` is ``False`` (the default), only rates larger
than positive ``allow_diff`` or rates smaller than negative
``allow_diff`` are flagged.
.. _HTimeseries: https://github.com/openmeteo/htimeseries/
=======
History
=======
3.0.2 (2024-04-17)
==================
- Compatible with htimeseries 7.
3.0.1 (2023-12-20)
==================
- Compatible with htimeseries 6.
3.0.0 (2022-12-01)
==================
- Compatible with htimeseries 4, which uses aware timestamps.
2.0.0 (2020-02-11)
==================
- rocc() now returns a list of strings with descriptions of where the
thresholds have been exceeded.
- The default flag is now to not add any flags.
- A bug has been fixed where it would crash if input time series was
empty.
1.0.0 (2020-11-06)
==================
- Initial release
Raw data
{
"_id": null,
"home_page": "https://github.com/openmeteo/rocc",
"name": "rocc",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Antonis Christofides",
"author_email": "antonis@antonischristofides.com",
"download_url": "https://files.pythonhosted.org/packages/a6/7c/1bdf3ec3fb9fa2711802ccbca4dcfab8967fa959d74de7ec3c3287a3102b/rocc-3.0.2.tar.gz",
"platform": null,
"description": "===========================================\nrocc - Rate-of-change check for time series\n===========================================\n\n\n.. image:: https://img.shields.io/pypi/v/rocc.svg\n :target: https://pypi.python.org/pypi/rocc\n\n.. image:: https://img.shields.io/travis/openmeteo/rocc.svg\n :target: https://travis-ci.org/openmeteo/rocc\n\n.. image:: https://codecov.io/github/openmeteo/rocc/coverage.svg\n :target: https://codecov.io/gh/openmeteo/rocc\n :alt: Coverage\n\n.. image:: https://pyup.io/repos/github/openmeteo/rocc/shield.svg\n :target: https://pyup.io/repos/github/openmeteo/rocc/\n :alt: Updates\n\n::\n\n from rocc import Threshold, rocc\n\n result = rocc(\n timeseries=a_htimeseries_object,\n thresholds=(\n Threshold(\"10min\", 10),\n Threshold(\"20min\", 15),\n Threshold(\"H\", 40),\n ),\n symmetric=True,\n flag=\"MYFLAG\",\n )\n\n``timeseries`` is a HTimeseries_ object. ``thresholds`` is, obviously,\na list of thresholds. ``Threshold`` is a named tuple whose items are\n``delta_t`` (a pandas interval specification) and ``allowed_diff`` (a\nfloating point number).\n\nThe function checks whether there exist intervals during which the value\nof the time series changes by more than the specified threshold. The\noffending records are flagged with the specified ``flag``.\n\nIt returns a list of strings describing where the thresholds have been\nexceeded.\n\nIf ``flag`` is ``None`` or the empty string, then the offending records\nare not flagged, and the only result is the returned value.\n\nHere is an example time series::\n\n 2020-10-06 14:30 24.0\n 2020-10-06 14:40 25.0 \n 2020-10-06 14:50 36.0 *\n 2020-10-06 15:01 51.0\n 2020-10-06 15:21 55.0 \n 2020-10-06 15:31 65.0 \n 2020-10-06 15:41 75.0 *\n 2020-10-06 15:51 70.0\n\nAfter running ``rocc()`` with the ``thresholds`` specified in the\nexample above, the records marked with a star will be flagged. The\nrecord ``14:50`` will be flagged because in the preceding 10-minute\ninterval the value increases by 11, which is more than 10. The record\n``15:41`` will be flagged because in the preceding 20-minute interval\nthe value increases by 20, which is more than 15. The record ``15:01``\nwill be unflagged; although there's a large difference since ``14:40``,\nthis is 21 minutes, not 20, so the 20-minute threshold of 15 does not\napply; likewise, there's a difference of 15 from ``14:50``, which does\nnot exceed the 20-minute threshold of 15, and while it does exceed the\n10-minute threshold of 10, it's 11 minutes, not 10. There's also not any\ndifference larger than 40 within an hour anywhere.\n\nThe return value in this example will be a list of two strings::\n\n \"2020-10-06T14:50 +11.0 in 10min (> 10.0)\"\n \"2020-10-06T15:41 +20.0 in 20min (> 15.0)\"\n\nThe return value should only be used for consumption by humans; it is\nsubject to change.\n\nIf ``symmetric`` is ``True``, it is the absolute value of the change\nthat matters, not its direction. In this case, ``allowed_diff`` must be\npositive. If ``symmetric`` is ``False`` (the default), only rates larger\nthan positive ``allow_diff`` or rates smaller than negative\n``allow_diff`` are flagged.\n\n.. _HTimeseries: https://github.com/openmeteo/htimeseries/\n\n\n=======\nHistory\n=======\n\n3.0.2 (2024-04-17)\n==================\n\n- Compatible with htimeseries 7.\n\n3.0.1 (2023-12-20)\n==================\n\n- Compatible with htimeseries 6.\n\n3.0.0 (2022-12-01)\n==================\n\n- Compatible with htimeseries 4, which uses aware timestamps.\n\n2.0.0 (2020-02-11)\n==================\n\n- rocc() now returns a list of strings with descriptions of where the\n thresholds have been exceeded.\n- The default flag is now to not add any flags.\n- A bug has been fixed where it would crash if input time series was\n empty.\n\n1.0.0 (2020-11-06)\n==================\n\n- Initial release\n",
"bugtrack_url": null,
"license": "GNU General Public License v3",
"summary": "Rate-of-change check of time series",
"version": "3.0.2",
"project_urls": {
"Homepage": "https://github.com/openmeteo/rocc"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a67c1bdf3ec3fb9fa2711802ccbca4dcfab8967fa959d74de7ec3c3287a3102b",
"md5": "73ae40d5eaca613a7ec39e9318d25d42",
"sha256": "30860f2c114f467ec3bcdef7ed702d343efdb2e0740ab7944b6233eb37508f66"
},
"downloads": -1,
"filename": "rocc-3.0.2.tar.gz",
"has_sig": false,
"md5_digest": "73ae40d5eaca613a7ec39e9318d25d42",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 75081,
"upload_time": "2024-04-17T10:49:43",
"upload_time_iso_8601": "2024-04-17T10:49:43.134938Z",
"url": "https://files.pythonhosted.org/packages/a6/7c/1bdf3ec3fb9fa2711802ccbca4dcfab8967fa959d74de7ec3c3287a3102b/rocc-3.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-17 10:49:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "openmeteo",
"github_project": "rocc",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "rocc"
}