Sony Pixel Power calrec Sony

Using Pyon scripts with MaMotion Creating a timetable schedule from an OD matrix

16/04/2015

Introduction MassMotion's timetables are incredibly powerful, but can be time-consuming to pull together by hand. On the other hand, simple programs can do much of the donkey work, converting files such as Origin/Destination Matrices (OD Matrices) or train schedules into a form that MassMotion can read. In this article I will be looking at converting an OD Matrix into a timetable schedule file using a programming language called Python.

Python Python is a free scripting language that is simple to use, powerful, and importantly for us great for working with comma separated value (.csv) files, which are a typical output from Excel.

Python comes in two slightly different versions: Python2x and Python3x. The x refers to the particular build: I am currently using Python3.4.3. You may find a certain amount of controversy online regarding which it is best to use, as Python3x cannot read libraries written in 2x. This is mostly academic now, as over the last few years the majority of libraries have now been updated. My recommendation is that you should use Python3x, and only use Python2x if you have a definite need to work with legacy systems.

You can download the main version of Python from www.python.org, including the IDLE shell, which is a programming environment aimed to help you write and run the programs. There are other Python shells out there out there that might offer some advantages to you, and there will be lots of online discussions extoling the various merits of each. You can even write your scripts in Notepad or Notepad++ and run them with a Windows command line if you wish.

