ELRMileages.fetch_mileage_file

ELRMileages.fetch_mileage_file(elr, update=False, dump_dir=None, verbose=False)[source]

Fetches the mileage file for the specified ELR.

Parameters:
  • elr (str) – The ELR for which the mileage file is requested (e.g. 'CJD', 'MLA', 'FED').

  • update (bool) – Whether to check for updates to the package data; defaults to False.

  • dump_dir (str | None) – Path to the directory where the data file will be saved; defaults to None.

  • verbose (bool | int) – Whether to print relevant information to the console; defaults to False.

Returns:

A dictionary containing the mileage file (codes), line name and any additional information or notes.

Return type:

dict

Examples:

>>> from pyrcs.line_data import ELRMileages  # from pyrcs import ELRMileages
>>> em = ELRMileages()
>>> # Get the mileage file of 'AAL' (Now 'NAJ3')
>>> aal_mileage_file = em.fetch_mileage_file(elr='AAL')
>>> type(aal_mileage_file)
dict
>>> list(aal_mileage_file.keys())
['ELR', 'Line', 'Sub-Line', 'Mileage', 'Notes', 'Formerly']
>>> aal_mileage_file['ELR']
'NAJ3'
>>> aal_mileage_file['Notes']
'Note that Ashendon Junction up line junction is on NAJ2'
>>> aal_mileage_file['Mileage']
    Mileage Mileage_Note  ... Link_1_ELR Link_1_Mile_Chain
0    0.0000               ...       NAJ2             33.69
1    0.0594               ...        GUA            164.75
2    1.0396               ...
3    3.0682               ...
4    6.0704               ...
5    8.0572               ...        BSG              0.00
6    8.0990               ...        WEJ
7    9.0594               ...
8   13.0264               ...
9   17.0858               ...
10  17.0968               ...
11  18.0572               ...        DCL             81.10
12  18.0638               ...        DCL             81.12
[13 rows x 8 columns]
>>> # Get the mileage file of 'MLA'
>>> mla_mileage_file = em.fetch_mileage_file(elr='MLA')
>>> type(mla_mileage_file)
dict
>>> list(mla_mileage_file.keys())
['ELR', 'Line', 'Sub-Line', 'Mileage', 'Notes']
>>> mla_mileage_file_mileages = mla_mileage_file['Mileage']
>>> type(mla_mileage_file_mileages)
dict
>>> list(mla_mileage_file_mileages.keys())
['Current measure', 'Original measure']
>>> mla_mileage_file_mileages['Original measure']
  Mileage Mileage_Note  ... Link_3_ELR Link_3_Mile_Chain
0  4.1386               ...       NEM4              0.00
1  5.0616               ...
2  5.1122               ...
[3 rows x 14 columns]
>>> mla_mileage_file_mileages['Current measure']
  Mileage Mileage_Note Miles_Chains  ...       Link_1 Link_1_ELR Link_1_Mile_Chain
0  0.0000                      0.00  ...  MRL2 (4.44)       MRL2              4.44
1  0.0572                      0.26  ...         None
2  0.1540                      0.70  ...         None
3  0.1606                      0.73  ...         None
[4 rows x 8 columns]
>>> # Get the mileage file of 'LCG'
>>> mla_mileage_file = em.fetch_mileage_file(elr='LCG')