Skip to main content

Some utilities for BNS internal use

Project description

BNS UTILS

Documentation goes here.

Data Module

IP21

The IP21 class provides a Python interface for interacting with an IP.21 historian database. It uses the pyodbc and pandas libraries to connect to the database and execute SQL queries.

Initialization

To use the IP21 Python Interface, you first need to initialize an instance of the IP21 class. The IP21 constructor takes the following arguments:

  • host: The IP address or hostname of the IP21 server
  • port: The port number to use when connecting to the IP21 server
  • ads: The name of the IP21 Advanced Data Server (ADS) to connect to (default: MINPRO)
from bns_utils.data import IP21

# Create an IP21 object to connect to the historian database
ip21 = IP21(host="127.0.0.1", port=1234, ads="MINPRO")

Retrieving Tag Names and Definitions

The tag_dump method can be used to retrieve a list of all IP.21 tags and their descriptions from the historian database. By default, this method saves the list to a CSV file named tag_dump.csv, but this behavior can be disabled by passing write_csv=False. For example:

# Retrieve a list of all tags and save it to a CSV file
ip21.tag_dump()

# Retrieve a list of all tags without saving it to a CSV file
tag_list = ip21.tag_dump(write_csv=False)

Retrieving Tag Data

You can retrieve historical data for a list of tags using the tag_data method. This method takes the following arguments:

  • tag_list: A list of tag names to retrieve data for
  • start: The start time for the data in the format "DD-Mon-YY HH:MM:SS"
  • end: The end time for the data in the format "DD-Mon-YY HH:MM:SS"
  • freq: The interval to retrieve data at in the format "HH:MM:SS"
  • separate: A boolean indicating whether to save the data for each tag separately (default: True)
  • file_type: The file format to use when saving the data (either ftr or csv, default: ftr)

Here is an example of how to retrieve data for a single tag:

ip21.tag_data(tag_list=["MyTag"], start="01-Jan-23 00:00:00", end="02-Jan-23 00:00:00", freq="00:01:00")

This will retrieve data for the tag "MyTag" between January 1st, 2023 and January 2nd, 2023, at one minute intervals. The data will be saved to a file named MyTag.ftr in Feather format by default.

If you want to retrieve data for multiple tags, simply pass a list of tag names to the tag_list argument:

ip21.tag_data(tag_list=["Tag1", "Tag2", "Tag3"], start="01-Jan-23 00:00:00", end="02-Jan-23 00:00:00", freq="00:01:00")

This will retrieve data for the tags "Tag1", "Tag2", and "Tag3" between January 1st, 2023 and January 2nd, 2023, at one minute intervals. The data for each tag will be saved to separate files by default.

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

bns_utils-0.0.5.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bns_utils-0.0.5-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file bns_utils-0.0.5.tar.gz.

File metadata

  • Download URL: bns_utils-0.0.5.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for bns_utils-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3bd3710c81bf4d29e477551cea345b234aa0f01029bedca689694a3ef9bd4cab
MD5 dfc2dd0bbbd15f50d6cd1a009076078f
BLAKE2b-256 f63fe2d758ac3f5393a2b2d929dd5bd0ee6e90c822d1d41a01c08d1de60967fd

See more details on using hashes here.

File details

Details for the file bns_utils-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: bns_utils-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for bns_utils-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d1b32c90a59644dbb3744d0ad782bb2fda88541fb68427dbb6993ad10042ccd3
MD5 f902881e13b9c5e19efcc194bc9dc697
BLAKE2b-256 27f239842231e7e3957bc2aac7849c2873495638a589d52a671044d4b95e614e

See more details on using hashes here.

Supported by

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