Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining multiple XY reports into excel worksheet

Status
Not open for further replies.

A.Jalal

Mechanical
Dec 8, 2017
4
Hello All

I am using a python script to post-process some data from a pipe span analysis using Abaqus 2016.

After I run the analysis, I submit a python script to extract multiple mode shapes of pipe vibrations based on the number of frequencies the user inputs. In the script I generate an XY report for every frame after extracting the desired field output (each frame represents a mode shape).

Python:
x0= session.xyDataObjects['IL-'+str(FrameCount)]
session.xyReportOptions.setValues(numDigits=5)
session.writeXYReport(fileName='IL-'+str(FrameCount)+'.xls', appendMode=OFF, xyData=(x0, ))

The FrameCount variable is a counter.

With the current script a lot of excel sheets are generated and the user has to manually look into each one.

Is it possible to merge all the data in excel such that there is only 1 column representing the X values (pipe length) and multiple columns representing the different Y-values (displacements)?

Thank you
 
Replies continue below

Recommended for you

Hi
Make you own report by script and save it in one file
 
Hello

Can you explain a little more what you mean?

If I save all the generated XY plots in 1 report or excel worksheet, the X values are repeated because they do not change. I want to have only 1 set of X values for multiple Y values.
 
Hello
I mean that you can get all data you need from odb and save them in array,after this you can save array to excel file
 
For a good sugestion it is necessary to know more about the problem.

You have one xy-plot per result frame, right? What data is on the two axis of that plot and how are the xy data generated?
What is the final goal - what do you want to have at the end in excel?
 
Thanks for the reply Mustaine3.

For this case. I have 2 xy-plots per result frame (x-coordinate vs. displacement) and (x-coordinate vs. contact pressure). That means for every result frame, I am having 2 output i.e. if I have 40 frames, the script will output 80 excel files. The x values for all the frame outputs of a certain xy-plot are the same (x-ccordinate) but the y values change.

The code section below is how I generate the data:

Python:
pth = session.Path(name='Path-1', type=NODE_LIST, expression=(('PART-1-1', ('1:401:1', )), ))

FramesNumber = len(odb_dynamic_IL.steps.values()[2].frames)

for FrameCount in range(FramesNumber):
	session.viewports['Viewport: 1'].odbDisplay.setPrimaryVariable(variableLabel='U', outputPosition=NODAL, refinement=(COMPONENT, 'U2'))
	session.viewports['Viewport: 1'].odbDisplay.setFrame(step=2, frame=FrameCount)
	session.XYDataFromPath(name='IL-'+str(FrameCount), path=pth, includeIntersections=False, shape=DEFORMED, labelType=X_COORDINATE)
	x0= session.xyDataObjects['IL-'+str(FrameCount)]
	session.xyReportOptions.setValues(numDigits=5)
	session.writeXYReport(fileName='IL-'+str(FrameCount)+'.xls', appendMode=OFF, xyData=(x0, ))

The final goal is to have only 2 output excel files regardelss of the number of frames I have.

I just want to be able to view all the results for a specific field output in a single excel file where 1 column represents the x-coordinate and the other columns correspond to each frame's filed output.

I hope this clarified my question.
 
Hi
Here attached I`m sending you my script which save history output of displacements to file. Hope this helps.
Python:
from odbAccess import *
odb = openOdb(path='Job-0.odb')
steps = odb.steps	#Repository
flag = -1
Us = []
Uk = ['StepName']
for stepKey in steps.keys():
	flag += 1
	step = steps[stepKey]
	regions = step.historyRegions
	Ur = [stepKey]
	for regionKey in regions.keys():
		region = regions[regionKey]
		outputs = region.historyOutputs
		if 'U1' in outputs.keys():
			if flag == 0:
				Uk.append(regionKey)
			U1 = "{:.1f}".format(outputs['U1'].data[1][1])
			U2 = "{:.1f}".format(outputs['U2'].data[1][1])
			U3 = "{:.1f}".format(outputs['U3'].data[1][1])
			Ur.append(U1+','+U2+','+U3)
	if flag == 0:
		Us.append(Uk)
	Us.append(Ur)
rptfile = open('UTdata.rpt','w')
for line in Us:
	rptline = '\t'.join(line)+'\n'
	rptfile.writelines(rptline)
rptfile.close()
 
@Igor76
The path plots are not stored in the odb. They are created in A/CAE and session objects.


@A.Jalal
In your code you save each curve in x0. Just access those data and write in a way you want into a .csv file. Afterwards you just have to open that file in Excel.

Just look at x0 and you'll see that it is a simple list with a tuple for each data point.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor