Plot Streaming Data with Plotly Express and Python

The article provides an overview of streaming data and its importance, particularly for tracking the International Space Station (ISS). It explains the process of retrieving ISS telemetry data using Python and Plotly Express, including details on handling streaming data, importing necessary libraries, and plotting ISS telemetry. The article also offers guidance on alternative approaches for tracking the ISS.

 Plot Streaming Data with Plotly Express and Python

“`html

Tracking the ISS in real time

The ability to handle streaming data is an important skill for a data scientist. In this Quick Success Data Science project, we’ll use streaming data to track the International Space Station (ISS) as it orbits the Earth. For coding we’ll use Python and Plotly Express in a Jupyter Notebook.

International Space Station Telemetry

Telemetry is the in-situ collection and automatic transmission of remote sensor data to receiving equipment for monitoring. While there are numerous sources for ISS telemetry, we’ll use the WTIA REST API (WTIA stands for Where the ISS at?).

The Plotly Express Library

Plotly Express is a built-in part of the Plotly graphing library. As a simpler, higher-level version of Plotly, it’s the recommended starting point for creating most common figures.

The Process

Data streams aren’t truly continuous. Websites are updated at some frequency, such as once per second. Likewise, we can’t get the data faster than it’s created, nor should we try to get it as fast as possible. If you ping a website too frequently, it may think it’s under attack and block your access. So, when possible, we should request data at the polite rate of every 5 or 10 seconds.

Importing Libraries and Assigning Constants

In addition to Plotly Express, we’ll need the time module, to control how often we access the streaming data; the requests library, for retrieving the data from a URL; the pandas library, for preparing the data for plotting; and IPython.display, for clearing the plot prior to posting an updated ISS location.

Getting the Streaming Data

The following get_iss_telemetry function retrieves the streaming data from the URL, loads it as a pandas DataFrame, drops unnecessary columns, and returns the DataFrame. Each time this function is called, it records the ISS telemetry for a single instant in time. Later, we’ll call this function in a loop to track the ISS over time. Of course, for all this to work, you’ll need an active internet connection.

Plotting the ISS

The last step is to define a function to plot the telemetry for a given number of orbits. This function will call the previous function using a for loop. The resulting plot will include a marker for the ISS and a line to record its ground track over time.

The Outcome

Despite a trivial amount of code, this plot possesses a lot of functionality. If you hover the cursor over the marker, a popup window will display telemetry such as the station’s altitude, velocity (in km/hour), visibility, and so on. You can zoom in and out with a mouse scroller or the toolbar. You can take screenshots, pan, and reset the view. The ISS marker will change colors depending on how the ISS is illuminated.

More Trackers

You can also access the ISS’s telemetry through the Open-Notify-API. And as always with Python, there’s more than one way to accomplish a task. Here are some alternative approaches for tracking the station.

Discover how AI can redefine your way of work. Identify Automation Opportunities: Locate key customer interaction points that can benefit from AI. Define KPIs: Ensure your AI endeavors have measurable impacts on business outcomes. Select an AI Solution: Choose tools that align with your needs and provide customization. Implement Gradually: Start with a pilot, gather data, and expand AI usage judiciously.

Spotlight on a Practical AI Solution:

Consider the AI Sales Bot from itinai.com/aisalesbot designed to automate customer engagement 24/7 and manage interactions across all customer journey stages.

Discover how AI can redefine your sales processes and customer engagement. Explore solutions at itinai.com.

“`

List of Useful Links:

AI Products for Business or Try Custom Development

AI Sales Bot

Welcome AI Sales Bot, your 24/7 teammate! Engaging customers in natural language across all channels and learning from your materials, it’s a step towards efficient, enriched customer interactions and sales

AI Document Assistant

Unlock insights and drive decisions with our AI Insights Suite. Indexing your documents and data, it provides smart, AI-driven decision support, enhancing your productivity and decision-making.

AI Customer Support

Upgrade your support with our AI Assistant, reducing response times and personalizing interactions by analyzing documents and past engagements. Boost your team and customer satisfaction

AI Scrum Bot

Enhance agile management with our AI Scrum Bot, it helps to organize retrospectives. It answers queries and boosts collaboration and efficiency in your scrum processes.