bifrost-bsx-tools


Namebifrost-bsx-tools JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryExtract time series from Bifrost BSX files as pandas DataFrame.
upload_time2023-04-03 12:16:12
maintainer
docs_urlNone
author
requires_python>=3.7
licenseCopyright (c) 2023 Valentin Bauer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords bifrost bsx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Bifrost BSX Tools

Extract time series from [Bifrost](https://bifrost.siemens.com) BSX files as pandas DataFrame.

Compatible with Bifrost v6 "Sindri".

## Installation

```bash
pip install bifrost_bsx_tools
```

## Usage

### Load a BSX file and get the settlement ID

```python
from bifrost_bsx_tools import BsxArchive

bsx = BsxArchive('scenario_a.bsx')
bsx.get_settlement_id()
```

Output:

```python
'MyFancySettlement'
```

---

### List the runs in the archive

Optinally, add the keyword argument `named_runs_only=True` to get only runs with names.

```python
bsx.get_runs_metadata()
```

Output:

```python
{
  'RUN:10601920-ac83-11ed-b4f1-0bee431b5633': {
    'startTime': 5097600,
    'timeHorizon': 7948800,
    'prefetchStep': 900,
    'description': 'run #1', # <- this is the name
    'timestamp': 1676391443,
    'tags': [],
    'scenarioHash': 'e2889fdc93ffba3511598322cc13252f3e768c4826f31c400e739ee62a66475d',
    'complete': True,
    'persisted': True,
    'historic': False
  },
  ...
}
```

---

### Get the metadata of dynamics present in a run

```python
run_id = 'RUN:10601920-ac83-11ed-b4f1-0bee431b5633'
bsx.get_dynamics_metadata(run_id)
```

Output:

```python
[
  {
    'id': 'SUN-ALTITUDE:0f2bf2d1-ac6b-11ed-9a57-2d85e0d4252e',
    'cardinality': 1,
    'type': 'number'
  },
  ...
]
```

---

### Does a timeseries exist for a dynamic?

Checks if a file with the name `SUN-ALTITUDE_0f2bf2d1-ac6b-11ed-9a57-2d85e0d4252e.csv` exists in the run folder. Bifrost sometimes does not create a file for every dynamic when it has not been stored in the InfluxDB.

```python
dynamic_id = 'SUN-ALTITUDE:0f2bf2d1-ac6b-11ed-9a57-2d85e0d4252e'
bsx.dynamic_timeseries_exists(run_id, dynamic_id)
```

Output:

```python
True
```

### Get the time series for a run

Returns a pandas DataFrame with the time series for the dynamic.

```python
bsx.get_dynamic_timeseries(run_id, dynamic_id)
```

Output:

| Time | Timestep | 0 |
| --- | ---: | ---: |
| 1970-03-01 00:00:00 | 5097600 | 138 |
| 1970-03-01 00:15:00 | 5098500 | 137 |
| 1970-03-01 00:30:00 | 5099400 | 135 |
| 1970-03-01 00:45:00 | 5100300 | 134 |
| 1970-03-01 01:00:00 | 5101200 | 132 |
| ... | ... | ... |
| 1970-05-31 23:00:00 | 13042800 | 109 |
| 1970-05-31 23:15:00 | 13043700 | 109 |
| 1970-05-31 23:30:00 | 13044600 | 109 |
| 1970-05-31 23:45:00 | 13045500 | 108 |
| 1970-06-01 00:00:00 | 13046400 | 108 |





            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "bifrost-bsx-tools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "bifrost,bsx",
    "author": "",
    "author_email": "Valentin Bauer <valentin.bauer@tuwien.ac.at>",
    "download_url": "https://files.pythonhosted.org/packages/c5/36/0ad0da36afb5d091bde4ba0f47b5da2c3099ced83f60337e10a6660fef92/bifrost_bsx_tools-0.0.2.tar.gz",
    "platform": null,
    "description": "# Bifrost BSX Tools\n\nExtract time series from [Bifrost](https://bifrost.siemens.com) BSX files as pandas DataFrame.\n\nCompatible with Bifrost v6 \"Sindri\".\n\n## Installation\n\n```bash\npip install bifrost_bsx_tools\n```\n\n## Usage\n\n### Load a BSX file and get the settlement ID\n\n```python\nfrom bifrost_bsx_tools import BsxArchive\n\nbsx = BsxArchive('scenario_a.bsx')\nbsx.get_settlement_id()\n```\n\nOutput:\n\n```python\n'MyFancySettlement'\n```\n\n---\n\n### List the runs in the archive\n\nOptinally, add the keyword argument `named_runs_only=True` to get only runs with names.\n\n```python\nbsx.get_runs_metadata()\n```\n\nOutput:\n\n```python\n{\n  'RUN:10601920-ac83-11ed-b4f1-0bee431b5633': {\n    'startTime': 5097600,\n    'timeHorizon': 7948800,\n    'prefetchStep': 900,\n    'description': 'run #1', # <- this is the name\n    'timestamp': 1676391443,\n    'tags': [],\n    'scenarioHash': 'e2889fdc93ffba3511598322cc13252f3e768c4826f31c400e739ee62a66475d',\n    'complete': True,\n    'persisted': True,\n    'historic': False\n  },\n  ...\n}\n```\n\n---\n\n### Get the metadata of dynamics present in a run\n\n```python\nrun_id = 'RUN:10601920-ac83-11ed-b4f1-0bee431b5633'\nbsx.get_dynamics_metadata(run_id)\n```\n\nOutput:\n\n```python\n[\n  {\n    'id': 'SUN-ALTITUDE:0f2bf2d1-ac6b-11ed-9a57-2d85e0d4252e',\n    'cardinality': 1,\n    'type': 'number'\n  },\n  ...\n]\n```\n\n---\n\n### Does a timeseries exist for a dynamic?\n\nChecks if a file with the name `SUN-ALTITUDE_0f2bf2d1-ac6b-11ed-9a57-2d85e0d4252e.csv` exists in the run folder. Bifrost sometimes does not create a file for every dynamic when it has not been stored in the InfluxDB.\n\n```python\ndynamic_id = 'SUN-ALTITUDE:0f2bf2d1-ac6b-11ed-9a57-2d85e0d4252e'\nbsx.dynamic_timeseries_exists(run_id, dynamic_id)\n```\n\nOutput:\n\n```python\nTrue\n```\n\n### Get the time series for a run\n\nReturns a pandas DataFrame with the time series for the dynamic.\n\n```python\nbsx.get_dynamic_timeseries(run_id, dynamic_id)\n```\n\nOutput:\n\n| Time | Timestep | 0 |\n| --- | ---: | ---: |\n| 1970-03-01 00:00:00 | 5097600 | 138 |\n| 1970-03-01 00:15:00 | 5098500 | 137 |\n| 1970-03-01 00:30:00 | 5099400 | 135 |\n| 1970-03-01 00:45:00 | 5100300 | 134 |\n| 1970-03-01 01:00:00 | 5101200 | 132 |\n| ... | ... | ... |\n| 1970-05-31 23:00:00 | 13042800 | 109 |\n| 1970-05-31 23:15:00 | 13043700 | 109 |\n| 1970-05-31 23:30:00 | 13044600 | 109 |\n| 1970-05-31 23:45:00 | 13045500 | 108 |\n| 1970-06-01 00:00:00 | 13046400 | 108 |\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2023 Valentin Bauer  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Extract time series from Bifrost BSX files as pandas DataFrame.",
    "version": "0.0.2",
    "split_keywords": [
        "bifrost",
        "bsx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e6520b4bceefd19689135d99c1ba963064665d4259d8e95bd2f8d75eb0dd257",
                "md5": "400751bbbffa548a3eeaf1015364e734",
                "sha256": "49438b407ac70cdc0ff828c961a5a3752f8c152f10c4a366e6b69a6807b195a6"
            },
            "downloads": -1,
            "filename": "bifrost_bsx_tools-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "400751bbbffa548a3eeaf1015364e734",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6562,
            "upload_time": "2023-04-03T12:16:10",
            "upload_time_iso_8601": "2023-04-03T12:16:10.155494Z",
            "url": "https://files.pythonhosted.org/packages/6e/65/20b4bceefd19689135d99c1ba963064665d4259d8e95bd2f8d75eb0dd257/bifrost_bsx_tools-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c5360ad0da36afb5d091bde4ba0f47b5da2c3099ced83f60337e10a6660fef92",
                "md5": "87502ed354f1144ae1caadb69ec61371",
                "sha256": "ad7a5a36a136a7335d13c5e8ff03e8af4f2adeb60c64d5e2ff8726f76e4620b0"
            },
            "downloads": -1,
            "filename": "bifrost_bsx_tools-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "87502ed354f1144ae1caadb69ec61371",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6385,
            "upload_time": "2023-04-03T12:16:12",
            "upload_time_iso_8601": "2023-04-03T12:16:12.957799Z",
            "url": "https://files.pythonhosted.org/packages/c5/36/0ad0da36afb5d091bde4ba0f47b5da2c3099ced83f60337e10a6660fef92/bifrost_bsx_tools-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-03 12:16:12",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "bifrost-bsx-tools"
}
        
Elapsed time: 0.05136s