HabdWild.collect_codes

HabdWild.collect_codes(confirmation_required=True, verbose=False, raise_error=False)[source]

Collect codes of HABDs and WILDs from the source web page.

Note

  • HABDs: Hot axle box detectors

  • WILDs: Wheel impact load detectors

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 containing the codes of HABDs and WILDs and the date they were last updated, or None if no data is collected.

Return type:

dict | None

Examples:

>>> from pyrcs.other_assets import HabdWild  # from pyrcs import HABDWILD

>>> hw = HabdWild()

>>> hw_codes = hw.collect_codes(verbose=True)
Proceed with collecting data of "HABD and WILD"?
 [No]|Yes: yes
Collecting the data ... Done.

>>> type(hw_codes)
dict
>>> list(hw_codes)
['HABD and WILD', 'Last updated date']

>>> hw_codes_dat = hw_codes['HABD and WILD']
>>> type(hw_codes_dat)
dict
>>> list(hw_codes_dat)
['HABD', 'WILD']

>>> habd_dat = hw_codes_dat['HABD']
>>> type(habd_dat)
pandas.DataFrame
>>> habd_dat.shape
(241, 5)
>>> habd_dat.head()
    ELR  ...                                              Notes
0  BAG2  ...
1  BAG2  ...  installed 29 September 1997, later moved to 74...
2  BAG2  ...                             previously at 74m 51ch
3  BAG2  ...                          removed 29 September 1997
4  BAG2  ...           present in 1969, later moved to 89m 00ch
[5 rows x 5 columns]

>>> wild_dat = hw_codes_dat['WILD']
>>> type(wild_dat)
pandas.DataFrame
>>> wild_dat.shape
(47, 5)
>>> wild_dat.head()
    ELR  ...                                              Notes
0  AYR3  ...
1  BAG2  ...
2  BML1  ...
3  BML1  ...      removed 20 March 2023 / removed 20 March 2023
4  BML1  ...  brought into use 1 May 2023, delayed from 20 M...
[5 rows x 5 columns]