I have a large collection of data with multi levels. An example of the data (in Association
shape) is here.
The data looks like this:
data = ToExpression[Import["test"]];
data[[;; , ;; 3]]
I am looking for fast way to extract the data from all Keys when the time (the last column) is within certain values.
If you see the following plot, I am looking to extract the data from all Keys within 5 seconds around each peaks when the peaks are above certain values compare to certain Key (say Key "G32" when the values are more than 20).
DateListPlot[data[[;; , ;; 200, {-1, 2}]], PlotRange -> All,
GridLines -> Automatic]
If I choose "G32" as my reference for selection then the time that I need to extract the data around is:
allevents =
First /@ Split[
Select[data[["G32"]], #[[2]] > 20 &], #2[[-1]] - #1[[-1]] < 5 &];
and this result is like this:
DateListPlot[data[[;; , ;; 900, {-1, 2}]], PlotRange -> All,
GridLines -> Automatic,
Epilog -> {PointSize[0.01], Point[allevents[[;; , {-1, 2}]]]}]
What I am facing is the difficulty to efficiently and quickly extract the data around each time of allevents
within 5 seconds. Currently I am using this method but it takes too long:
alleventstime = allevents[[;; , -1]];
AbsoluteTiming[
eventsdata =
Table[Select[#, Abs[#[[-1]] - i] <= 5 &], {i, alleventstime}] & /@
data;]
{252.585, Null}
Part of the result looks like this:
Any idea how can I do that fast. I have tried couple of other methods but no much luck.
Thank you