Skip to main content
Calculate statistical data, such as mean tensile response curves and confidence intervals, from functional data attributes in test records. Import the roll-up data into Granta MI.

Get test data from Granta MI

Connect to Granta MI and specify a database and tables.
Records in these tables are organised by test temperature, so we can fetch all children of a carefully selected folder in Tensile Test Data. Use table.bulk_fetch() to efficiently populate the attributes for each test record and filter out records that do not have values for the attributes required by this analysis.
Create a pandas DataFrame and populate it with data from the functional attribute Tensile Response (11 axis), as well as Specimen ID and Test Temperature. To produce a usable DataFrame, the functional data must:
  1. Have the headers removed
  2. Be converted from a range into a single value

Process the data and calculate statistics

For easier plotting, interpolate each series onto the union of all the parameter values (pandas uses the strain parameter as an index for the union). Any NaN inside the populated area for this column is interpolated by the interpolate() method with limit_area="inside". Group the data by Test Temperature, then use scipy to calculate the 95% confidence intervals by passing the count, mean and standard deviation of the grouped data. Use the .T property to transpose the data frame before the .groupby() operation and after the .count(), .mean(), and .std() operations.
Convert the transformed data into an aggregate DataFrame for plotting and import, taking the minimum, maximum, confidence intervals and mean at each strain value and temperature.
Plot the aggregated data using matplotlib, creating a grid of subplots with identical (shared) axes to easily compare the tensile response at different temperatures.
png

Import roll-up data into Granta MI

Define two helper functions: one that resamples a DataFrame linearly based on a target column’s values, and one that appends a series of range values to a FloatFunctionalAttributeValue, skipping any NaN values. (Although pandas has a built-in resample() function, it only operates on time-series data.)
Import the roll-up data into a Granta MI database. Use path_from() to create a folder path, and then create a statistical data record as a child of the final folder. Populate the Test Temperature and Tensile Response Analysis (11 axis) attributes using the helper functions. Write the new record into a Granta MI database using Session.update(), then link the newly-created attribute to the relevant test results. Finally, write the new links to the Granta MI database using Session.update_links().