Averaging in each X;Y by K lines and writing to new variable

Moderators: davetaflin, salter, steve, jprenaud, straton, Chris Idso

Svetlana
Expert
Posts: 93
Joined: Sun Dec 22, 2013 3:08 pm
Location: Australia
Contact:

Averaging in each X;Y by K lines and writing to new variable

Postby Svetlana » Thu Dec 26, 2013 7:54 pm

My data has 3 variables, X, Y, TIME, with I, J, and K indicated for them once only for a single zone; and a single T variable for each such point. An example file as follows:

Code: Select all

VARIABLES = TIME,Y,X, T
1,1,1,300
...
1.04,19,9,300.249
1.04,19,10,300.249
1.04,20,1,300.249
1.04,20,2,300.249
1.04,20,3,300.249
...


You can generate it using MATLAB code, then add the header manually:

Code: Select all

fid = fopen('example.dat','w')
for time=1:0.01:2
for j=1:1:20
for i=1:1:10
fprintf(fid,strcat(num2str(time), ",", num2str(j), ",", num2str(i), ",", num2str(300+sin(2*pi*time)),"\r\n"))
end
end
end



I would like to average T in each (X; Y) point by TIME and save the result to a new variable.

I understand this may be partially done by Analyzer > Integration > Average ("Average variable T by Zones by K lines with all 3 indices set from 1 to Mx"), but it only outputs a list of values and doesn't write it to a variable.

I am doing this because I would like to do Fourier transform on the data but it appears to work better on variables fluctuating around 0, not around 300.

(I am not using SolutionTime for each time because when I do it, the Data > Fourier transform dialog does not have SolutionTime listed as the independent variable.)

straton
Jedi Master
Posts: 45
Joined: Tue Jul 26, 2011 7:38 am
Location: Bellevue, Washington
Contact:

Re: Averaging in each X;Y by K lines and writing to new vari

Postby straton » Fri Dec 27, 2013 1:09 pm

Svetlana, as long as you have a zone for each time step, and your grid is the same for all your zones, you could write a Tecplot macro to loop through all your zones to: (a) create a sum for your variable (e.g. V3[index]), then after the loop (b) divide by the total number of zones for the average.

If you need further assistance, and have current Tecplot SMS (Software Maintenance Service), please contact your Tecplot distributor:

http://www.tecplot.com/distributors/

Thank you.
Straton Spyropoulos

Svetlana
Expert
Posts: 93
Joined: Sun Dec 22, 2013 3:08 pm
Location: Australia
Contact:

Re: Averaging in each X;Y by K lines and writing to new vari

Postby Svetlana » Fri Dec 27, 2013 5:37 pm

Thanks. Such approach appears to need something capable of assigning to a variable with index, eg VAR3[I,J]=... . I could not find that in examples. Don't know whether the university license has SMS.

Svetlana
Expert
Posts: 93
Joined: Sun Dec 22, 2013 3:08 pm
Location: Australia
Contact:

Re: Averaging in each X;Y by K lines and writing to new vari

Postby Svetlana » Thu Jan 09, 2014 2:33 pm

I now use stats addon. I then use the separate zones - one for each point in space - for Fourier transform on each such point individually.


Return to “Loading Data”

Who is online

Users browsing this forum: No registered users and 1 guest

cron