How to uniquely identify a train?

1,087 views
Skip to first unread message

Mark Waldron

unread,
Sep 11, 2013, 10:19:44 AM9/11/13
to openrail...@googlegroups.com
Hi,

I am looking at the train movement data and want to organise it somewhat in order to search through it easier. 

I want to be able to group together all the messages that belong to a specific journey. My immediate thought was to group the messages together using the train_id. However, this id looks to be some kind of concatenation of coded info that may or may not be unique over time. Does anyone know the format of this id? Can I assume that it will remain unique? IE. could a different train (perhaps on a different date) reuse a previously used train_id?


The other alternative would be the train_service_code. This is documented as:
train_service_codeTrain service code as per schedule
It is documented in the SCHEDULE docs as:
CIF_train_service_codeDivides trains into service groups and used for revenue reasons
I am not sure what any of that means, it doesn't explain a lot, and does not explain what a 'service group' is. I guess maybe used for auditing in some way? Could this be unique across all journeys?


Maybe a combination of train_id and train_service_code?

Or perhaps:

a combination of date and train_id?


If anyone has more info about these codes that would help me immensely and enable me to make a decision.

Cheers,

Mark

Stuart Bridger

unread,
Sep 11, 2013, 10:30:38 AM9/11/13
to Mark Waldron, openrail...@googlegroups.com
The train_id is a concatenation of other fields;
 
i.e. 721N09MC11
 
72           - first two digits of origin stanox (72410 in this case)
1N09      - headcode
11           - day of the month
 
Not sure what the MC refers to.
 
I believe this should be unique in any one month.

--
You received this message because you are subscribed to the Google Groups "A gathering place for the Open Rail Data community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openraildata-t...@googlegroups.com.
To post to this group, send an email to openrail...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Mark Waldron

unread,
Sep 11, 2013, 10:55:42 AM9/11/13
to openrail...@googlegroups.com, Mark Waldron
Cheers Stuart, that helps alot.

I have heard the term 'headcode' referenced a lot in the docs. I know that it identified the train in some way but dont know what it actually means. Does it identify a physical train?

Cheers,

Mark

Stuart Bridger

unread,
Sep 11, 2013, 11:06:48 AM9/11/13
to Mark Waldron, openrail...@googlegroups.com
The headcode is generally how a train is referenced on the railway  i.e. when signallers / controllers / platform staff are talking they will use the headcode.
 
The headcode is usually unique for each operator on each day, but they will generally repeat day-to-day for the same service.
 
So 1U24 might be the London Midland 09:28 London Euston to Crewe and will be the same Monday to Friday.
 
The first digit is the class   1 = express  2 = local  5 = freight
The second letter will generally be the same for a specific route, so Euston to Crewe might be 'U' and Northampton to Birmingham might be 'N'.
The last two digits are incremental, so if the 09:28 is 24, then the 09:58 would be 25., etc...
 
This is a very general overview and each operator will have their own way of doing things. Special services and freight will be different again.

Stuart Bridger

unread,
Sep 11, 2013, 11:09:09 AM9/11/13
to Mark Waldron, openrail...@googlegroups.com
Lots more useful information on the wiki...
 

Mark Waldron

unread,
Sep 11, 2013, 11:37:07 AM9/11/13
to openrail...@googlegroups.com, Mark Waldron
Thats great info. Thanks Stuart.

The headcode formed like that means that it will be unique within a single day. With the train_id including the day of month we will have uniqueness for a given month. If I manually add the current month and year then I can guarantee uniqueness across all time. I will need to be careful with journeys that span over the month end but that can be worked around.

Much Appreciated,

Mark

Chris Northwood

unread,
Sep 11, 2013, 12:52:06 PM9/11/13
to openraildata-talk
Sadly no, the headcode isn't unique. It's unique per signalling area, but a train in the south-east and Glasgow could have the same headcodes, e.g., http://www.opentraintimes.com/search/by_headcode/1A32/2013-09-11

Peter Hicks

unread,
Sep 11, 2013, 1:57:25 PM9/11/13
to Chris Northwood, openraildata-talk

On 11 Sep 2013, at 17:52, Chris Northwood <cnort...@gmail.com> wrote:

Sadly no, the headcode isn't unique. It's unique per signalling area, but a train in the south-east and Glasgow could have the same headcodes, e.g., http://www.opentraintimes.com/search/by_headcode/1A32/2013-09-11

It's planned to be unique per signalling area (supposedly) within 'n' hours - I've heard six, but it can be less.  

Take Stourbridge Town as an example - http://www.opentraintimes.com/location/SBT/2013-09-11/0000-2359 - it has three 2P01s during the day - 0550, 1412 and 2232 arrivals from Stourbridge Junction.

The extra digits TRUST appends guarantee the TRUST ID for a train will be unique over a calendar month.  I can't think of another way to do it that isn't equally as laced with domain knowledge!


Peter


Mark Waldron

