PowerSystems.jl icon indicating copy to clipboard operation
PowerSystems.jl copied to clipboard

Adding warnings to time series parsing non-supported timestamp format

Open sourabhdalvi opened this issue 1 year ago • 2 comments

I encountered an error with timestamp parsing where the format was 2012-01-06 08:00:00 instead of the expected 2012-01-06T08:00:00. Interestingly, the parsing process didn't fail but instead replaced the timestamps with today's datetime.

julia> get_time_series_array(SingleTimeSeries, hy, "max_activate_power")
8760×1 TimeSeries.TimeArray{Float64, 1, DateTime, Vector{Float64}} 2023-11-21T00:00:00 to 2024-11-19T23:00:00
│                     │ A      │
├─────────────────────┼────────┤
│ 2023-11-21T00:00:00 │ 0.9473 │
│ 2023-11-21T01:00:00 │ 0.9473 │
│ 2023-11-21T02:00:00 │ 0.9473 │
│ 2023-11-21T03:00:00 │ 0.9473 │
│ 2023-11-21T04:00:00 │ 0.9473 │
│ 2023-11-21T05:00:00 │ 0.9473 │
│ 2023-11-21T06:00:00 │ 0.9473 │
│ 2023-11-21T07:00:00 │ 0.9473 │
│ 2023-11-21T08:00:00 │ 0.9473 │

This led to an issue when running transform_single_time_series!(sys, 24, Hour(24)), where the system threw an error due to the timestamps not aligning.

julia> transform_single_time_series!(sys, 24, Hour(24))
ERROR: InfrastructureSystems.ConflictingInputsError("forecast initial_timestamp 2023-11-21T00:00:00 does not match system initial_timestamp 2012-01-01T00:00:00")
Stacktrace:

It would be helpful to have an error or warning when parsing encounters a timestamp format that is not supported.

sourabhdalvi avatar Nov 21 '23 22:11 sourabhdalvi

This is an interesting bug. Unexpected behavior

jd-lara avatar Nov 21 '23 22:11 jd-lara

I tried to reproduce this issue by injecting bad strings in this InfrastructureSystems test file, which is used by this test. All attempts resulted in this error:

ArgumentError: Invalid DateTime string
DateTime,values,bus2,bus3,bus4
2020-01-01 00:00:00
DateTime,values,bus2,bus3,bus4
2020-01-01 T00:00:00

I also tried both of those with microseconds, as in 2020-01-01 T00:00:00.0.

I’m testing with julia version 1.10.2. I’ll need some help reproducing this.

daniel-thom avatar Mar 19 '24 01:03 daniel-thom

close as it is stale and couldn't be reproduced

jd-lara avatar May 15 '24 14:05 jd-lara