Bug or feature
import pandas as pd
import sys
sys.path.insert(0, 'D:\energylogger_test\pychiver')
from pychiver.calculations import InterpolationStrategy, LinearInterpolationStrategy, LastAcquiredValueInterpolationStrategy
from pychiver.archiver import Archiver
archiver = Archiver()
df_pychiver_1 = archiver.get('DTL-010:RFS-LLRF-101:SPRampingPhase',
start_date="2023-07-10 08:00:00",
end_date="2023-07-10 22:00:00",
max_number_of_hours_back = 72)
print(df_pychiver_1)
When I run that code I get the following values:
{'DTL-010:RFS-LLRF-101:SPRampingPhase': secs val nanos severity status status_label severity_label secs_nanos time time_dt
0 1.689018e+09 -180.00 46266769 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:01.046266769+00:00 2023-07-10 19:40:01.092533+00:00
1 1.689018e+09 -170.00 147920988 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:02.147920988+00:00 2023-07-10 19:40:02.295841+00:00
2 1.689018e+09 -128.12 949004088 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:10.949004088+00:00 2023-07-10 19:40:11.898008+00:00
3 1.689018e+09 -180.00 134362797 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:31.134362797+00:00 2023-07-10 19:40:31.268725+00:00
4 1.689018e+09 -170.00 235830596 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:32.235830596+00:00 2023-07-10 19:40:32.471661+00:00
5 1.689018e+09 -160.00 337826271 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:33.337826271+00:00 2023-07-10 19:40:33.675652+00:00
6 1.689018e+09 -150.00 439509345 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:34.439509345+00:00 2023-07-10 19:40:34.879018+00:00
7 1.689018e+09 -140.00 540831443 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:35.540831443+00:00 2023-07-10 19:40:36.081662+00:00
8 1.689018e+09 -130.00 642699595 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:36.642699595+00:00 2023-07-10 19:40:37.285398+00:00
9 1.689018e+09 -120.00 744019398 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:37.744019398+00:00 2023-07-10 19:40:38.488039+00:00
10 1.689018e+09 -110.00 845293660 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:38.845293660+00:00 2023-07-10 19:40:39.690587+00:00
11 1.689018e+09 -100.00 946645343 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:39.946645343+00:00 2023-07-10 19:40:40.893290+00:00
12 1.689018e+09 -90.00 48194180 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.689018e+09 2023-07-10 19:40:41.048194180+00:00 2023-07-10 19:40:41.096388+00:00
This means I don't know what the value between 08:00 and 19:40. Since the functions does not go back in time and retrieve the last point or an interpolation from the last two points. The max_number_of_hours_back = 72, only goes back in time and searches for values if no data points have been found between the specified start_Date and end_date. Hence, I would like a feature which goes back in time and searches for a value, so I know the value between 08:00 and 19:40.
The other issue. When I run the following code,
import pandas as pd
import sys
sys.path.insert(0, 'D:\energylogger_test\pychiver')
from pychiver.calculations import InterpolationStrategy, LinearInterpolationStrategy, LastAcquiredValueInterpolationStrategy
from pychiver.archiver import Archiver
archiver = Archiver()
df_pychiver_1 = archiver.get('DTL-010:RFS-LLRF-101:SPRampingPhase',
start_date="2023-07-10 08:00:00",
end_date="2023-07-10 22:00:00",
max_number_of_hours_back = 72)
df_pychiver_2 = archiver.get('DTL-010:RFS-LLRF-101:SPRampingPhase',
start_date="2023-07-10 08:00:00",
end_date="2023-07-10 08:10:00",
max_number_of_hours_back = 72)
print(df_pychiver_2)
I get the following values:
{'DTL-010:RFS-LLRF-101:SPRampingPhase': secs val nanos severity status status_label severity_label secs_nanos time time_dt
0 1.688976e+09 -112.0 0 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.688976e+09 2023-07-10 08:00:00+00:00 2023-07-10 08:00:00+00:00
1 1.688977e+09 -112.0 0 0 0 EpicsStatus.NO_ALARM EpicsSeverity.NO_ALARM 1.688977e+09 2023-07-10 08:10:00+00:00 2023-07-10 08:10:00+00:00}
This is a value interpolated from searching after points max_number_of_hours_back = 72. So I assume it interpolates between the two last points it can find 72 h back, meaning interpolation is done between values -36 and -128 which gives -112. I might not want the interpolation value, maybe I want the lastacquired point from archiver which is -128.
Arek, could you take a look at this and see if this is something that can be implemented in pychiver ?