Skip to main content

Extract time series from Bifrost BSX files as pandas DataFrame.

Project description

Bifrost BSX Tools

Extract time series from Bifrost BSX files as pandas DataFrame.

Compatible with Bifrost v6 "Sindri".

Installation

pip install bifrost_bsx_tools

Usage

Load a BSX file and get the settlement ID

from bifrost_bsx_tools import BsxArchive

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

Output:

'MyFancySettlement'

List the runs in the archive

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

bsx.get_runs_metadata()

Output:

{
  '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

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

Output:

[
  {
    '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.

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

Output:

True

Get the time series for a run

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bifrost_bsx_tools-0.0.4.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

bifrost_bsx_tools-0.0.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file bifrost_bsx_tools-0.0.4.tar.gz.

File metadata

  • Download URL: bifrost_bsx_tools-0.0.4.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for bifrost_bsx_tools-0.0.4.tar.gz
Algorithm Hash digest
SHA256 37d86b0864abdd79d655f0271039c7de928a23d1eb119842f128fb7019f5e4c0
MD5 3b3731726593c3fa740fabae50b6d633
BLAKE2b-256 426c575e6525ec6f1c31f074ec7cb9cff8d44a2cec2798eec9ee5187061ade83

See more details on using hashes here.

File details

Details for the file bifrost_bsx_tools-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for bifrost_bsx_tools-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 15a88975657e72b0c4c79b047da5239dbc4f27e9dc434b8e89b63afd5201d861
MD5 87ddaa5a297d906eeaedce0b04c1078b
BLAKE2b-256 bbd828ca069ed2d4e13e0d01385de0a89e80844536bfbe7546077bc4cfb07f14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page