Coding with Python There is lots of guidance available on how to write Python programs, including much which is free on the web (https://docs.python.org/3/tutorial/ is a good place to start). Here I will go through a few key points, but I do recommend that you do one of the many excellent courses or books that are out there.

If you are used to programming in other languages, you may note that a main difference between it and other languages is that loops and other relationships are shown by indenting. For example, a FOR/NEXT loop does not include a NEXT, but instead looks something like this:

for row in input_file: input_rows.append(row) Comments always start with a #, so Python will ignore anything you write after one.

Rather than creating Arrays, Python uses Lists, and allows an item in a List to also be a List. In the script below I create a List, where each item is a line from the OD matrix csv. As items in a List are separated by commas, each line becomes its own list, allowing me to pluck individual values out. For example, to retrieve the value from the second column in the third row of the csv I might ask for (as Python always has the first item as zero):

row[2][1] While Python has many commands that you can use, there are modules and libraries available to make your life easier. In our case, we will import the csv module, which enables us to read and write such files without having to do so much coding. We do this with:

import csv Commands using this module start with csv. , such as csv.reader and csv.writer.

Note that for a general program you might want to add in browse dialogs to grab the files and locations, but for something like this I suggest that you just edit the names directly into the script and save the script into the same folder as the files you want to work on.

The Data For this exercise I have created a very simple OD matrix, but the program will work with one of any size:

OD Matrix ExitPortal1 ExitPortal2 ExitPortal3 ExitPortal4 ExitPortal5 ExitPortal6 ExitPortal7

EntryPortal1 0 80 51 0 19 81 7

EntryPortal2 51 10 70 40 110 0 12

EntryPortal3 99 26 20 47 58 39 3

EntryPortal4 39 16 119 0 5 4 75

EntryPortal5 11 44 0 35 10 108 0

EntryPortal6 0 1 115 77 0 21 47

And the end result will look like this:

From To Population Time offset Curve Avatar Profile Init Action Give Tokens

EntryPortal1 ExitPortal2 80 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1

EntryPortal1 ExitPortal3 51 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1

EntryPortal1 ExitPortal5 19 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1

EntryPortal1 ExitPortal6 81 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1

EntryPortal1 ExitPortal7 7 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1

EntryPortal2 ExitPortal1 51 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1



I have only shown the first few lines, just enough to show how it works. The end result has one line per non-zero value in the OD matrix plus the headers. Some items are optional, so for example you might leave the Action column blank if you are not applying any to the agents when they spawn.

As these are csv files the OD matrix (OD_matrix.csv) actually looks like this:

OD Matrix,ExitPortal1,ExitPortal2,ExitPortal3,ExitPortal4,ExitPortal5,ExitPortal6,ExitPortal7 EntryPortal1,0,80,51,0,19,81,7 EntryPortal2,51,10,70,40,110,0,12 EntryPortal3,99,26,20,47,58,39,3 EntryPortal4,39,16,119,0,5,4,75 EntryPortal5,11,44,0,35,10,108,0 EntryPortal6,0,1,115,77,0,21,47 And the results look similar.

The program As you will see, the resultant Python script (OD-schedule.py) is not long and hopefully easy to follow.

# OD matrix to MassMotion Timetable # read OD matrix csv and write Schedule csv import csv # enable the use of csv commands # set up standard values - adjust to suit: offset = 00:00:00 # from start of simulation for start of arrivals (optional) curve = Arrival_curve # defined in Timetable_curve.csv (optional) avatar = Orange_LowPoly # defaul
LINK: http://www.oasys-software.com/blog/2015/04/using-python-scripts-with-m...
See more stories from oasys

Most recent headlines

05/01/2027

Worlds first 802.15.4ab-UWB chip verified by Calterah and Rohde & Schwarz to be demoed at CES 2026

Worlds first 802.15.4ab-UWB chip verified by Calterah and Rohde & Schwarz to be ...

04/08/2026

Dalet Announces Commercial Availability of Dalia, Bringing Media-Aware Agentic AI to Enterprise Productions

Dalet, a leading technology and service provider for media-rich organizations, t...

04/07/2026

Detective Conan: Fallen Angel of the Highway Opens in Dolby Cinemas Across Japan, Presented in Dolby Atmos and Dolby ...

April 7 2026, 19:00 (PDT) Detective Conan: Fallen Angel of the Highway Opens in...

01/06/2026

Dolby Sets the New Standard for Premium Entertainment at CES 2026

January 6 2026, 05:30 (PST) Dolby Sets the New Standard for Premium Entertainment at CES 2026 Throughout the week, Dolby brings to life the latest innovatio...

23/05/2026

FOX Sports, IMS Productions Scale Up Indy 500 Production With New In-Car Cameras, AR Graphics, Cinematic Sets

In its second year as rightsholder, FOX Sports goes bigger across the board for ...

23/05/2026

Inside Apple TVs MLS iPhone Production with Royce Dickerson, Apple Live Sports, Executive Producer

Tonight's MLS matchup between the LA Galaxy and the Houston Dynamo FC will m...

23/05/2026

IK Multimedia reveal ReSing Voices Japanese Pack

AI-powered vocal tool gains first new language expansion IK Multimedia's AI-powered voice-creation software has seen a number of updates since it launch...

23/05/2026

Building a better future: Nielsen celebrates Global Volunteer Month and Earth Day 2026 with record participation

Nielsen Global Leadership Network graduates celebrate Earth Day 2026 Nielsen vo...

23/05/2026

Gray Media Names New Station General Managers

Share Copy link Facebook X Linkedin Bluesky Email...

23/05/2026

New CIMM Paper Urges Industry to Rethink How Media Is Evaluated

Share Copy link Facebook X Linkedin Bluesky Email...

23/05/2026

Lawo to Showcase Edge One, Efficient IP Workflows at InfoComm 2026

Share Copy link Facebook X Linkedin Bluesky Email...

23/05/2026

Spectrum Launches Ultra-Low Latency Internet

Share Copy link Facebook X Linkedin Bluesky Email...

22/05/2026

Germanys Magenta TV Selects DMC to Provide FIFA World Cup Technical Support for Studios in Munich, New York City

Germany's Magenta TV, which will have 44 exclusive FIFA World Cup match broa...

22/05/2026

DAZN Grabs IFAF Flag Football Global Rights

DAZN, the world's leading sports entertainment platform, has acquired global broadcast rights to the International Federation of American Football's ( I...

22/05/2026

ATHLOS 2026 Season Set for October Debut in London; Aurora Media Worldwide Named Host Broadcast Partner

ATHLOS, the all-women's professional track and field league, has announced i...

22/05/2026

NATAS to Stream Sports, News, and Documentary Emmy Awards Live on YouTube

The National Academy of Television Arts & Sciences (NATAS) today announced that the 47th Annual Sports Emmy Awards and the 47th Annual News & Documentary Emmy A...

22/05/2026

Wooden Camera Rolls Out New Blackmagic URSA Accessories

Wooden Camera today announced the release of new accessories for the Blackmagic URSA Cine Immersive. The new lineup includes a redesigned Top Plate and Side Rai...

22/05/2026

YES Network, OTT Advisors Extend Streaming Partnership for Sixth Season

YES Network and OTT Advisors have announced a sixth consecutive season of their streaming partnership, continuing their collaboration on the Gotham app. OTT Adv...

22/05/2026

NESN Monster Week' Returns With Full Red Sox Broadcast From Atop Green Monster

NESN, New England's premier sports network, will again turn its camera to Fe...

22/05/2026

Dale Pro Audio RF Over Fiber Webinar Set for May 28

Dale Pro Audio is hosting an RF over Fiber Livestream Webinar on May 28 from 1-2:30 pm EST. With major sporting events and large-scale productions putting incre...

22/05/2026

Audio-Technica Appoints Humrichouser, Schanz to New Roles

Audio-Technica has announced key leadership appointments designed to further strengthen its sales organization and drive continued growth across the Americas. M...

22/05/2026

Scott Coker Launches Global MMA League With $60 Million in Backing

After nearly four decades shaping the global combat sports landscape, Scott Coker has announced a powerful return as he looks to build a new international mixed...

22/05/2026

Skyline Launches xOps Vanguard Runway for Autonomous Era

Skyline Communications, the company behind the globally deployed DataMiner xOps platform, today announced the launch of xOps Vanguard Runway, a strategic accele...

22/05/2026

The American Rodeo Takes Over Globe Life Field for Championship Weekend

For the fully onsite production, 30 cameras - including a SkyCam and Megalodon - will capture the action in Texas One of the world's biggest rodeo producti...

22/05/2026

Argentinas Torneos Taps Imagine Versio for Playout Operations Upgrade

Leading Argentina-based sports media company Torneos y Competencias S.A. has modernized its playout operations, implementing a fully redundant, multichannel env...

22/05/2026

Owl AI and Major League Pickleball Go Live with First-Ever AI Officiating System Powered by Broadcast Cameras and the Cloud

As the 2026 Major League Pickleball season kicks off this weekend in Dallas, it ...

22/05/2026

Shure, Edge Sound Research Look to Innovate via Partnership

Shure has become a minority investor in Edge Sound Research, a start-up company that is developing new experiential audio technologies that redefine how many au...

22/05/2026

SVG Rewind: MLBs UmpCam AR System Puts Fans Inside the Strike Zone Like Never Before

In advance of this year's Sports Emmy Awards, SVG is taking a deep dive into...

22/05/2026

Jelly Roll Offers Up 2026 Stanley Cup Playoff Theme Song for NHL, Amazon Music

The National Hockey League (NHL) and Amazon Music announced that GRAMMY Award-winning superstar Jelly Roll will provide the official theme song of the 2026 Stan...

22/05/2026

David Pogue, Andy Beach Keynotes Highlight Silicon Valley Video Summer Camp, July 14 at De Anza College

David Pogue will keynote SVV Summer Camp and discuss Apple at 50: How the World...

22/05/2026

FOX Sports, IMS Productions Scale Up Indy 500 Production in Year Two With New In-Car Cameras, AR Graphics, and Cinematic Sets

In its second year as rightsholder, FOX Sports goes bigger across the board for ...

22/05/2026

FOX Sports' Indy 500 Director Mitch Riggin on the Tech and Storytelling for the Greatest Spectacle in Racing

The broadcaster is drawing on lessons learned in its first year of covering the ...

22/05/2026

How Spotify's Rebuilt Ad Platform Is Delivering New Value for Brands

At our 2026 Investor Day, we shared an inside look at the rebuild of our advertising business. This pivot to our own purpose-built platform is already driving s...

22/05/2026

Spotify Levels Up Our Podcast Experience With New Features for Fans and Creators

Podcasting on Spotify continues to grow, and so do the ways listeners engage with it. At Investor Day 2026, we shared how we're building the next chapter of...

22/05/2026

CEDAR Audio introduce Icons Bundles

Limited-time collections now available Restoration experts CEDAR Audio have recently launched a new line of Icons plug-ins that make their powerful processo...

22/05/2026

Boss expand PS-1 Plugout Pedal

Three new classics join Model Pass line-up Boss' PX-1 Plugout Pedal offers an innovative approach to guitar pedals, providing users with a hardware stom...

22/05/2026

SGL Carbon commissions photovoltaic system and lays the foundation for a new nitrogen plant at its Meitingen site

At its Meitingen site, SGL Carbon has implemented two key projects to further de...

22/05/2026

Statement regarding 2026 National NAIDOC Lifetime Achievement Award for the late Rhoda Roberts AO

Statement regarding 2026 National NAIDOC Lifetime Achievement Award for the late...

22/05/2026

Polsat Reclaims Second Place and ByteDance Enters Top 10 as Polish Viewing Moves Beyond the Living Room in April

Latest data reveals steady distributor rankings, a seasonal shift toward digital...

22/05/2026

FCC Votes to Update Disaster Information Reporting System

Share Copy link Facebook X Linkedin Bluesky Email...

22/05/2026

Amagi delivers 30 per cent revenue growth in FY26 Adjuste...

Amagi Media Labs Limited (NSE: AMAGI, BSE: 544679), a cloud-native SaaS platform providing AI-enabled solutions to global media and entertainment companies, tod...

22/05/2026

Annima Post Relies on Cintel to Revive Classic Mexican Films

An nima Post Relies on Cintel to Revive Classic Mexican Films Brie Clayton May 22, 2026 0 Comments Film scanner and DaVinci Resolve Studio help manage...

22/05/2026

Boris FX Sapphire Adds Optical Beauty and Hypnotic Textures

Boris FX Sapphire Adds Optical Beauty and Hypnotic Textures Jessie Electa Petrov May 22, 2026 0 Comments The 2026.5 release introduces advanced defocu...

22/05/2026

Deployment Preserves Trusted Workflows While Enabling a P...

Deployment Preserves Trusted Workflows While Enabling a Path to UHD and SMPTE ST 2110 Leading Argentina-based sports media company Torneos y Competencias S.A....

22/05/2026

Study: AI Labeling Does Not Hurt Video Ad Performance

Share Copy link Facebook X Linkedin Bluesky Email...

22/05/2026

NAB Show Makes 200+ Sessions Available on Demand

Share Copy link Facebook X Linkedin Bluesky Email...

22/05/2026

Torneos Upgrades Multichannel Playout with Imagine's Versio

Share Copy link Facebook X Linkedin Bluesky Email...

22/05/2026

Ex-Husband, Current Husband, One Wild Rescue: Korean Action Comedy Husbands in Action' Premieres June 19

Back to All News Ex-Husband, Current Husband, One Wild Rescue: Korean Action Co...

22/05/2026

Beta Da Silva hosts live performances from 20 new Irish artists in Sessions from Oblivion on 2FM's New Music Show

Catch the latest in Irish music live from venues such as Whelan's, R is n Du...

21/05/2026

CBS Sports Expands WNBA Tip-Off Show To Cover Half of 20-Game, Regular-Season Package

Game Creek Video Columbia and Celtic, NEP Supershooter 8 will house onsite produ...