Electrification.collect_national_network_codes

Electrification.collect_national_network_codes(confirmation_required=True, verbose=False, raise_error=False)[source]

Collect the section codes for Overhead Line Electrification (OLE) installations for the national network from the source web page.

Parameters:
  • confirmation_required (bool) – Whether user confirmation is required; if confirmation_required=True (default), prompts the user for confirmation before proceeding with data collection.

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

  • raise_error (bool) – Whether to raise the provided exception; if raise_error=False (default), the error will be suppressed.

Returns:

A dictionary of OLE section codes for the national network, or None if not applicable.

Return type:

dict | None

Examples:

>>> from pyrcs.line_data import Electrification  # from pyrcs import Electrification

>>> elec = Electrification()

>>> nn_codes = elec.collect_national_network_codes(verbose=True)
Proceed with collecting section codes for OLE installations: "National network"?
 [No]|Yes: yes
Collecting the data ... Done.

>>> type(nn_codes)
dict
>>> list(nn_codes.keys())
['National network', 'Last updated date']

>>> nn_codes_dat = nn_codes['National network']  # elec.KEY_TO_NATIONAL_NETWORK
>>> type(nn_codes_dat)
dict
>>> list(nn_codes_dat.keys())
['Traditional numbering system [distance and sequence]',
 'New numbering system [km and decimal]',
 'Codes not certain [confirmation is welcome]',
 'Suspicious data',
 'An odd one to complete the record',
 'LBSC/Southern Railway overhead system',
 'Codes not known']

>>> tns_codes = nn_codes_dat['Traditional numbering system [distance and sequence]']
>>> type(tns_codes)
dict
>>> list(tns_codes.keys())
['Codes', 'Notes']

>>> tns_codes_dat = tns_codes['Codes']
>>> tns_codes_dat.shape
(577, 5)
>>> tns_codes_dat.head()
  Code  ...                                               Note
0    A  ...
1    A  ...  Only a short length at Newbridge Junction wire...
2    A  ...
3    A  ...  Former DC system, now closed; it appears that ...
4   AB  ...              Reported, probably never used.  See F
[5 rows x 5 columns]