Skip to main content

Pull weather data into TrendMiner

  • August 19, 2026
  • 0 replies
  • 20 views

eddieh
Employee
Forum|alt.badge.img

Weather and climate conditions have a measurable impact on manufacturing operations. Temperature fluctuations affect material properties, humidity influences product quality, and atmospheric pressure can impact equipment performance. By bringing weather data directly into TrendMiner, you can correlate these environmental factors with your production metrics in real time, revealing patterns that spreadsheet-based analysis misses.

Quick example

Here's a Python script you can run within custom calculations to extract the latest weather data and create a new tag with it. You can also create your own custom connector using our API documentation; reach out to your Customer Success Manager or the TrendMiner Support Team for more information.

import pandas as pd
from datetime import datetime
import pytz
import os
import requests
from trendminer import TrendMinerClient

client = TrendMinerClient.from_token(token=os.environ['ACCESS_TOKEN'])
output_file = os.environ["OUTPUT_FILE"]

# Set your facility timezone
local_tz = pytz.timezone('America/Chicago')

# Fetch weather data
w = requests.get('http://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&q=Houston&aqi=no')
weather_data = w.json()

# Extract timestamp and value
ts = weather_data['current']['last_updated']
val = weather_data['current']['feelslike_f']

# Convert to UTC
ts_datetime_local = local_tz.localize(datetime.strptime(ts, '%Y-%m-%d %H:%M'))
ts_datetime_utc = ts_datetime_local.astimezone(pytz.utc)

# Create output
df = pd.DataFrame({'timestamp': [ts_datetime_utc], 'value': [val]})
df.to_csv(output_file, index=False)

Customize the script with your location, timezone, and desired weather metric (temperature, humidity, pressure, etc.). Schedule it to run hourly or on whatever cadence fits your analysis needs. There are some free and other paid services online where you can get detailed weather data from.