d= First@Import["E:\\Presentations\\BAO\\Amas 21cm\\test1.fits","RawData"];

data = Drop[d[[1]],{1}];

data = Drop[data,-1];

dataLog = Table[{(i/8192)*250+1250, data[[i]]},{i,1,Length[data]}];

ListLinePlot[dataLog,PlotRange->{{1380,1425},{0.99,1.01}},PlotStyle->Red,Frame->True, FrameTicks->{Table[i,{i,1250,1500,5}],Automatic}, GridLines->{Table[{i,Dashed},{i,1250,1500,5}],Automatic}]

dataFreq=Table[{(i/8192)*250+1250,10*Log10[data[[i]]]},{i,1,Length[data]}];

ListLinePlot[dataFreq,PlotRange->{{1400,1450},{-0.02,0.1}},PlotStyle->Red,Frame->True, FrameTicks->{Table[i,{i,1250,1500,5}],Automatic}, GridLines->{Table[{i,Dashed},{i,1250,1500,5}],Automatic}]

ListLinePlot[Table[Apply[Composition,Table[MedianFilter[#,n]&,{1}]][data],{n,{1,2,5}}],PlotStyle->{Blue,Red,Green,Pink,Orange,Black},PlotRange->{{4000,4500},{0.99,1.01}}]

Plot[Re@WaveletPhi[CDFWavelet[],x],{x,-5,5},PlotRange->All]

dwd1 = DiscreteWaveletPacketTransform[data,CDFWavelet[],3];

WaveletScalogram[dwd1,Ticks->Full]

WaveletListPlot[dwd1,ColorFunction->"BlueGreenYellow",Filling->Axis]

dwd1["TreeView"]

dwd1["EnergyFraction"]

ListLinePlot[dwd1[{0,0,0},"Values"][[1]]+dwd1[{0,0,1},"Values"][[1]],PlotRange->Full]

invdwd1 = InverseWaveletTransform[WaveletThreshold[dwd1,{"LargestCoefficients",10}]];

invdwd1[[1]]

dataRec = Table[{(i/8192)*250+1250, 10*Log10[invdwd1[[i]]]},{i,1,Length[data]}];

ListLinePlot[dataRec,PlotRange->{{1400,1450},{-0.02,0.1}},PlotStyle->Red,Frame->True, FrameTicks->{Table[i,{i,1400,1425,5}],Automatic}, GridLines->{Table[{i,Dashed},{i,1250,1500,5}],Automatic}]

ListLinePlot[data-invdwd1,PlotRange->{All,{-0.002,0.001}},PlotStyle->Red,Frame->True, FrameTicks->{Table[i,{i,1400,1425,5}],Automatic}, GridLines->{Table[{i,Dashed},{i,1250,1500,5}],Automatic}]

Apply[Composition,Table[MedianFilter[#,3]&,{2}]][x]

Table[Apply[Composition,Table[MedianFilter[#,n]&,{1}]][x],{n,{1,2,5}}]

Table[Apply[Composition,Table[MedianFilter[#,n]&,{1}]][data],{n,{1,2,5}}]

FindThreshold[data]

ListLinePlot[ClusteringComponents[data,2],PlotRange->{All,All},PlotStyle->Red,Frame->True, FrameTicks->{Table[i,{i,1400,1425,5}],Automatic}, GridLines->{Table[{i,Dashed},{i,1250,1500,5}],Automatic}]

ClusteringComponents[data,10]

x = Array[Subscript[a,#]&,{10}]

y= Array[Subscript[b,#]&,{10}]

FullForm[x+ y]

Table[{x[[i]],y[[i]]},{i,1,Length[x]}]