How to extract the first dimension in TimeSeries?
You can also use TimeSeriesMap
or MapAt
:
audio = AudioLocalMeasurements[ExampleData[{"Audio", "PianoScale"}],"MFCC"];
res0 = TimeSeriesMap[{First@#}&, audio]["Path"];
res1 = MapAt[{First@#}&, audio["Path"],{{All,2}}];
res0 == res1 == res
True
You can use the "Properties"
specification of a TimeSeries
, as introduced in the Details section of its reference page. This avoids normalizing it.
For instance, with the properties "Times"
and "Values"
:
audio = AudioLocalMeasurements[ExampleData[{"Audio", "PianoScale"}], "MFCC"];
res = Transpose[{audio["Times"], audio["Values"][[All, {1}]]}];
The symbol res
gives the expected output:
data = Normal@audio;
res === Thread[{data[[All, 1]], data[[All, 2, {1}]]}]
(* True *)
Alternatively, you can use the property "Path"
. Here is a possible way:
resBis = {#1, {#2[[1]]}} & @@@ audio["Path"];
resBis === res
(* True *)
Note that other objects of the language accept the "Properties"
specification, once they are constructed through evaluation. These include SparseArray
and QuantityArray
:
spa = SparseArray[Range[10]];
spa["Properties"]
(* {"AdjacencyLists", "Background", "ColumnIndices", "Density", "MatrixColumns",
"NonzeroValues", "PatternArray", "Properties", "RowPointers"} *)
qa = QuantityArray[Range[10], "Meters"];
qa["Properties"]
(* {"Data", "Properties", "Structure"} *)
The specification "Methods"
can also be used for these two last:
spa["Methods"]
(* {"AdjacencyLists", "Background", "ColumnIndices", "Density", "MatrixColumns",
"MethodInformation", "Methods", "NonzeroPositions", "NonzeroValues", "PatternArray",
"Properties", "RowPointers"} *)
qa["Methods"]
(* {"Data", "MethodInformation", "Methods", "Properties", "Structure"} *)