Skip to main content
Export pedigree data and tensile test results for composite materials, process the data in a pandas DataFrame, and plot summaries of the data (including layup information) using matplotlib and seaborn.

Get data from Granta MI

Connect to Granta MI and specify a database.
Specify the records and attributes you want to export from the first table. We want to use attributes describing the layup for all records in the Composite Pedigree table.
Specify the records you want to export from the second table. Here, a link group is used to export only records linked to records in the first table. Alternatively, you can specify a table with no link groups to the original table, as long as you can join the two datasets later on. For example, we could search for all records created after a certain date, or tested on a certain machine.
Specify the attributes you want to export from the second table. Panel number will be used to relate the tensile tests to the layup data.

Use DataFrames to pre-process and append the data

Build a separate DataFrame for each table

Create a DataFrame for each Granta MI table. The DataFrames are built from two separate lists of dictionaries:
Create a DataFrame pedigree_df that contains the pedigree records. Set the DataFrame index to be the Panel number attribute value and sort by the index.
Ply count Panel thickness, average (measured) Ply thickness, average (measured)
Panel number
LBJ13 6 1.397000 0.232029
LBJ14 6 1.431636 0.238044
LBJ42 6 1.438564 0.240007
LBJ53 6 1.385455 0.231279
LBJ62 6 1.410677 0.234618
Create a second DataFrame tensile_df that contains the tensile test results. Again, set the index to be the Panel number attribute value and sort by both the index and the Specimen ID.
Specimen ID Young’s Modulus (11-axis) Ultimate Tensile Strength Test Type
Panel number
LBJ13 LBJ1311A 47.594514 1582.870937 0° tension
LBJ13 LBJ1312A 47.353197 1542.122918 0° tension
LBJ13 LBJ1313A 47.387671 1612.952766 0° tension
LBJ14 LBJ1413A NaN 1613.614663 0° tension
LBJ14 LBJ1415A NaN 1611.201497 0° tension

Join the dataframes

Use the dataframe.join() method to create a DataFrame with both sets of data. The join type will default to a left-join if not specified; this is fine in our case because the records were linked via a smart link in Granta MI, and so the set of indices is the same for both DataFrames.
Ply count Panel thickness, average (measured) Ply thickness, average (measured) Specimen ID Young’s Modulus (11-axis) Ultimate Tensile Strength Test Type
Panel number
LBJ13 6 1.397000 0.232029 LBJ1311A 47.594514 1582.870937 0° tension
LBJ13 6 1.397000 0.232029 LBJ1312A 47.353197 1542.122918 0° tension
LBJ13 6 1.397000 0.232029 LBJ1313A 47.387671 1612.952766 0° tension
LBJ14 6 1.431636 0.238044 LBJ1413A NaN 1613.614663 0° tension
LBJ14 6 1.431636 0.238044 LBJ1415A NaN 1611.201497 0° tension
Finally, create a units dict so you can create plots with meaningful axis labels.
Previous cell output:

Plot the data

This code snippet is optional, and is included to increase the size of all plots generated in this notebook.

Investigate the relationship between two properties

Create a scatter plot with matplotlib comparing Ultimate Tensile Strength of the panels to Ply thickness, average.
png There is a significant difference between the results at 1200 - 1600 MPa and the group below 100 MPa. We need to identify what causes this difference, and then represent the data in a clearer way.

Investigate the impact of other properties

First, examine the underlying data; use the DataFrame.describe() method to view a statistical summary of the data in each column.
Ply count Panel thickness, average (measured) Ply thickness, average (measured) Specimen ID Young’s Modulus (11-axis) Ultimate Tensile Strength Test Type
count 67.000000 67.000000 67.000000 67 18.000000 67.000000 67
unique NaN NaN NaN 67 NaN NaN 2
top NaN NaN NaN LBJ1311A NaN NaN 0° tension
freq NaN NaN NaN 1 NaN NaN 56
mean 6.492537 1.534167 0.235604 NaN 42.775844 1288.110261 NaN
std 1.119701 0.294450 0.005039 NaN 13.523385 557.743977 NaN
min 6.000000 1.379415 0.229948 NaN 13.217251 44.629768 NaN
25% 6.000000 1.385455 0.231279 NaN 47.022249 1353.613343 NaN
50% 6.000000 1.410677 0.234618 NaN 47.973725 1545.653034 NaN
75% 6.000000 1.438564 0.240007 NaN 49.364743 1603.610369 NaN
max 9.000000 2.213429 0.245727 NaN 51.400420 1639.559637 NaN
The Test Type column summary shows that the most frequent value is ‘0° tension’ (as expected), but there are 9 occurrences of a second test type. To identify all possible values in the Test Type column, use DataFrame["Test Type"].unique().
Previous cell output:
Although there is only one populated attribute for Ultimate Tensile Strength and Young’s modulus, the Test Type column shows that the tensile tests were performed in two different directions. Since composite materials are often highly orthotropic, the direction of the test must be taken into account when plotting the results. We can filter the DataFrame based on the Test Type column when plotting:
png We can also overlay the 90° Ultimate Tensile Strength results, using .twinx() to plot them on a separate y-axis.
png