# How to extract the first dimension in TimeSeries?

I want to extract the first dimension in TimeSeries，for example:

So I use this code:

data = Normal@AudioLocalMeasurements[ExampleData[{"Audio", "PianoScale"}],"MFCC"];


But it is a little complex,I want to know if there is more gentle way to do it?

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"} *)


The more elegant way:

In[15]:= ts =
AudioLocalMeasurements[ExampleData[{"Audio", "PianoScale"}], "MFCC"];

In[21]:= first = ts["PathComponent", {1}];

In[25]:= data = Normal[ts];

In[26]:= Thread[{data[[All, 1]], data[[All, 2, {1}]]}] == (first[
"Path"])

Out[26]= True


Or without creating vector values:

In[15]:= ts =
AudioLocalMeasurements[ExampleData[{"Audio", "PianoScale"}], "MFCC"];

In[27]:= first = ts["PathComponent", 1];

In[28]:= data = Normal[ts];

In[29]:= Thread[{data[[All, 1]], data[[All, 2, 1]]}] == (first["Path"])

Out[29]= True

• (Tip: If you set SetOptions[\$FrontEnd, ExportMultipleCellsOptions -> {"IncludeCellLabels" -> False}], then the pesky In[]/Out[] labels won't be copied. It will make it easier for others to test and use your code.) Nov 30, 2016 at 0:53
• what is PathComponent.I can not find it in doc Nov 30, 2016 at 14:29
• td = TemporalData[Array[x, {10, 2}], {0}, ValueDimensions -> 2]; td["DeveloperProperties"] Dec 1, 2016 at 16:49