Re: CONDITION/DATA ANALYSIS/PLOTS
- To: mathgroup at smc.vnet.net
- Subject: [mg107892] Re: CONDITION/DATA ANALYSIS/PLOTS
- From: jihane <jihane.ajaja at mail.mcgill.ca>
- Date: Tue, 2 Mar 2010 03:36:31 -0500 (EST)
Mr hanlon:
thank you very much for the help.
I tried to implement this in my code but i didn't succeed. If you would like to check my code and perhaps indicate to me how i could implement it in my code I would really appreciate:
<< PlotLegends`
(* Change Flight number in labelling *)
SetDirectory[NotebookDirectory[]];
cutOffFreq = 20;
fileTime = 85;
(**********************USER INPUT***********************************)
\
(*Specify column numbers within text file to be extracted*)
fineTimeCol = 1;
X0Col = 6;
Y0Col = 7;
Z0Col = 8;
(*Total number of columns in the text file*)
numberOfColumns = 12;
(*For RMS plots*)
(*Specify how often to calculate RMS values; i.e. every ___ seconds*)
\
RMSseconds = 1;
(*For PSD plots*)
(*Choose how often to integrate PSD plots to find RMS contribution*)
\
fileTime = 85;
numSeconds = 60;
RawDataPlots = True;
(********************************************************************)
(*The samples are collected at 32Hz for a85 minute file*)
sampleFreq = 32;
(*Read data from file*)
data = Import["UofT_Nanowire_Flight1 - Copy.dat"];
listOfZeroes = Table[0, {i, numberOfColumns}];
(*Specify which columns to read*)
td = ReplacePart[listOfZeroes, fineTimeCol -> 1];
x0d = ReplacePart[listOfZeroes, X0Col -> 1];
y0d = ReplacePart[listOfZeroes, Y0Col -> 1];
z0d = ReplacePart[listOfZeroes, Z0Col -> 1];
(*Split data into appropriate columns, drop "EndOfFile" at the end of \
the list*)
X0D = Drop[data.x0d, -1];
Y0D = Drop[data.y0d, -1];
Z0D = Drop[data.z0d, -1];
(********************************************************************************************************************)
\
(*Start analysis for each group of X, Y, Z*)
(********************************************************************************************************************)
(*Assign the X, Y, Z lists*)
XD = X0D;
YD = Y0D;
ZD = Z0D;
XDNew = {};
YDNew = {};
ZDNew = {};
LZ = Length[ZD];
For[j = 1, j <= LZ, j++;
If[ZD[[j]] < 0.05, ZDNew = Append[ZDNew, ZD[[j]]];
XDNew = Append[XDNew, XD[[j]]]; YDNew = Append[YDNew, YD[[j]]]];
];
(*xMean= mean of raw data rounded to 6 decimal places*)
xMean = N[Mean[XD], 6];
yMean = N[Mean[YD], 6];
zMean = N[Mean[ZD], 6];
xMeanNew = N[Mean[XDNew], 6];
yMeanNew = N[Mean[YDNew], 6];
zMeanNew = N[Mean[ZDNew], 6];
(*Demean the raw data*)
XDemeaned = XD - xMean;
YDemeaned = YD - yMean;
ZDemeaned = ZD - zMean;
XDemeanedNew = XDNew - xMeanNew;
YDemeanedNew = YDNew - yMeanNew;
ZDemeanedNew = ZDNew - zMeanNew;
(*Create list of course time based on number of data points and \
sample frequency*)
TD = (Range[Length[XD]] - 1)/sampleFreq;
TDNew = (Range[Length[ZDNew]] - 1)/sampleFreq;
(*Time interval*)
dt = TD[[2]] - TD[[1]];
dtNew = TDNew[[2]] - TDNew[[1]];
(******************Raw Data Plots************************************)
(*Plot raw data plots if specified*)
If[RawDataPlots,
(* 'time' is a list of numbers representing the time at which each \
data point was collected *)
time = TD/60;
timeNew = TDNew/60;
(* 'XDV' is a two dimensional list represengting the voltage \
measurements versus time *)
XDV = Transpose[{time, XD}];
YDV = Transpose[{time, YD}];
ZDV = Transpose[{time, ZD}];
XDVNew = Transpose[{timeNew, XDNew}];
YDVNew = Transpose[{timeNew, YDNew}];
ZDVNew = Transpose[{timeNew, ZDNew}];
(* The following exports plots of the acceleration data for each \
axis into the folder specified at the beginning of this file *)
xName = "X-Axis Accelerometer Measurement.gif";
yName = "Y-Axis Accelerometer Measurement.gif" ;
zName = "Z-Axis Accelerometer Measurement.gif";
xOut = StringForm["X-Axis Accelerometer Measurement - Flight 1"];
yOut = StringForm["Y-Axis Accelerometer Measurement - Flight 1"];
zOut = StringForm["Z-Axis Accelerometer Measurement - Flight 1"];
Export[xName,
Framed[ListLinePlot[XDVNew, PlotRange -> All,
PlotLabel -> Style[xOut, 20], Frame -> True,
FrameLabel -> {"Time (min)",
"Measured Acceleration (g/\!\(\*SubscriptBox[\"g\", \
\"0\"]\))"}, LabelStyle -> Directive[15], ImageSize -> Scaled[1],
Axes -> False]]];
Export[yName,
Framed[ListLinePlot[YDVNew, PlotRange -> All,
PlotLabel -> Style[yOut, 20], Frame -> True,
FrameLabel -> {"Time (min)",
"Measured Acceleration (g/\!\(\*SubscriptBox[\"g\", \
\"0\"]\))"}, LabelStyle -> Directive[15], ImageSize -> Scaled[1],
Axes -> False]]];
Export[zName,
Framed[ListLinePlot[ZDVNew, PlotRange -> All,
PlotLabel -> Style[zOut, 20], Frame -> True,
FrameLabel -> {"Time (min)",
"Measured Acceleration (g/\!\(\*SubscriptBox[\"g\", \
\"0\"]\))"}, LabelStyle -> Directive[15], ImageSize -> Scaled[1],
Axes -> False]]];
];