unread,
Sep 12, 2013, 4:21:36 AM9/12/13
to openrail...@googlegroups.com, Chris Northwood
The 2P01 headcode highlight this no uniqueness issue very well. The trains are thus:

2P01P35595WTTC05:47 Stourbridge Junction - Stourbridge TownLondon Midland
2P01P35596WTTC14:09 Stourbridge Junction - Stourbridge TownLondon Midland
2P01P35598WTTC22:29 Stourbridge Junction - Stourbridge TownLondon Midland
If all these are starting from the same place and the TRUST train_id is formatted as per Stuart Bridger's comment above:

i.e. 721N09MC11
 
72           - first two digits of origin stanox (72410 in this case)
1N09      - headcode
11           - day of the month

..then we will have (potentially) the same train_id for multiple trains on the same day.

If Peters comment hold true:

The extra digits TRUST appends guarantee the TRUST ID for a train will be unique over a calendar month.

I guess that the extra couple of digits in the train_id (MC in the above example) must be there to guarantee the uniqueness for the day. Either that or they specify something unknown that make the uniqueness of this id for the day hold true.

If I can rely on the fact that the TRUST train_id is unique within a given day then I have a way forward.

Peter - how do you know this stuff, I cant find anything in the online docs that discuss the TRUST train_id in any detail.


Thanks for all your helps,

Mark

Peter Hicks

unread,
Sep 12, 2013, 5:33:46 AM9/12/13
to Mark Waldron, openrail...@googlegroups.com, Chris Northwood
Hi Mark

On 12 Sep 2013, at 09:21, Mark Waldron <ma...@undercovermonkey.co.uk> wrote:

If all these are starting from the same place and the TRUST train_id is formatted as per Stuart Bridger's comment above:

i.e. 721N09MC11
 
72           - first two digits of origin stanox (72410 in this case)
1N09      - headcode
11           - day of the month

..then we will have (potentially) the same train_id for multiple trains on the same day.

If Peters comment hold true:

The extra digits TRUST appends guarantee the TRUST ID for a train will be unique over a calendar month.

I guess that the extra couple of digits in the train_id (MC in the above example) must be there to guarantee the uniqueness for the day. Either that or they specify something unknown that make the uniqueness of this id for the day hold true.

I thought the format was already documented, but it appears it wasn't... I've updated http://nrodwiki.rockshore.net/index.php/Train_Activation with fuller details of the composition of the train ID, in particular the TSPEED and Call Code fields.

If I can rely on the fact that the TRUST train_id is unique within a given day then I have a way forward.

I've only seen one example where this isn't guaranteed unique, but it's rather vague - I can dig out details if you need them.


Peter - how do you know this stuff, I cant find anything in the online docs that discuss the TRUST train_id in any detail.

It's my job to know :-)   I've been doing Open Data work for Network Rail since the start of the year, working with the real-time feeds for two and a half years (prior to them becoming open), and I'm busy working on a number of other rail-related consultancy projects at the moment.


Peter


Mark Waldron

unread,
Sep 12, 2013, 5:58:00 AM9/12/13
to openrail...@googlegroups.com, Mark Waldron, Chris Northwood

I thought the format was already documented, but it appears it wasn't... I've updated http://nrodwiki.rockshore.net/index.php/Train_Activation with fuller details of the composition of the train ID, in particular the TSPEED and Call Code fields.


Thats really cool, thank you very much. :-)
 
If I can rely on the fact that the TRUST train_id is unique within a given day then I have a way forward.

I've only seen one example where this isn't guaranteed unique, but it's rather vague - I can dig out details if you need them.


If you have the time I would be interested, but by the sound of it I think the train_id with a month and year appended would be accurate enough for my requirements. I did think that maybe the train_service_code may be useful, am I way off mark here?
Peter - how do you know this stuff, I cant find anything in the online docs that discuss the TRUST train_id in any detail.

It's my job to know :-)   I've been doing Open Data work for Network Rail since the start of the year, working with the real-time feeds for two and a half years (prior to them becoming open), and I'm busy working on a number of other rail-related consultancy projects at the moment.

 
 You are indeed a good man to know in this sphere :-)

Thanks for all your help. 

Jiang Li

unread,
Sep 23, 2013, 2:07:51 AM9/23/13
to openrail...@googlegroups.com, Chris Northwood
Hi Peter,

The three services in your example don't overlap. Can I say the services with the same head code won't run at the same time? Thanks.

Cheers,
Jiang 

Peter Hicks

unread,
Sep 23, 2013, 4:24:54 AM9/23/13
to openrail...@googlegroups.com
On 23/09/13 07:07, Jiang Li wrote:
> The three services in your example don't overlap. Can I say the
> services with the same head code won't run at the same time? Thanks.
No - there may be a 1C01 running in two parts of the country at the same
time.


Peter

Jiang Li

unread,
Sep 23, 2013, 6:48:48 PM9/23/13
to openrail...@googlegroups.com
Thanks Peter.
Reply all
Reply to author
Forward
0 new messages