rfwtools.timestamp.TimestampMapper
- class rfwtools.timestamp.TimestampMapper[source]
Bases:
objectClass for mapping timestamps in Tom’s label files to the timestamp with fractional seconds used elsewhere.
- __init__()
Methods
__init__()get_full_timestamp(zone, dt)Returns the full timestamp based on the supplied zone and timestamp strings.
save_mapper(filename)Method to save the mapper to pickle file.
update_timestamp_map([mapper, begin, end])Creates/replaces a nested dict mapping event timestamps without fractional seconds to those with fractions
- get_full_timestamp(zone, dt)[source]
Returns the full timestamp based on the supplied zone and timestamp strings. Expects label file format
- Parameters:
zone (
str) – The fault event’s zoneformat is CED (e.g., 1L23).dt (
datetime) – The datetime object containing the truncated time. Typical that microseconds = 0 (Tom’s format).
- Returns:
15:30.2”
- Return type:
Standard web-based format timestamp string, e.g., “2019-02-01 01
- save_mapper(filename)[source]
Method to save the mapper to pickle file. Relative to Config().output_dir, unless path is absolute.
- Parameters:
filename (
str) – The name of the file. Relative to Config().output_dir unless path is absolute.- Return type:
None
- static update_timestamp_map(mapper=None, begin='2018-01-01 00:00:00', end=None)[source]
Creates/replaces a nested dict mapping event timestamps without fractional seconds to those with fractions
- Parameters:
mapper (
Optional[Dict[str,Dict[datetime,datetime]]]) – If none, one is generated. Otherwise, the given map replaces the existing one.begin (
str) – What time should the timestamp mapper begin at if a new one is to be generatedend (
Optional[str]) – What time should the timestamp mapper stop at if a new one is to be generated
- Return type:
None