DEV Community

Cover image for Combining Weather Data and Operation Performance to Improve Service Level Agreements
Ashok Sharma
Ashok Sharma

Posted on

Combining Weather Data and Operation Performance to Improve Service Level Agreements

Service Level Agreements (SLA) are a critical part of any business. They serve several critical purposes. Customers know what they can expect from a vendor in terms of quality, schedule, and what sort of uncertainty is acceptable. SLA’s acknowledge that no one can provide perfect service; instead, that level of service should be discussed, agreed to, and penalties should be agreed upon well before a service obligation is not met. They also allow the customer to express in writing what metrics are most important to them. Key SLA metrics can be many, and for each one agreed to there is an indirect price paid by the customer, as it means the vendor has to go to extra lengths to ensure the metric is met, avoiding penalties.

Uncertain events are the bane of SLA’s, and weather is a key contributor. While there are ways to improve your internal business processes, such as using Python to improve data pre-processing and analyzing key metrics to ensure they are at the right levels, it can be difficult to track uncertain factors that are out of a business’ hands. By using Python and pulling weather data for analysis, you can better understand what weather affects your SLA metrics, and can begin to improve the metrics themselves while gaining a better understanding of reasonable SLA with your customers.

Using Weather API Data to Predict the Impact of Extreme Weather on Your SLA Metrics

This tutorial will walk through a very straightforward way to pull historical weather data, pre-process it, and align it with key metrics that reflect your SLA targets (on time deliveries, reliability, outages, etc.). Because we are using Python, we can pull the weather data, input the SLA metrics, and create visualizations of their correlations all in the same script. This can quickly help your team better understand weather impacts, which is critical for two reasons: You can better optimize your SLA metrics around current and predicted weather events that you know may affect you, and you can better adjust your service level agreements in a way that reflect weather intrusions and show your customers that your SLA is more reliable.

Setup

This tutorial utilizes Python, along with the following libraries (shown in the screenshot) to collect and analyze historical weather data. For this example we will use Tomorrow.io’s Weather API call as it has a vast amount of weather data available and has been designed for easy use.

Image description

Get/Input API Key

For this example we are using Tomorrow.io, so you will need to sign up to get your API key, then enter it at the prompt to gain access to the data.

Image description

Select A Location of Interest

For a location there is some flexibility, as you can enter it as a Latlong pair, or you can either use a geometry attribute of a GeoJSON or you can use a “locationID”, which is pulled from a Locations API (more info on the locations format here).

Image description

List the Weather Fields of Interest

We will pull key weather metrics that most likely affect uptime, deliveries, and overall service, depending on your business. These include:

  1. Precipitation that has accumulated
  2. Wind
  3. Speed
  4. Gust
  5. Direction
  6. Snow accumulation

There are many other data points that can be pulled, with the details of each metric explained here. However these should offer a glimpse at potential service interruption due to weather.

Image description

Decide What Unit System to Use

This step is simple, you can select either metric or imperial measurements.

Image description

Select The Timestep

For timesteps, you can select either hourly or daily steps (1h and 1d). However, it is helpful to know that this will pull the max value in that timestep, not the average. You can add Min, Max, or Avg to the timestamp to specify (syntax here), or you can specify a MinTime or MaxTime variable to alert when in the timestep the event occurs.

Image description

Set Up The Time Frame

This allows you to decide how much historical data to look at, and supports data from January 01 2015 onward. This can be helpful even if you don’t have business data that goes back that far, as you can use what you have to determine basic correlation of weather increasing risk of affecting SLA metrics, then apply that correlation to the historic weather data to get a longer term look at how the weather has or would have affected your business.

Image description

Select Time Zone

The time zone should use the standard IANA database format.

Image description

Pull The Timelines

This step pulls the data from the timelines as requested, but you will need to include corresponding units to each item in order to keep track of what the data represents.

Image description

Construct A Dataframe to Hold The Response

This step creates and populates a dataframe so that you can analyze and manipulate it, as well as bring in your own data to conduct the correlation analysis.

Image description

Bring In Your Business Data

At this point you have the weather data you need, and it’s time to bring in the business data. For this example we will keep it simple, importing data (using the same timesteps as the weather data) that includes:

  • # Delays
  • Average duration of each delay
  • Missed deliveries
  • Average route length There are countless other metrics that could be used, and it’s important to select your own metrics based on the nature of your business. You will need to brainstorm which metrics could be affected by adverse weather, directly or indirectly.

Image description

Create Visualizations for Faster Decision Making

At this point you can use whatever visualization tools you’d like to paint a picture of weather / SLA correlation. Remember, visualization isn’t about creating a good looking chart; what matters is the metric “time to action”. In other words, what decisions will I need to make once I see the data, and how can I create a visualization that guides me to those decisions as quickly as possible.

Image description

Final Thoughts

This tutorial for pulling weather data and correlating with SLA metrics should give you plenty of flexibility to customize it for your own needs. Remember, more accurate SLA’s mean fewer penalties, happier customers, and more revenue. Good luck!

Source: main image Depositphotos

Top comments (0)