Skip to main content
Glama
XRDS76354

SUMO-MCP Server

by XRDS76354
analysis.py1.08 kB
import sumolib import pandas as pd import os def analyze_fcd(fcd_file: str) -> str: """ Analyze FCD (Floating Car Data) output XML to compute basic statistics. """ if not os.path.exists(fcd_file): return f"Error: File {fcd_file} not found." try: speeds = [] vehicle_counts = 0 # sumolib.output.parse returns a generator for timestep in sumolib.output.parse(fcd_file, 'timestep'): if timestep.vehicle: for vehicle in timestep.vehicle: speeds.append(float(vehicle.speed)) vehicle_counts += 1 if not speeds: return "No vehicle data found in FCD output." avg_speed = sum(speeds) / len(speeds) df = pd.DataFrame({'speed': speeds}) desc = df.describe().to_string() return f"Analysis Result:\nTotal Data Points: {vehicle_counts}\nAverage Speed: {avg_speed:.2f} m/s\n\nStatistics:\n{desc}" except Exception as e: return f"Analysis error: {str(e)}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/XRDS76354/SUMO-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server