Predix_Logo
  • Categories
    • Questions
    • Predix | Updates
      • Pricing
      • Product
    • Deloitte - Private
    • How-To
    • Accenture-Private
  • Explore
    • Topics
    • Questions
    • Articles
    • Feedback or Feature Requests
  • Sign in
  • Home /
  • How-To /
avatar image
  • Home /
  • How-To /

How-To: Simulate Time Series Data with Python

  • Export to PDF
j12y created · Feb 28, 2018 at 11:20 AM
1

PROBLEM

You want to populate your Predix Time Series instance with some sample / test data. If you don't already have sample data in a file you may need to generate some random data.

Python can be helpful for this sort of quick and dirty task.

STEPS

(1) Install the Predix Python SDK

If you don't already have PredixPy, install it with pip. More instructions can be found from the PredixPy Github Repository.

(2) Create a UAA and Time Series Instance

Perhaps you already have instances, but if not the Predix Python SDK can help create them.

 import predix.admin.app
 admin = predix.admin.app.Manifest()
 admin.create_uaa(uaa_secret)
 admin.create_client(client_id, client_secret)
 admin.create_timeseries()

(3) Generate a random value

There are many ways to generate a random number in Python and make it fit within the parameters you are looking for. If you'd like to add more examples that are useful I'd like to see them. Once you have your random value, then you can simply send it to Time Series in the way that makes sense for your application testing.

 import time
 import random
 import predix.app
 
 min_voltage = 200
 max_voltage = 240
 hertz = 1.0/1.0
 
 app = predix.app.Manifest()
 ts = app.get_timeseries()
 while True:
       try:
 
         # Generate a random voltage value simulated from multiple sensors
         # and queue them up.
         for tag in ['Voltage:Sensor1', 'Voltage:Sensor2', 'Voltage:Sensor3']:
             value = random.randint(min_voltage, max_voltage)
             ts.queue(tag, value)
             print(tag, value)
 
         # Send readings from all 3 sensors to Time Series and then wait to
         # take another reading.
         ts.send()
         time.sleep(hertz)
 
     except KeyboardInterrupt:
 
         # Provide evidence data was being stored before exiting
         print(ts.get_tags())
         break

DEPENDENCIES

To use this you need

  • Predix Python SDK

  • Time Series Instance with UAA Client Scopes/Authorities

If you find something to be missing, comment or let me know.

RESOURCES

Useful resources

  • PredixPy Cookbook

  • Github Repository

thub.nodes.view.add-new-comment
pythonpython-sdkpredix-timeseries-service
Add comment
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Article

Contributors

avatar image
Follow

Follow this article

64 People are following this .

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Navigation

How-To: Simulate Time Series Data with Python

Related Articles

How-To: Specify a Python Version for Your App

How-To: Analytics Framework Workflow Automation Using Python --- Single Analytic Management

How-To: Deploy a Python App on Predix in under 10 minutes!

How-To Use Python to Remove or Modify Empty Values in a CSV Dataset

How-to: Deploy a python app on predix consisting of more than one or multiple python (.py) files.

How-To: Specify a Python Buildpack

How-To: Include Your Own Private Python Libraries in Your App

How-To: Use redis-cli, psql and python from gotty in the Predix Cloud

How-To: Update DevBox for Python Development

GE Monogram
  • Legal
  • Cookies
  • Forum Terms
  • Contact Us
  • Copyright © 2017 General Electric Company. All rights reserved.


Enterprise
Social Q&A

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Submit your feedback or feature request
  • Categories
  • Questions
  • Predix | Updates
    • Pricing
    • Product
  • Deloitte - Private
  • How-To
  • Accenture-Private
  • Explore
  • Topics
  • Questions
  • Articles
  • Feedback or Feature Requests