An open-data initiative
%matplotlib inline
# interactictive plots
# %matplotlib notebook
%config InlineBackend.figure_formats = {'png', 'retina'}
# Utilized to create and work with dataframes
import pandas as pd
import numpy as np
import math as m
# MATPLOTLIB
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.colors as mcolors
from matplotlib import rc
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from pylab import rcParams
from matplotlib.ticker import AutoMinorLocator
import scipy.stats as stats
import statsmodels.api as sm
%load_ext memory_profiler
# %memit
%load_ext autotime
from matplotlib.ticker import AutoMinorLocator
import matplotlib.ticker as ticker
from scipy.stats import gaussian_kde
import statsmodels.api as sm
#Prevent columns/rows from truncating
pd.set_option('display.max_columns', 1000)
pd.set_option('display.max_rows', 5000)
#print(data)
#data.columns.tolist()
#Use a function to set default plotting parameters; cuts down on extra code (if you don't want to use matplotlib defaults)
#Note: Running this cell will reset your matplotlib defaults (for this notebook, only)
def default_plotting():
#fig
plt.rcParams['savefig.dpi'] = '100'
plt.rcParams['savefig.format'] = ('png')
#font
plt.rcParams['font.family'] = 'Georgia'
#plt.rcParams['font.size'] = 22
plt.rcParams['axes.labelsize'] = 18
plt.rcParams['axes.titlesize'] = 18
plt.rcParams['xtick.labelsize'] = 18
plt.rcParams['ytick.labelsize'] = 18
#legend
#plt.rcParams['legend.fontsize'] = 12
#axes
plt.rcParams['axes.linewidth'] = 1
plt.rcParams['axes.edgecolor'] = 'black'
plt.rcParams['axes.facecolor'] = 'white'
plt.rcParams['axes.grid'] = False
plt.rcParams['axes.labelpad'] = 10
plt.rcParams['axes.axisbelow'] = False
#tick marks
plt.gca().xaxis.set_ticks_position('bottom')
plt.gca().yaxis.set_ticks_position('left')
plt.rcParams['xtick.major.size'] = 7
plt.rcParams['ytick.major.size'] = 7
plt.rcParams['ytick.minor.size'] = 3
plt.rcParams['xtick.minor.size'] = 3
plt.rcParams['ytick.major.width'] = 1
plt.rcParams['ytick.minor.width'] = 1
plt.rcParams['xtick.major.width'] = 1
plt.rcParams['xtick.minor.width'] = 1
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
default_plotting()
plt.close()
import MySQLdb
#command-line arguments
import sys
conn = MySQLdb.connect(host="localhost", #Replace with MySQL host name
user="USERNAME", #Enter as it appears in MySQL database settings
passwd="PASSWORD", #Replace with MySQL database password that you set when you imported the database to MySQL
db="NAMEOFDATABASE") #Replace with the name you assigned to the database when you imported to MySQL
# Create proxy cursor to interact with the database
cursor = conn.cursor()
To import the database, we will need to import each table individually, then merge the tables at the end. This is a long process! We also drop MySQL ID columns that are unnecessary here.
cursor.execute('SELECT * FROM authors')
rows = cursor.fetchall()
authors = pd.DataFrame( [[ij for ij in i] for i in rows])
authors.rename(columns={0: 'authorID', 1: 'name', 2:'affiliation',
3: 'city', 4: 'country', 5: 'long',
6: 'lat', 7: 'email', 8: 'last_updated'},
inplace=True);
# drop last_update column
authors = authors.drop('last_updated', axis = 1)
cursor.execute('SELECT * FROM papers')
rows = cursor.fetchall()
papers = pd.DataFrame( [[ij for ij in i] for i in rows])
papers.rename(columns={0: 'paperID', 1: 'authorID', 2:'authors',
3: 'title', 4: 'journal', 5: 'volume',
6: 'issue', 7: 'pages', 8: 'year',
9: 'doi', 10: 'material', 11: 'material_group',
12: 'last_updated'},
inplace=True);
# drop last_update column
papers = papers.drop('last_updated', axis = 1)
papers = pd.merge(papers, authors, on = 'authorID', how = 'outer')
cursor.execute('SELECT * FROM props_adds')
rows = cursor.fetchall()
props_adds = pd.DataFrame( [[ij for ij in i] for i in rows])
props_adds.rename(columns={0: 'addID', 1: 'add_name', 2:'add_density',
3: 'add_MW'},
inplace=True);
cursor.execute('SELECT * FROM props_fluids')
rows = cursor.fetchall()
props_fluids = pd.DataFrame( [[ij for ij in i] for i in rows])
props_fluids.rename(columns={0: 'fluidID', 1: 'fluid', 2:'fluid_density_liq',
3: 'fluid_density_sol', 4: 'fluid_therm_cond_liq',
5: 'fluid_therm_cond_solid', 6: 'last_updated'},
inplace=True);
# drop last_update column
props_fluids = props_fluids.drop('last_updated', axis = 1)
cursor.execute('SELECT * FROM props_mech_bulk')
rows = cursor.fetchall()
props_mech_bulk = pd.DataFrame( [[ij for ij in i] for i in rows])
props_mech_bulk.rename(columns={0: 'materialID', 1: 'props_material', 2:'material_density',
3: 'props_compress_bulk', 4: 'props_youngs_bulk',
5: 'props_flexion_bulk', 6: 'last_updated'},
inplace=True);
# drop last_update column
props_mech_bulk = props_mech_bulk.drop('last_updated', axis = 1)
cursor.execute('SELECT * FROM props_mold')
rows = cursor.fetchall()
props_mold = pd.DataFrame( [[ij for ij in i] for i in rows])
props_mold.rename(columns={0: 'moldID', 1: 'material', 2:'mold_thermal_cond'},
inplace=True);
cursor.execute('SELECT * FROM props_particles')
rows = cursor.fetchall()
props_particles = pd.DataFrame( [[ij for ij in i] for i in rows])
props_particles.rename(columns={0: 'particleID', 1: 'particle', 2:'description',
3: 'particle_density', 4: 'particle_thermal_cond', 5: 'last_updated'},
inplace=True);
# drop last_update column
props_particles = props_particles.drop('last_updated', axis = 1)
props_particles = props_particles.drop('description', axis = 1)
cursor.execute('SELECT * FROM samples')
rows = cursor.fetchall()
samples = pd.DataFrame( [[ij for ij in i] for i in rows])
samples.rename(columns={0: 'sampleID', 1: 'paperID', 2:'materialID',
3: 'total_VF', 4: 'total_particles', 5: 'total_fluids',
6: 'composite', 7: 'last_updated'},
inplace=True);
# drop last_update column
samples = samples.drop('last_updated', axis = 1)
samples = pd.merge(props_mech_bulk, samples, on = 'materialID', how = 'outer')
samples.columns = ['materialID', 'props_material', 'bulk_material_density', 'bulk_material_compress',
'bulk_material_youngs', 'bulk_material_flexion', 'sampleID', 'paperID',
'total_VF', 'total_particles', 'total_fluids', 'composite']
samples = samples[['sampleID','paperID', 'materialID', 'props_material',
'bulk_material_density', 'bulk_material_compress',
'bulk_material_youngs', 'bulk_material_flexion',
'total_VF', 'total_particles', 'total_fluids', 'composite']]
samples = samples[(samples['sampleID']) > 0]
cursor.execute('SELECT * FROM suspension')
rows = cursor.fetchall()
suspension = pd.DataFrame( [[ij for ij in i] for i in rows])
suspension.rename(columns={0: 'ID', 1: 'sampleID', 2:'ballTime',
3: 'pH', 4: 'viscosity_100', 5: 'zeta', 6: 'last_updated'},
inplace=True);
# drop last_update and suspensionID columns
suspension = suspension.drop('last_updated', axis = 1)
suspension = suspension.drop('ID', axis = 1)
cursor.execute('SELECT * FROM susp_fluid_1')
rows = cursor.fetchall()
fluid1 = pd.DataFrame( [[ij for ij in i] for i in rows])
fluid1.rename(columns={0: 'ID', 1: 'sampleID', 2:'fluidID',
3: 'fluid1_vf', 4: 'last_updated'},
inplace=True);
# drop last_update and fluid1ID columns
fluid1 = fluid1.drop('last_updated', axis = 1)
fluid1 = fluid1.drop('ID', axis = 1)
fluid1 = pd.merge(props_fluids, fluid1, on = 'fluidID', how = 'outer')
fluid1.columns = ['fluid1_ID', 'fluid1', 'fluid1_densityLiq', 'fluid1_densitySol',
'fluid1_thermal_condLiq', 'fluid1_thermal_condSolid', 'sampleID', 'fluid1_vf']
fluid1 = fluid1[(fluid1['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_fluid_2')
rows = cursor.fetchall()
fluid2 = pd.DataFrame( [[ij for ij in i] for i in rows])
fluid2.rename(columns={0: 'ID', 1: 'sampleID', 2:'fluidID',
3: 'fluid2_vf', 4: 'last_updated'},
inplace=True);
# drop last_update and fluid1ID columns
fluid2 = fluid2.drop('last_updated', axis = 1)
fluid2 = fluid2.drop('ID', axis = 1)
fluid2 = pd.merge(props_fluids, fluid2, on = 'fluidID', how = 'outer')
fluid2.columns = ['fluid2_ID', 'fluid2', 'fluid2_densityLiq', 'fluid2_densitySol',
'fluid2_thermal_condLiq', 'fluid2_thermal_condSolid', 'sampleID', 'fluid2_vf']
fluid2 = fluid2[(fluid2['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_part_1')
rows = cursor.fetchall()
particle1 = pd.DataFrame( [[ij for ij in i] for i in rows])
particle1.rename(columns={0: 'ID', 1: 'sampleID', 2:'particleID',
3: 'shape', 4: 'diameter', 5: 'length',
6: 'particle1_vf', 7: 'last_updated'},
inplace=True);
# drop last_update and ID columns
particle1 = particle1.drop('last_updated', axis = 1)
particle1 = particle1.drop('ID', axis = 1)
particle1 = pd.merge(props_particles, particle1, on = 'particleID', how = 'outer')
particle1.columns = ['particle1ID', 'particle1', 'particle1_density',
'particle1_thermal_cond', 'sampleID', 'particle1_shape',
'particle1_diameter', 'particle1_length', 'particle1_vf']
particle1 = particle1[(particle1['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_part_2')
rows = cursor.fetchall()
particle2 = pd.DataFrame( [[ij for ij in i] for i in rows])
particle2.rename(columns={0: 'ID', 1: 'sampleID', 2:'particleID',
3: 'shape', 4: 'diameter', 5: 'length',
6: 'particle1_vf', 7: 'last_updated'},
inplace=True);
# drop last_update and ID columns
particle2 = particle2.drop('last_updated', axis = 1)
particle2 = particle2.drop('ID', axis = 1)
particle2 = pd.merge(props_particles, particle2, on = 'particleID', how = 'outer')
particle2.columns = ['particle2ID', 'particle2', 'particle2_density',
'particle2_thermal_cond', 'sampleID', 'particle2_shape',
'particle2_diameter', 'particle2_length', 'particle2_vf']
particle2 = particle2[(particle2['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_part_3')
rows = cursor.fetchall()
particle3 = pd.DataFrame( [[ij for ij in i] for i in rows])
particle3.rename(columns={0: 'ID', 1: 'sampleID', 2:'particleID',
3: 'shape', 4: 'diameter', 5: 'length',
6: 'particle3_vf', 7: 'last_updated'},
inplace=True);
# drop last_update and ID columns
particle3 = particle3.drop('last_updated', axis = 1)
particle3 = particle3.drop('ID', axis = 1)
particle3 = pd.merge(props_particles, particle3, on = 'particleID', how = 'outer')
particle3.columns = ['particle3ID', 'particle3', 'particle3_density',
'particle3_thermal_cond',
'sampleID', 'particle3_shape', 'particle3_diameter',
'particle3_length', 'particle3_vf']
particle3 = particle3[(particle3['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_disp_1')
rows = cursor.fetchall()
dispersant1 = pd.DataFrame( [[ij for ij in i] for i in rows])
dispersant1.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'dispersant1_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
dispersant1 = dispersant1.drop('last_updated', axis = 1)
dispersant1 = dispersant1.drop('ID', axis = 1)
dispersant1 = pd.merge(props_adds, dispersant1, on = 'addID', how = 'outer')
dispersant1.columns = ['dispersant1ID', 'dispersant1', 'dispersant1_density', 'dispersant1MW',
'sampleID', 'dispersant1_wf']
dispersant1 = dispersant1[(dispersant1['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_disp_2')
rows = cursor.fetchall()
dispersant2 = pd.DataFrame( [[ij for ij in i] for i in rows])
dispersant2.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'dispersant2_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
dispersant2 = dispersant2.drop('last_updated', axis = 1)
dispersant2 = dispersant2.drop('ID', axis = 1)
dispersant2 = pd.merge(props_adds, dispersant2, on = 'addID', how = 'outer')
dispersant2.columns = ['dispersant2ID', 'dispersant2', 'dispersant2_density', 'dispersant2MW',
'sampleID', 'dispersant2_wf']
dispersant2 = dispersant2[(dispersant2['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_bind_1')
rows = cursor.fetchall()
binder1 = pd.DataFrame( [[ij for ij in i] for i in rows])
binder1.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'binder1_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
binder1 = binder1.drop('last_updated', axis = 1)
binder1 = binder1.drop('ID', axis = 1)
binder1 = pd.merge(props_adds, binder1, on = 'addID', how = 'outer')
binder1.columns = ['binder1ID', 'binder1', 'binder1_density', 'binder1_MW',
'sampleID', 'binder1_wf']
binder1 = binder1[(binder1['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_bind_2')
rows = cursor.fetchall()
binder2 = pd.DataFrame( [[ij for ij in i] for i in rows])
binder2.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'binder2_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
binder2 = binder2.drop('last_updated', axis = 1)
binder2 = binder2.drop('ID', axis = 1)
binder2 = pd.merge(props_adds, binder2, on = 'addID', how = 'outer')
binder2.columns = ['binder2ID', 'binder2', 'binder2_density', 'binder2_MW',
'sampleID', 'binder2_wf']
binder2 = binder2[(binder2['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_cryo')
rows = cursor.fetchall()
cryoprotectant = pd.DataFrame( [[ij for ij in i] for i in rows])
cryoprotectant.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'cryoprotectant_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
cryoprotectant = cryoprotectant.drop('last_updated', axis = 1)
cryoprotectant = cryoprotectant.drop('ID', axis = 1)
cryoprotectant = pd.merge(props_adds, cryoprotectant, on = 'addID', how = 'outer')
cryoprotectant.columns = ['cryoprotectantID', 'cryoprotectant', 'cryoprotectant_density', 'cryoprotectant_MW',
'sampleID', 'cryoprotectant_wf']
cryoprotectant = cryoprotectant[(cryoprotectant['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_add_ph')
rows = cursor.fetchall()
add_ph = pd.DataFrame( [[ij for ij in i] for i in rows])
add_ph.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'add_ph_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
add_ph = add_ph.drop('last_updated', axis = 1)
add_ph = add_ph.drop('ID', axis = 1)
add_ph = pd.merge(props_adds, add_ph, on = 'addID', how = 'outer')
add_ph.columns = ['add_phID', 'add_ph', 'add_ph_density', 'add_ph_MW',
'sampleID', 'add_ph_wf']
add_ph = add_ph[(add_ph['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_surfact')
rows = cursor.fetchall()
surfactant = pd.DataFrame( [[ij for ij in i] for i in rows])
surfactant.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'surfactant_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
surfactant = surfactant.drop('last_updated', axis = 1)
surfactant = surfactant.drop('ID', axis = 1)
surfactant = pd.merge(props_adds, surfactant, on = 'addID', how = 'outer')
surfactant.columns = ['surfactantID', 'surfactant', 'surfactant_density', 'surfactant_MW',
'sampleID', 'surfactant_wf']
surfactant = surfactant[(surfactant['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_init')
rows = cursor.fetchall()
initiator = pd.DataFrame( [[ij for ij in i] for i in rows])
initiator.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'initiator_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
initiator = initiator.drop('last_updated', axis = 1)
initiator = initiator.drop('ID', axis = 1)
initiator = pd.merge(props_adds, initiator, on = 'addID', how = 'outer')
initiator.columns = ['surfactantID', 'initiator', 'initiator_density', 'initiator_MW',
'sampleID', 'initiator_wf']
initiator = initiator[(initiator['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_mono')
rows = cursor.fetchall()
monomer = pd.DataFrame( [[ij for ij in i] for i in rows])
monomer.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'initiator_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
monomer = monomer.drop('last_updated', axis = 1)
monomer = monomer.drop('ID', axis = 1)
monomer = pd.merge(props_adds, monomer, on = 'addID', how = 'outer')
monomer.columns = ['monomerID', 'monomer', 'monomer_density', 'monomer_WF',
'sampleID', 'monomer_wf']
monomer = monomer[(monomer['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_catal')
rows = cursor.fetchall()
catalyst = pd.DataFrame( [[ij for ij in i] for i in rows])
catalyst.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'initiator_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
catalyst = catalyst.drop('last_updated', axis = 1)
catalyst = catalyst.drop('ID', axis = 1)
catalyst = pd.merge(props_adds, catalyst, on = 'addID', how = 'outer')
catalyst.columns = ['catalystID', 'catalyst', 'catalyst_density', 'catalyst_wf',
'sampleID', 'catalyst_wf']
catalyst = catalyst[(catalyst['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_cross')
rows = cursor.fetchall()
crosslinker = pd.DataFrame( [[ij for ij in i] for i in rows])
crosslinker.rename(columns={0: 'ID', 1: 'sampleID', 2:'addID',
3: 'crosslinker_wf', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
crosslinker = crosslinker.drop('last_updated', axis = 1)
crosslinker = crosslinker.drop('ID', axis = 1)
crosslinker = pd.merge(props_adds, crosslinker, on = 'addID', how = 'outer')
crosslinker.columns = ['crosslinkerID', 'crosslinker', 'crosslinker_density', 'crosslinker_wf',
'sampleID', 'crosslinker_wf']
crosslinker = crosslinker[(crosslinker['sampleID']) > 0]
cursor.execute('SELECT * FROM susp_viscosity')
rows = cursor.fetchall()
viscosity = pd.DataFrame( [[ij for ij in i] for i in rows])
viscosity.rename(columns={0: 'ID', 1: 'sampleID', 2:'shearRate',
3: 'viscosity', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
viscosity = viscosity.drop('last_updated', axis = 1)
viscosity = viscosity.drop('ID', axis = 1)
cursor.execute('SELECT * FROM sublimation')
rows = cursor.fetchall()
sublimation = pd.DataFrame( [[ij for ij in i] for i in rows])
sublimation.rename(columns={0: 'ID', 1: 'sampleID', 2:'sublimated',
3: 'sublimation_time', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
sublimation = sublimation.drop('last_updated', axis = 1)
sublimation = sublimation.drop('ID', axis = 1)
cursor.execute('SELECT * FROM solidification')
rows = cursor.fetchall()
solidification = pd.DataFrame( [[ij for ij in i] for i in rows])
solidification.rename(columns={0: 'ID', 1: 'sampleID', 2:'technique',
3: 'direction', 4: 'gravity', 5: 'refrigerant',
6: 'cooling_rate', 7: 'T_Cold', 8: 'T_Hot', 9: 'T_constant',
10: 'gradient', 11: 'velocity', 12: 'T_nuceation',
13: 'last_updated'},
inplace=True);
# drop last_update and ID columns
solidification = solidification.drop('last_updated', axis = 1)
solidification = solidification.drop('ID', axis = 1)
cursor.execute('SELECT * FROM solid_mold')
rows = cursor.fetchall()
mold = pd.DataFrame( [[ij for ij in i] for i in rows])
mold.rename(columns={0: 'ID', 1: 'sampleID', 2:'mold_shape',
3: 'mold_dia', 4: 'mold_height', 5: 'mold_l',
6: 'mold_w', 7: 'mold_wall', 8: 'fill_height', 9: 'moldID',
10: 'last_updated'},
inplace=True);
# drop last_update and ID columns
mold = mold.drop('last_updated', axis = 1)
mold = mold.drop('ID', axis = 1)
mold = pd.merge(props_mold, mold, on = 'moldID', how = 'outer')
mold.columns = ['moldID', 'mold_material', 'mold_thermal_cond', 'sampleID',
'mold_shape', 'mold_dia', 'mold_height', 'mold_l',
'mold_w', 'mold_wall', 'fill_height']
mold = mold[(mold['sampleID']) > 0]
cursor.execute('SELECT * FROM sinter1')
rows = cursor.fetchall()
sinter1 = pd.DataFrame( [[ij for ij in i] for i in rows])
sinter1.rename(columns={0: 'ID', 1: 'sampleID', 2:'sinter1_time',
3: 'sinter1_temp', 4: 'sinter1_rampC', 5: 'sinter1_rampH',
6: 'last_updated'},
inplace=True);
# drop last_update and ID columns
sinter1 = sinter1.drop('last_updated', axis = 1)
sinter1 = sinter1.drop('ID', axis = 1)
cursor.execute('SELECT * FROM sinter2')
rows = cursor.fetchall()
sinter2 = pd.DataFrame( [[ij for ij in i] for i in rows])
sinter2.rename(columns={0: 'ID', 1: 'sampleID', 2:'sinter2_time',
3: 'sinter2_temp', 4: 'sinter2_rampC', 5: 'sinter2_rampH',
6: 'last_updated'},
inplace=True);
# drop last_update and ID columns
sinter2 = sinter2.drop('last_updated', axis = 1)
sinter2 = sinter2.drop('ID', axis = 1)
cursor.execute('SELECT * FROM sinter3')
rows = cursor.fetchall()
sinter3 = pd.DataFrame( [[ij for ij in i] for i in rows])
sinter3.rename(columns={0: 'ID', 1: 'sampleID', 2:'sinter3_time',
3: 'sinter3_temp', 4: 'sinter3_rampC', 5: 'sinter3_rampH',
6: 'last_updated'},
inplace=True);
# drop last_update and ID columns
sinter3 = sinter3.drop('last_updated', axis = 1)
sinter3 = sinter3.drop('ID', axis = 1)
cursor.execute('SELECT * FROM shrinkage')
rows = cursor.fetchall()
shrinkage = pd.DataFrame( [[ij for ij in i] for i in rows])
shrinkage.rename(columns={0: 'ID', 1: 'sampleID', 2:'shrinkage_volumetric',
3: 'shrinkage_diameter', 4: 'shrinkage_linear', 5: 'last_updated'},
inplace=True);
# drop last_update and ID columns
shrinkage = shrinkage.drop('last_updated', axis = 1)
shrinkage = shrinkage.drop('ID', axis = 1)
cursor.execute('SELECT * FROM microstructure')
rows = cursor.fetchall()
microstructure = pd.DataFrame( [[ij for ij in i] for i in rows])
microstructure.rename(columns={0: 'ID', 1: 'sampleID', 2:'pore_structure',
3: 'porosity', 4: 'spacing', 5: 'pore',
6: 'wall', 7: 'aspectPore', 8: 'aspectWall',
9: 'surfaceArea', 10: 'last_updated'},
inplace=True);
# drop last_update and ID columns
microstructure = microstructure.drop('last_updated', axis = 1)
microstructure = microstructure.drop('ID', axis = 1)
cursor.execute('SELECT * FROM composites')
rows = cursor.fetchall()
composite = pd.DataFrame( [[ij for ij in i] for i in rows])
composite.rename(columns={0: 'ID', 1: 'sampleID', 2:'compositeType',
3: 'impregnate_material', 4: 'last_updated'},
inplace=True);
# drop last_update and ID columns
composite = composite.drop('last_updated', axis = 1)
composite = composite.drop('ID', axis = 1)
cursor.execute('SELECT * FROM mechanical')
rows = cursor.fetchall()
mechanical = pd.DataFrame( [[ij for ij in i] for i in rows])
mechanical.rename(columns={0: 'ID', 1: 'sampleID', 2:'mech_shape',
3: 'mech_height', 4: 'mech_dia', 5: 'mech_length',
6: 'mech_width', 7: 'mech_ratio', 8: 'mech_volume',
9: 'compression', 10: 'flexural', 11: 'youngs',
12: 'strainRate', 13: 'crossheadspeed', 14: 'last_updated'},
inplace=True);
mechanical = mechanical.drop('ID', axis = 1)
# drop last_update and ID columns
mechanical = mechanical.drop('last_updated', axis = 1)
data = pd.merge(papers, samples, on = 'paperID', how = 'outer')
data = pd.merge(data, suspension, on = 'sampleID', how = 'outer')
data = pd.merge(data, fluid1, on = 'sampleID', how = 'outer')
data = pd.merge(data, fluid2, on = 'sampleID', how = 'outer')
data = pd.merge(data, particle1, on = 'sampleID', how = 'outer')
data = pd.merge(data, particle2, on = 'sampleID', how = 'outer')
data = pd.merge(data, particle3, on = 'sampleID', how = 'outer')
data = pd.merge(data, dispersant1, on = 'sampleID', how = 'outer')
data = pd.merge(data, dispersant2, on = 'sampleID', how = 'outer')
data = pd.merge(data, binder1, on = 'sampleID', how = 'outer')
data = pd.merge(data, binder2, on = 'sampleID', how = 'outer')
data = pd.merge(data, cryoprotectant, on = 'sampleID', how = 'outer')
data = pd.merge(data, surfactant, on = 'sampleID', how = 'outer')
data = pd.merge(data, add_ph, on = 'sampleID', how = 'outer')
data = pd.merge(data, initiator, on = 'sampleID', how = 'outer')
data = pd.merge(data, crosslinker, on = 'sampleID', how = 'outer')
data = pd.merge(data, monomer, on = 'sampleID', how = 'outer')
data = pd.merge(data, catalyst, on = 'sampleID', how = 'outer')
data = pd.merge(data, viscosity, on = 'sampleID', how = 'outer')
data = pd.merge(data, solidification, on = 'sampleID', how = 'outer')
data = pd.merge(data, sublimation, on = 'sampleID', how = 'outer')
data = pd.merge(data, mold, on = 'sampleID', how = 'outer')
data = pd.merge(data, sinter1, on = 'sampleID', how = 'outer')
data = pd.merge(data, sinter2, on = 'sampleID', how = 'outer')
data = pd.merge(data, sinter3, on = 'sampleID', how = 'outer')
data = pd.merge(data, shrinkage, on = 'sampleID', how = 'outer')
data = pd.merge(data, microstructure, on = 'sampleID', how = 'outer')
data = pd.merge(data, mechanical, on = 'sampleID', how = 'outer')
data = pd.merge(data, composite, on = 'sampleID', how = 'outer')
data = data[(data['sampleID']) > 0]
data['norm_compress'] = (data['compression']/data['bulk_material_compress'])
data['norm_flexural'] = (data['flexural']/data['bulk_material_flexion'])
data['norm_youngs'] = (data['youngs']/data['bulk_material_youngs'])
Variable(s) | Units |
---|---|
Density | kg/m3 |
Thermal conductivity | W/m K |
Compressive, flexural STRENGTH | MPa |
Strain rate | mm/min |
Young's modulus | MPa |
Ball mill, sintering, sublimation TIME | hours |
Viscosity | Pa s |
Velocity | um//s |
Diameter, length, width, etc. (molds, samples, particles) | m |
Pore, wall, spacing | um |
Temperature | K |
Gradient (thermal) | K/m |
Cooling/heating rate | K/min |
Zeta potential | eV |
#Print the column values to ensure we've merged everything correctly
print(list(data.columns.values))
#Replace "ENTERFILEPATH" with the filepath you'd like the csv or text file to be saved to.
data.to_csv(path_or_buf='C:/ENTERFILEPATH/data.txt',
header=True)
data.to_csv(path_or_buf='C:/ENTERFILEPATH/data.csv',
header=True)
papers = papers.set_index('paperID')
authors = papers['authors']
year = papers['year']
doi = papers['doi']
journal = papers['journal']
volume = papers['volume']
issue = papers['issue']
title = papers['title']
pages = papers['pages']
papers['citation'] = (
authors.str.cat(year.astype(str), sep = ' (').str.cat(
title, sep = '). "').str.cat(journal, sep = '." ').str.cat(
volume.astype(str), sep = ', ').str.cat(
issue.astype(str), sep = '(').str.cat(
pages, sep = '), ').str.cat(doi, sep = '. doi: '))
# define function to return citation information
# for specified paperID
def citations(FigRef):
for i in FigRef:
i = index
def Refs(index):
for i in papers.index:
return (papers.loc[index,'citation'])
def printPapers(df, FigX):
#num_Papers = list(df['paperID'].unique())
#num_Papers = num_Papers.count(num_Papers)
set_Papers = set(df['paperID'])
num_Papers = len(set_Papers)
print 'Number of papers', '(', FigX, '):', num_Papers
# For the following plots, you'll need wordcloud and basemap. Uncomment the lines below and run the cell to install via pip
# ! pip install wordcloud
# ! pip install wordcloud --upgrade
# ! pip install basemap
# ! pip install basemap --upgrade
The following plot uses corresponding author location (longitude/latitude) from the authors table to plot author geolocations. Change "FILEPATH" to the filepath you are using to save your figures.
from mpl_toolkits.basemap import Basemap
fig = plt.figure(figsize=(10,10))
fig = Basemap(projection = 'robin', resolution = "l", area_thresh=100000.0, lon_0 = 0, lat_0 = 0)
fig.drawcoastlines(linewidth=0.9)
fig.drawcountries(linewidth=0.9)
fig.fillcontinents(color = 'lightsage', lake_color='#7777ff')
fig.drawmapboundary(fill_color='#f4f4f4')
fig.drawmeridians(np.arange(0, 360, 30), linewidth=0.8)
fig.drawparallels(np.arange(-90, 90, 30), linewidth=0.8)
fig.drawmapboundary(fill_color="#7777ff")
x,y = fig(authors['long'].values, authors['lat'].values)
fig.plot(x, y, 'ro', markersize=4)
plt.savefig('FILEPATH/map.png')
Here, we plot the number of papers published on freeze-casting per year since year 2000. Change "FILEPATH" to the filepath you are using to save your figures. You do not need Seaborn for this plot, you can use matplotlib. However, if you do use Seaborn, you'll need to install it.
import seaborn as sns
sns.set(font_scale=1.75)
sns.set_style("white")
Fig = sns.factorplot("year", data=papers, kind = "count",
color = 'b', alpha = 0.6, aspect = 2.2,
size = 5)
Fig.set_xticklabels(rotation=30)
Fig.set(xlim=(1.5, 18))
Fig.set_axis_labels("Year", "Number of papers published")
plt.savefig('FILEPATH/papers.png')
plt.savefig('FILEPATH/.png Figures/papers.png')
#reset rc_params (sns resets)
sns.reset_orig()
default_plotting()
You'll need to install WordCloud to run this plot. Change "FILEPATH" to the filepath you are using to save your figures.
material_words = papers
material_words = material_words[material_words.material != 'Review']
material_words = material_words[material_words.material != 'Model']
material_words = material_words['material'].str.cat(sep = ' ')
# display(material_words)
from wordcloud import WordCloud
import re
wordcloud = WordCloud(
background_color = 'black',
width = 2000,
height = 1400
).generate(material_words)
plt.imshow(wordcloud)
plt.axis("off");
plt.savefig('FILEPATH/materials.png')
default_plotting()
Change filepaths for all of the plots below to the filepath that corresponds to the folder you'd like to save your figures. You'll need to install the statistics packages referenced in the notebook set-up cell, if you'd like the linear regression stats to print with the plot. Otherwise, you can just delete those lines of code prior to running.
We are using the "Number of Papers" function we wrote in the set-up section (function 1) to print the number of papers that correspond to the grouped data points. You can run the citation function (function 2) to print citations for each data point.
porosity_micro = data[(data['porosity']) > 0]
porosity_pore = porosity_micro[(porosity_micro['pore']) > 0]
porosity_wall = porosity_micro[(porosity_micro['wall']) > 0]
porosity_spacing = porosity_micro[(porosity_micro['spacing']) > 0]
X1 = porosity_pore['porosity']*100
X1 = sm.add_constant(X1)
y1 = porosity_pore['pore']
linear_regression_porosity_pore = sm.OLS(y1, X1)
fitted_model_porosity_pore = linear_regression_porosity_pore.fit()
#print(fitted_model_porosityWater.summary())
betas = np.array(fitted_model_porosity_pore.params)
fitted_values_porosity_pore = fitted_model_porosity_pore.predict(X1)
print('porosity_pore: ', fitted_model_porosity_pore.params)
X2 = porosity_wall['porosity']*100
X2 = sm.add_constant(X2)
y2 = porosity_wall['wall']
linear_regression_porosity_wall = sm.OLS(y2, X2)
fitted_model_porosity_wall = linear_regression_porosity_wall.fit()
#print(fitted_model_porosityWater.summary())
betas = np.array(fitted_model_porosity_wall.params)
fitted_values_porosity_wall = fitted_model_porosity_wall.predict(X2)
print('porosity_wall: ', fitted_model_porosity_wall.params)
X3 = porosity_spacing['porosity']*100
X3 = sm.add_constant(X3)
y3 = porosity_spacing['spacing']
linear_regression_porosity_spacing = sm.OLS(y3, X3)
fitted_model_porosity_spacing = linear_regression_porosity_spacing.fit()
#print(fitted_model_porosityWater.summary())
betas = np.array(fitted_model_porosity_spacing.params)
fitted_values_porosity_spacing = fitted_model_porosity_spacing.predict(X3)
print('TBA: ', fitted_model_porosity_spacing.params)
fig = plt.figure(figsize = (6,15))
ax1 = fig.add_subplot(3, 1, 1)
ax2 = fig.add_subplot(3, 1, 2)
ax3 = fig.add_subplot(3, 1, 3)
minorLocator = AutoMinorLocator()
x1 = porosity_pore['porosity']*100
x2 = porosity_wall['porosity']*100
x3 = porosity_spacing['porosity']*100
y1 = porosity_pore['pore']
y2 = porosity_wall['wall']
y3 = porosity_spacing['spacing']
#fit1 = 1.719334*z + -50.374846
#fit2 = -0.713651*xz2 + 73.522240
#fit3 = -0.026450*x3 + 55.109607
ax1.set(xlim = [0, 100])
ax1.set(ylim = [0.1, 1000])
ax2.set(xlim = [0, 100])
ax2.set(ylim = [0.1, 1000])
ax3.set(xlim = [0, 100])
ax3.set(ylim = [0.1, 1000])
ax1.xaxis.set_minor_locator(minorLocator)
ax2.xaxis.set_minor_locator(minorLocator)
ax3.xaxis.set_minor_locator(minorLocator)
ax1.set_ylabel('Pore width (${\mu}$m)', fontsize = 20)
ax2.set_ylabel('Wall width (${\mu}$m)', fontsize = 20)
ax3.set_ylabel('Primary spacing (${\mu}$m)', fontsize = 20)
ax3.set_xlabel('Porosity (%)', fontsize = 20)
ax1.set_yscale('log')
ax2.set_yscale('log')
ax3.set_yscale('log')
ax1.set_xticklabels([])
ax2.set_xticklabels([])
ax1.scatter(x1, y1, color = 'black', s = 20, edgecolor = 'none')
ax2.scatter(x2, y2, color = 'black', s = 20, edgecolor = 'none')
ax3.scatter(x3, y3, color = 'black', s = 20, edgecolor = 'none')
ax1.xaxis.set_ticks_position('bottom')
ax2.xaxis.set_ticks_position('bottom')
ax3.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
ax2.yaxis.set_ticks_position('left')
ax3.yaxis.set_ticks_position('left')
plt.subplots_adjust(hspace=0, wspace=0)
ax3.xaxis.set_ticks(np.arange(0, 120, 20))
ax1.yaxis.set_major_locator(ticker.LogLocator(base = 10.0))
ax2.yaxis.set_major_locator(ticker.LogLocator(base = 100.0))
ax3.yaxis.set_major_locator(ticker.LogLocator(base = 100.0))
printPapers(porosity_pore, 'fig')
printPapers(porosity_wall, 'fig')
printPapers(porosity_spacing, 'fig')
plt.savefig('FILEPATH/micro.png')
Here, we are using a point density plot to find the trend. You don't need a special library for this, we're just using numpy.
porosity = data[(data['porosity']) > 0]
porosity = porosity[(porosity['total_VF']) > 0]
porosity_water = porosity[(porosity['fluid1_ID']) == 1]
porosity_camphene = porosity[(porosity['fluid1_ID']) == 2]
porosity_tba = porosity[(porosity['fluid1_ID']) == 3]
porosity_other = porosity[(porosity['fluid1_ID']) > 3]
minorLocator1 = AutoMinorLocator()
minorLocator2 = AutoMinorLocator()
x = porosity['total_VF']*100
y = porosity['porosity']*100
# Calculate the point density
xy = np.vstack([x,y])
z = gaussian_kde(xy)(xy)
fig, ax = plt.subplots(figsize = (7,8))
ax.scatter(x, y, c=z, s=25, edgecolor='')
ax.set(xlim = [0, 60])
ax.set(ylim = [0, 100])
ax.yaxis.set_minor_locator(minorLocator1)
ax.xaxis.set_minor_locator(minorLocator2)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.set_ylabel('Porosity (%)', fontsize = 20)
ax.set_xlabel('Solid loading (vol.%)', fontsize = 20)
printPapers(porosity, 'fig')
plt.savefig('C:FILEPATH/porosity_solid_densityplot.png')
Instead of just printing the linear regression statistics, we'll print the linear regression lines to the subplots here. We still print out the statistics so we have the coefficient values.
X1 = porosity_water['total_VF']*100
X1 = sm.add_constant(X1)
y1 = porosity_water['porosity']*100
linear_regression_porosityWater = sm.OLS(y1, X1)
fitted_model_porosityWater = linear_regression_porosityWater.fit()
#print(fitted_model_porosityWater.summary())
betas = np.array(fitted_model_porosityWater.params)
fitted_values_porosityWater = fitted_model_porosityWater.predict(X1)
print('water: ', fitted_model_porosityWater.params)
X2 = porosity_camphene['total_VF']*100
X2 = sm.add_constant(X2)
y2 = porosity_camphene['porosity']*100
linear_regression_porosityCamphene = sm.OLS(y2, X2)
fitted_model_porosityCamphene = linear_regression_porosityCamphene.fit()
#print(fitted_model_porosityWater.summary())
betas = np.array(fitted_model_porosityCamphene.params)
fitted_values_porosityCamphene = fitted_model_porosityCamphene.predict(X2)
print('Camphene: ', fitted_model_porosityCamphene.params)
X3 = porosity_tba['total_VF']*100
X3 = sm.add_constant(X3)
y3 = porosity_tba['porosity']*100
linear_regression_porosityTBA = sm.OLS(y3, X3)
fitted_model_porosityTBA = linear_regression_porosityTBA.fit()
#print(fitted_model_porosityWater.summary())
betas = np.array(fitted_model_porosityTBA.params)
fitted_values_porosityTBA = fitted_model_porosityTBA.predict(X3)
print('TBA: ', fitted_model_porosityTBA.params)
fig = plt.figure(figsize = (10,5))
ax1 = fig.add_subplot(1, 3, 1)
ax2 = fig.add_subplot(1, 3, 2)
ax3 = fig.add_subplot(1, 3, 3)
minorLocator1 = AutoMinorLocator()
minorLocator2 = AutoMinorLocator()
x1 = porosity_water['total_VF']*100
x2 = porosity_camphene['total_VF']*100
x3 = porosity_tba['total_VF']*100
y1 = porosity_water['porosity']*100
y2 = porosity_camphene['porosity']*100
y3 = porosity_tba['porosity']*100
fit1 = -1.073029*x1 + 81.413699
fit2 = -1.120717*x2 + 80.029084
fit3 = -0.615286*x3 + 72.318229
ax1.set(xlim = [0, 60])
ax1.set(ylim = [0, 100])
ax2.set(xlim = [0, 60])
ax2.set(ylim = [0, 100])
ax3.set(xlim = [0, 60])
ax3.set(ylim = [0, 100])
ax1.yaxis.set_minor_locator(minorLocator1)
ax1.xaxis.set_minor_locator(minorLocator2)
ax2.yaxis.set_minor_locator(minorLocator1)
ax2.xaxis.set_minor_locator(minorLocator2)
ax3.yaxis.set_minor_locator(minorLocator1)
ax3.xaxis.set_minor_locator(minorLocator2)
ax1.set_ylabel('Porosity', fontsize = 20)
ax2.set_xlabel('Solid loading (vol.%)', fontsize = 20)
ax1.scatter(x1, y1, color = 'blue', s = 10, edgecolor = 'none')
ax1.plot(x1, fit1, color = 'black')
ax2.scatter(x2, y2, color = 'red', s = 10, edgecolor = 'none')
ax2.plot(x2, fit2, color = 'black')
ax3.scatter(x3, y3, color = 'green', s = 10, edgecolor = 'none')
ax3.plot(x3, fit3, color = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax2.xaxis.set_ticks_position('bottom')
ax3.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
ax2.yaxis.set_ticks_position('left')
ax3.yaxis.set_ticks_position('left')
ax1.xaxis.set_ticks(np.arange(0, 60, 10))
ax1.yaxis.set_ticks(np.arange(20, 100, 20))
ax2.xaxis.set_ticks(np.arange(10, 60, 10))
ax3.xaxis.set_ticks(np.arange(10, 70, 10))
ax2.set_yticklabels([])
ax3.set_yticklabels([])
ax1.set_title("Water")
ax2.set_title("Camphene")
ax3.set_title("TBA")
plt.subplots_adjust(hspace=0, wspace=0)
printPapers(porosity_water, 'fig')
printPapers(porosity_camphene, 'fig')
printPapers(porosity_tba, 'fig')
plt.savefig('FILEPATH/porosity_solidload_fluids.png')
porosityCera = porosity[(porosity['material_group']) == 'Ceramic']
porosityMetal = porosity[(porosity['material_group']) == 'Metal']
porosityPoly = porosity[(porosity['material_group']) == 'Polymer']
porosityCera_water = porosityCera[(porosityCera['fluid1_ID']) == 1]
porosityCera_camphene = porosityCera[(porosityCera['fluid1_ID']) == 2]
porosityCera_TBA = porosityCera[(porosityCera['fluid1_ID']) == 3]
porosityMetal_water = porosityMetal[(porosityMetal['fluid1_ID']) == 1]
porosityMetal_camphene = porosityMetal[(porosityMetal['fluid1_ID']) == 2]
porosityMetal_TBA = porosityMetal[(porosityMetal['fluid1_ID']) == 3]
porosityPoly_water = porosityPoly[(porosityPoly['fluid1_ID']) == 1]
porosityPoly_camphene = porosityPoly[(porosityPoly['fluid1_ID']) == 2]
porosityPoly_TBA = porosityPoly[(porosityPoly['fluid1_ID']) == 3]
fig = plt.figure(figsize = (12,12))
ax1 = fig.add_subplot(3, 3, 1)
ax2 = fig.add_subplot(3, 3, 2)
ax3 = fig.add_subplot(3, 3, 3)
ax4 = fig.add_subplot(3, 3, 4)
ax5 = fig.add_subplot(3, 3, 5)
ax6 = fig.add_subplot(3, 3, 6)
ax7 = fig.add_subplot(3, 3, 7)
ax8 = fig.add_subplot(3, 3, 8)
ax9 = fig.add_subplot(3, 3, 9)
minorLocator1 = AutoMinorLocator()
minorLocator2 = AutoMinorLocator()
x1 = porosityCera_water['total_VF']*100
y1 = porosityCera_water['porosity']*100
x2 = porosityMetal_water['total_VF']*100
y2 = porosityMetal_water['porosity']*100
x3 = porosityPoly_water['total_VF']*100
y3 = porosityPoly_water['porosity']*100
x4 = porosityCera_camphene['total_VF']*100
y4 = porosityCera_camphene['porosity']*100
x5 = porosityMetal_camphene['total_VF']*100
y5 = porosityMetal_camphene['porosity']*100
x6 = porosityPoly_camphene['total_VF']*100
y6 = porosityPoly_camphene['porosity']*100
x7 = porosityCera_TBA['total_VF']*100
y7 = porosityCera_TBA['porosity']*100
x8 = porosityMetal_TBA['total_VF']*100
y8 = porosityMetal_TBA['porosity']*100
x9 = porosityPoly_TBA['total_VF']*100
y9 = porosityPoly_TBA['porosity']*100
ax1.scatter(x1, y1, color = 'blue', s = 10)
ax2.scatter(x2, y2, color = 'blue', s = 10)
ax3.scatter(x3, y3, color = 'blue', s = 10)
ax4.scatter(x4, y4, color = 'red', s = 10)
ax5.scatter(x5, y5, color = 'red', s = 10)
ax6.scatter(x6, y6, color = 'red', s = 10)
ax7.scatter(x7, y7, color = 'green', s = 10)
ax8.scatter(x8, y8, color = 'green', s = 10)
ax9.scatter(x9, y9, color = 'green', s = 10)
ax1.set(xlim = [0, 60])
ax1.set(ylim = [0, 100])
ax2.set(xlim = [0, 60])
ax2.set(ylim = [0, 100])
ax3.set(xlim = [0, 60])
ax3.set(ylim = [0, 100])
ax4.set(xlim = [0, 60])
ax4.set(ylim = [0, 100])
ax5.set(xlim = [0, 60])
ax5.set(ylim = [0, 100])
ax6.set(xlim = [0, 60])
ax6.set(ylim = [0, 100])
ax7.set(xlim = [0, 60])
ax7.set(ylim = [0, 100])
ax8.set(xlim = [0, 60])
ax8.set(ylim = [0, 100])
ax9.set(xlim = [0, 60])
ax9.set(ylim = [0, 100])
ax1.set_xticklabels([])
ax2.set_xticklabels([])
ax3.set_xticklabels([])
ax4.set_xticklabels([])
ax5.set_xticklabels([])
ax6.set_xticklabels([])
ax2.set_yticklabels([])
ax3.set_yticklabels([])
ax5.set_yticklabels([])
ax6.set_yticklabels([])
ax8.set_yticklabels([])
ax9.set_yticklabels([])
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
ax2.xaxis.set_ticks_position('bottom')
ax2.yaxis.set_ticks_position('left')
ax3.xaxis.set_ticks_position('bottom')
ax3.yaxis.set_ticks_position('left')
ax4.xaxis.set_ticks_position('bottom')
ax4.yaxis.set_ticks_position('left')
ax5.xaxis.set_ticks_position('bottom')
ax5.yaxis.set_ticks_position('left')
ax6.xaxis.set_ticks_position('bottom')
ax6.yaxis.set_ticks_position('left')
ax7.xaxis.set_ticks_position('bottom')
ax7.yaxis.set_ticks_position('left')
ax8.xaxis.set_ticks_position('bottom')
ax8.yaxis.set_ticks_position('left')
ax9.xaxis.set_ticks_position('bottom')
ax9.yaxis.set_ticks_position('left')
ax7.xaxis.set_ticks(np.arange(10, 60, 10))
ax8.xaxis.set_ticks(np.arange(10, 60, 10))
ax9.xaxis.set_ticks(np.arange(10, 70, 10))
ax1.yaxis.set_ticks(np.arange(20, 120, 20))
ax3.yaxis.set_ticks(np.arange(20, 100, 20))
ax7.yaxis.set_ticks(np.arange(0, 100, 20))
ax3.yaxis.set_label_position("right")
ax6.yaxis.set_label_position("right")
ax9.yaxis.set_label_position("right")
ax3.yaxis.labelpad = 20
ax6.yaxis.labelpad = 20
ax9.yaxis.labelpad = 20
ax1.yaxis.set_minor_locator(minorLocator1)
ax1.xaxis.set_minor_locator(minorLocator2)
ax2.yaxis.set_minor_locator(minorLocator1)
ax2.xaxis.set_minor_locator(minorLocator2)
ax3.yaxis.set_minor_locator(minorLocator1)
ax3.xaxis.set_minor_locator(minorLocator2)
ax4.yaxis.set_minor_locator(minorLocator1)
ax4.xaxis.set_minor_locator(minorLocator2)
ax5.yaxis.set_minor_locator(minorLocator1)
ax5.xaxis.set_minor_locator(minorLocator2)
ax6.yaxis.set_minor_locator(minorLocator1)
ax6.xaxis.set_minor_locator(minorLocator2)
ax7.yaxis.set_minor_locator(minorLocator1)
ax7.xaxis.set_minor_locator(minorLocator2)
ax8.yaxis.set_minor_locator(minorLocator1)
ax8.xaxis.set_minor_locator(minorLocator2)
ax9.yaxis.set_minor_locator(minorLocator1)
ax9.xaxis.set_minor_locator(minorLocator2)
fig.subplots_adjust(wspace = 0, hspace = 0)
ax4.set_ylabel('Porosity (%)')
ax8.set_xlabel('Solid loading (vol.%)')
w = ax3.set_ylabel('Water')
c = ax6.set_ylabel('Camphene')
t = ax9.set_ylabel('TBA')
w.set_rotation(-90)
c.set_rotation(-90)
t.set_rotation(-90)
ax1.set_axis_bgcolor('aliceblue')
ax2.set_axis_bgcolor('aliceblue')
ax3.set_axis_bgcolor('aliceblue')
ax4.set_axis_bgcolor('mistyrose')
ax5.set_axis_bgcolor('mistyrose')
ax6.set_axis_bgcolor('mistyrose')
ax7.set_axis_bgcolor('honeydew')
ax8.set_axis_bgcolor('honeydew')
ax9.set_axis_bgcolor('honeydew')
ax1.set_title("Ceramic")
ax2.set_title("Metal")
ax3.set_title("Polymer")
printPapers(porosityCera_water, 'fig')
printPapers(porosityMetal_water, 'fig')
printPapers(porosityPoly_water, 'fig')
printPapers(porosityCera_camphene, 'fig')
printPapers(porosityMetal_camphene, 'fig')
printPapers(porosityPoly_camphene, 'fig')
printPapers(porosityCera_TBA, 'fig')
printPapers(porosityMetal_TBA, 'fig')
printPapers(porosityPoly_TBA, 'fig')
plt.savefig('FILEPATH/porosity_groups.png')
Al2O3_porosity = porosity[(porosity['materialID']) == 1]
x = Al2O3_porosity['total_VF']*100
y = Al2O3_porosity['porosity']*100
minorLocator1 = AutoMinorLocator()
minorLocator2 = AutoMinorLocator()
# Calculate the point density
xy = np.vstack([x,y])
z = gaussian_kde(xy)(xy)
fig, ax = plt.subplots(figsize = (5,6))
ax.scatter(x, y, c=z, s=25, edgecolor='')
ax.set(xlim = [0, 60])
ax.set(ylim = [0, 100])
ax.yaxis.set_minor_locator(minorLocator1)
ax.xaxis.set_minor_locator(minorLocator2)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.set_ylabel('Porosity (%)', fontsize = 20)
ax.set_xlabel('Solid loading (vol.% Al2O3)', fontsize = 20)
printPapers(Al2O3_porosity, 'fig')
plt.savefig('FILEPATH/Al2O3porosity_solid_densityplot.png')
pore = data[(data['pore']) > 0]
pore = pore[(pore['total_VF']) > 0]
wall = data[(data['wall']) > 0]
wall = wall[(wall['total_VF']) > 0]
pore_water = pore[(pore['fluid1_ID']) == 1]
pore_camphene = pore[(pore['fluid1_ID']) == 2]
pore_tba = pore[(pore['fluid1_ID']) == 3]
wall_water = wall[(wall['fluid1_ID']) == 1]
wall_camphene = wall[(wall['fluid1_ID']) == 2]
wall_tba = wall[(wall['fluid1_ID']) == 3]
fig = plt.figure(figsize = (10,12))
minorLocator = AutoMinorLocator()
ax1 = fig.add_subplot(3, 2, 1)
ax4 = fig.add_subplot(3, 2, 2)
ax2 = fig.add_subplot(3, 2, 3)
ax5 = fig.add_subplot(3, 2, 4)
ax3 = fig.add_subplot(3, 2, 5)
ax6 = fig.add_subplot(3, 2, 6)
x1 = pore_water['total_VF']*100
x2 = pore_camphene['total_VF']*100
x3 = pore_tba['total_VF']*100
y1 = pore_water['pore']
y2 = pore_camphene['pore']
y3 = pore_tba['pore']
x4 = wall_water['total_VF']*100
x5 = wall_camphene['total_VF']*100
x6 = wall_tba['total_VF']*100
y4 = wall_water['wall']
y5 = wall_camphene['wall']
y6 = wall_tba['wall']
ax1.scatter(x1, y1, color = 'blue', s = 10)
ax2.scatter(x2, y2, color = 'red', s = 10)
ax3.scatter(x3, y3, color = 'green', s = 10)
ax4.scatter(x4, y4, color = 'blue', s = 10)
ax5.scatter(x5, y5, color = 'red', s = 10)
ax6.scatter(x6, y6, color = 'green', s = 10)
ax1.set_yscale('log')
ax2.set_yscale('log')
ax3.set_yscale('log')
ax4.set_yscale('log')
ax5.set_yscale('log')
ax6.set_yscale('log')
ax1.set(xlim = [0, 50])
ax1.set(ylim = [0.1, 1000])
ax2.set(xlim = [0, 50])
ax2.set(ylim = [0.1, 1000])
ax3.set(xlim = [0, 50])
ax3.set(ylim = [0.1, 1000])
ax4.set(xlim = [0, 50])
ax4.set(ylim = [0.1, 1000])
ax5.set(xlim = [0, 50])
ax5.set(ylim = [0.1, 1000])
ax6.set(xlim = [0, 50])
ax6.set(ylim = [0.1, 1000])
ax1.yaxis.set_ticks_position('left')
ax2.yaxis.set_ticks_position('left')
ax3.yaxis.set_ticks_position('left')
ax1.xaxis.set_ticks_position('none')
ax2.xaxis.set_ticks_position('none')
ax4.yaxis.set_ticks_position('left')
ax5.yaxis.set_ticks_position('left')
ax6.yaxis.set_ticks_position('left')
ax4.xaxis.set_ticks_position('none')
ax5.xaxis.set_ticks_position('none')
ax3.xaxis.set_ticks_position('bottom')
ax6.xaxis.set_ticks_position('bottom')
ax3.xaxis.set_minor_locator(minorLocator)
ax6.xaxis.set_minor_locator(minorLocator)
ax2.set_ylabel('Pore width (${\mu}$m)')
ax5.set_ylabel('Wall width (${\mu}$m)')
ax3.set_xlabel('Solid loading (vol.%)')
ax6.set_xlabel('Solid loading (vol.%)')
ax1.set_xticklabels([])
ax2.set_xticklabels([])
ax4.set_xticklabels([])
ax5.set_xticklabels([])
ax3.xaxis.set_ticks(np.arange(10, 50, 10))
ax6.xaxis.set_ticks(np.arange(10, 50, 10))
fig.subplots_adjust(wspace = 0.4, hspace = 0)
ax1.yaxis.set_major_locator(ticker.LogLocator(base = 100.0))
ax2.yaxis.set_major_locator(ticker.LogLocator(base = 100.0))
ax3.yaxis.set_major_locator(ticker.LogLocator(base = 10.0))
ax4.yaxis.set_major_locator(ticker.LogLocator(base = 100.0))
ax5.yaxis.set_major_locator(ticker.LogLocator(base = 100.0))
ax6.yaxis.set_major_locator(ticker.LogLocator(base = 10.0))
printPapers(pore_water, 'fig_porewater')
printPapers(pore_camphene, 'fig_porecamphene')
printPapers(pore_tba, 'fig_poretba')
printPapers(wall_water, 'fig_wallwater')
printPapers(wall_camphene, 'fig_wallcamphene')
printPapers(wall_tba, 'fig_walltba')
plt.savefig('FILEPATH/walls_pores_fluids.png')
TConstant = data[(data['T_constant']) > 0]
TConstant = TConstant[(TConstant['fluid1_ID']) == 1]
TConstant_spacing = TConstant[(TConstant['spacing']) > 0]
TConstant_pore = TConstant[(TConstant['pore']) > 0]
TConstant_wall = TConstant[(TConstant['wall']) > 0]
fig = plt.figure(figsize = (7,10))
ax1 = fig.add_subplot(3, 1, 1)
ax2 = fig.add_subplot(3, 1, 2)
ax3 = fig.add_subplot(3, 1, 3)
x1 = TConstant_spacing['T_constant']
x2 = TConstant_pore['T_constant']
x3 = TConstant_wall['T_constant']
y1 = TConstant_spacing['spacing']
y2 = TConstant_pore['pore']
y3 = TConstant_wall['wall']
minorLocator = AutoMinorLocator()
ax1.set(xlim = [50, 275])
ax2.set(xlim = [50, 275])
ax3.set(xlim = [50, 275])
ax1.set(ylim = [1, 1000])
ax2.set(ylim = [1, 1000])
ax3.set(ylim = [1, 1000])
ax1.xaxis.set_minor_locator(minorLocator)
ax3.set_xlabel('Constant substrate temperature (K)', fontsize = 16)
ax1.set_ylabel('Primary spacing (${\mu}$m)', fontsize = 16)
ax2.set_ylabel('Pore width (${\mu}$m)', fontsize = 16)
ax3.set_ylabel('Wall width (${\mu}$m)', fontsize = 16)
ax1.scatter(x1, y1, color = 'blue', s = 30, edgecolor = 'black')
ax3.scatter(x3, y3, color = 'blue', s = 30, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'blue', s = 30, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
ax2.xaxis.set_ticks_position('bottom')
ax2.yaxis.set_ticks_position('left')
ax3.xaxis.set_ticks_position('bottom')
ax3.yaxis.set_ticks_position('left')
ax1.set_yscale('log')
ax2.set_yscale('log')
ax3.set_yscale('log')
plt.tight_layout()
printPapers(TConstant_spacing, 'fig')
printPapers(TConstant_pore, 'fig')
printPapers(TConstant_wall, 'fig')
plt.savefig('FILEPATH/coldconstant.png')
compressPorosity = data[(data['porosity']) > 0]
compressPorosity = compressPorosity[(compressPorosity['norm_compress']) > 0]
compressPorosity_water = compressPorosity[(compressPorosity['fluid1_ID']) == 1]
compressPorosity_camphene = compressPorosity[(compressPorosity['fluid1_ID']) == 2]
compressPorosity_tba = compressPorosity[(compressPorosity['fluid1_ID']) == 3]
x1 = compressPorosity_water['porosity']*100
x2 = compressPorosity_camphene['porosity']*100
x3 = compressPorosity_tba['porosity']*100
y1 = compressPorosity_water['norm_compress']
y2 = compressPorosity_camphene['norm_compress']
y3 = compressPorosity_tba['norm_compress']
fig = plt.figure(figsize = (7,7))
ax1 = fig.add_subplot(1, 1, 1)
ax2 = fig.add_subplot(1, 1, 1)
ax3 = fig.add_subplot(1, 1, 1)
minorLocator = AutoMinorLocator()
ax1.set(xlim = [1, 100])
ax1.set(ylim = [0.00001, 1])
ax1.xaxis.set_minor_locator(minorLocator)
ax1.set_ylabel('Normalized compressive strength', fontsize = 20)
ax1.set_xlabel('Porosity (%)', fontsize = 20)
ax1.set_yscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax3.scatter(x3, y3, color = 'green', s = 40, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'red', s = 40, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
printPapers(compressPorosity_water, 'fig')
printPapers(compressPorosity_camphene, 'fig')
printPapers(compressPorosity_tba, 'fig')
plt.savefig('FILEPATH/porosityCompress.png')
x1 = compressPorosity_water['porosity']*100
x2 = compressPorosity_camphene['porosity']*100
x3 = compressPorosity_tba['porosity']*100
y1 = compressPorosity_water['norm_compress']
y2 = compressPorosity_camphene['norm_compress']
y3 = compressPorosity_tba['norm_compress']
fig = plt.figure(figsize = (12,7))
ax1 = fig.add_subplot(1, 3, 1)
ax2 = fig.add_subplot(1, 3, 2)
ax3 = fig.add_subplot(1, 3, 3)
minorLocator = AutoMinorLocator()
ax1.set(xlim = [1, 100])
ax1.set(ylim = [0.00001, 1])
ax1.xaxis.set_minor_locator(minorLocator)
ax2.set(xlim = [1, 100])
ax2.set(ylim = [0.00001, 1])
ax2.xaxis.set_minor_locator(minorLocator)
ax3.set(xlim = [1, 100])
ax3.set(ylim = [0.00001, 1])
ax3.xaxis.set_minor_locator(minorLocator)
ax1.set_ylabel('Normalized compressive strength', fontsize = 20)
ax2.set_xlabel('Porosity (%)', fontsize = 20)
ax1.set_yscale('log')
ax2.set_yscale('log')
ax3.set_yscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax3.scatter(x3, y3, color = 'green', s = 40, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'red', s = 40, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
fig.subplots_adjust(wspace = 0, hspace = 0)
ax2.set_yticklabels([])
ax3.set_yticklabels([])
ax1.xaxis.set_ticks(np.arange(20, 100, 20))
ax2.xaxis.set_ticks(np.arange(20, 100, 20))
ax3.xaxis.set_ticks(np.arange(20, 100, 20))
printPapers(compressPorosity_water, 'fig')
printPapers(compressPorosity_camphene, 'fig')
printPapers(compressPorosity_tba, 'fig')
plt.savefig('FILEPATH')
compressPore = data[(data['pore']) > 0]
compressPore = compressPore[(compressPore['norm_compress']) > 0]
compressPore_water = compressPore[(compressPore['fluid1_ID']) == 1]
compressPore_camphene = compressPore[(compressPore['fluid1_ID']) == 2]
compressPore_water_tba = compressPore[(compressPore['fluid1_ID']) == 3]
x1 = compressPore_water['pore']
x2 = compressPore_camphene['pore']
x3 = compressPore_water_tba['pore']
y1 = compressPore_water['norm_compress']
y2 = compressPore_camphene['norm_compress']
y3 = compressPore_water_tba['norm_compress']
fig = plt.figure(figsize = (7,7))
ax1 = fig.add_subplot(1, 1, 1)
ax2 = fig.add_subplot(1, 1, 1)
ax3 = fig.add_subplot(1, 1, 1)
#minorLocator = AutoMinorLocator()
ax1.set(xlim = [0.1, 1000])
ax1.set(ylim = [0.00001, 1])
ax1.xaxis.set_minor_locator(minorLocator)
ax1.set_ylabel('Normalized compressive strength', fontsize = 20)
ax1.set_xlabel('Pore size (${\mu}$m)', fontsize = 20)
ax1.set_yscale('log')
ax1.set_xscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax3.scatter(x3, y3, color = 'green', s = 40, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'red', s = 40, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
printPapers(compressPore_water, 'fig')
printPapers(compressPore_camphene, 'fig')
printPapers(compressPore_water_tba, 'fig')
plt.savefig('FILEPATH')
compressWall = data[(data['wall']) > 0]
compressWall = compressWall[(compressWall['norm_compress']) > 0]
compressWall_water = compressWall[(compressWall['fluid1_ID']) == 1]
compressWall_camphene = compressWall[(compressWall['fluid1_ID']) == 2]
compressWall_water_tba = compressWall[(compressWall['fluid1_ID']) == 3]
x1 = compressWall_water['wall']
x2 = compressWall_camphene['wall']
x3 = compressWall_water_tba['wall']
y1 = compressWall_water['norm_compress']
y2 = compressWall_camphene['norm_compress']
y3 = compressWall_water_tba['norm_compress']
fig = plt.figure(figsize = (7,7))
ax1 = fig.add_subplot(1, 1, 1)
ax2 = fig.add_subplot(1, 1, 1)
ax3 = fig.add_subplot(1, 1, 1)
#minorLocator = AutoMinorLocator()
ax1.set(xlim = [1, 400])
ax1.set(ylim = [0.00001, 1])
ax1.xaxis.set_minor_locator(minorLocator)
ax1.set_ylabel('Normalized compressive strength', fontsize = 20)
ax1.set_xlabel('Wall width (${\mu}$m)', fontsize = 20)
ax1.set_yscale('log')
ax1.set_xscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax3.scatter(x3, y3, color = 'green', s = 40, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'red', s = 40, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
printPapers(compressWall_water, 'fig')
printPapers(compressWall_camphene, 'fig')
printPapers(compressWall_water_tba, 'fig')
plt.savefig('FILEPATH')
compressShrink = data[(data['norm_compress']) > 0]
compressShrink_dia = compressShrink[(compressShrink['shrinkage_diameter']) > 0]
compressShrink_vol = compressShrink[(compressShrink['shrinkage_volumetric']) > 0]
compressShrink_lin = compressShrink[(compressShrink['shrinkage_linear']) > 0]
x1 = compressShrink_dia['shrinkage_diameter']*100
x2 = compressShrink_vol['shrinkage_volumetric']*100
x3 = compressShrink_lin['shrinkage_linear']*100
y1 = compressShrink_dia['norm_compress']
y2 = compressShrink_vol['norm_compress']
y3 = compressShrink_lin['norm_compress']
fig = plt.figure(figsize = (12,7))
ax1 = fig.add_subplot(1, 3, 2)
ax2 = fig.add_subplot(1, 3, 3)
ax3 = fig.add_subplot(1, 3, 1)
minorLocator = AutoMinorLocator()
ax1.set(xlim = [1, 100])
ax2.set(xlim = [1, 100])
ax3.set(xlim = [1, 100])
ax1.set(ylim = [0.00001, 1])
ax2.set(ylim = [0.00001, 1])
ax3.set(ylim = [0.00001, 1])
ax1.xaxis.set_minor_locator(minorLocator)
ax1.set_xlabel('Shrinkage (%diameter)', fontsize = 16)
ax2.set_xlabel('Volumetric shrinkage (%)', fontsize = 16)
ax3.set_xlabel('Linear shrinkage (%)', fontsize = 16)
ax3.set_ylabel('Normalized compressive strength', fontsize = 20)
ax1.set_yscale('log')
ax2.set_yscale('log')
ax3.set_yscale('log')
ax1.set_xscale('log')
ax2.set_xscale('log')
ax3.set_xscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax3.scatter(x3, y3, color = 'blue', s = 40, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'blue', s = 40, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
ax2.xaxis.set_ticks_position('bottom')
ax2.yaxis.set_ticks_position('left')
ax3.xaxis.set_ticks_position('bottom')
ax3.yaxis.set_ticks_position('left')
fig.subplots_adjust(wspace = 0, hspace = 0)
ax1.set_yticklabels([])
ax2.set_yticklabels([])
#ax1.xaxis.set_ticks(np.arange(20, 100, 20))
#ax2.xaxis.set_ticks(np.arange(20, 100, 20))
#ax3.xaxis.set_ticks(np.arange(20, 100, 20))
printPapers(compressShrink_dia, 'fig')
printPapers(compressShrink_vol, 'fig')
printPapers(compressShrink_lin, 'fig')
plt.savefig('FILEPATH')
flexuralPorosity = data[(data['porosity']) > 0]
flexuralPorosity = flexuralPorosity[(flexuralPorosity['norm_flexural']) > 0]
flexuralPorosity_water = flexuralPorosity[(flexuralPorosity['fluid1_ID']) == 1]
flexuralPorosity_camphene = flexuralPorosity[(flexuralPorosity['fluid1_ID']) == 2]
flexuralPorosity_tba = flexuralPorosity[(flexuralPorosity['fluid1_ID']) == 3]
x1 = flexuralPorosity_water['porosity']*100
x2 = flexuralPorosity_camphene['porosity']*100
x3 = flexuralPorosity_tba['porosity']*100
y1 = flexuralPorosity_water['norm_flexural']
y2 = flexuralPorosity_camphene['norm_flexural']
y3 = flexuralPorosity_tba['norm_flexural']
fig = plt.figure(figsize = (7,7))
ax1 = fig.add_subplot(1, 1, 1)
ax2 = fig.add_subplot(1, 1, 1)
ax3 = fig.add_subplot(1, 1, 1)
minorLocator = AutoMinorLocator()
ax1.set(xlim = [1, 100])
ax1.set(ylim = [0.001, 1])
ax1.xaxis.set_minor_locator(minorLocator)
ax1.set_ylabel('Normalized flexural strength', fontsize = 20)
ax1.set_xlabel('Porosity (%)', fontsize = 20)
ax1.set_yscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax3.scatter(x3, y3, color = 'green', s = 40, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'red', s = 40, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
printPapers(flexuralPorosity_water, 'fig')
printPapers(flexuralPorosity_camphene, 'fig')
printPapers(flexuralPorosity_tba, 'fig')
youngsPorosity = data[(data['porosity']) > 0]
youngsPorosity = youngsPorosity[(youngsPorosity['norm_youngs']) > 0]
youngsPorosity_water = youngsPorosity[(youngsPorosity['fluid1_ID']) == 1]
youngsPorosity_camphene = youngsPorosity[(youngsPorosity['fluid1_ID']) == 2]
youngsPorosity_tba = youngsPorosity[(youngsPorosity['fluid1_ID']) == 3]
x1 = youngsPorosity_water['porosity']*100
x2 = youngsPorosity_camphene['porosity']*100
x3 = youngsPorosity_tba['porosity']*100
y1 = youngsPorosity_water['norm_youngs']
y2 = youngsPorosity_camphene['norm_youngs']
y3 = youngsPorosity_tba['norm_youngs']
fig = plt.figure(figsize = (7,7))
ax1 = fig.add_subplot(1, 1, 1)
ax2 = fig.add_subplot(1, 1, 1)
ax3 = fig.add_subplot(1, 1, 1)
minorLocator = AutoMinorLocator()
ax1.set(xlim = [1, 100])
ax1.set(ylim = [0.00001, 1])
ax1.xaxis.set_minor_locator(minorLocator)
ax1.set_ylabel("Normalized Young's modulus", fontsize = 20)
ax1.set_xlabel('Porosity (%)', fontsize = 20)
ax1.set_yscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax3.scatter(x3, y3, color = 'green', s = 40, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'red', s = 40, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
printPapers(youngsPorosity_water, 'fig')
printPapers(youngsPorosity_camphene, 'fig')
printPapers(youngsPorosity_tba, 'fig')
print(list(data.columns.values))
Using the column values above as a reminder, pick the variables you'd like to run a correlation matrix with. Replace the column values below with your values, and run the cell below to create the corresponding correlation matrix.
X = (data[['materialID', 'material_group', 'total_VF', 'composite',
'ballTime', 'fluid1_ID', 'particle1ID', 'particle1_diameter',
'particle1_density', 'particle1_thermal_cond',
'dispersant1_wf', 'binder1_wf', 'cooling_rate',
'T_Cold', 'T_constant', 'velocity',
'mold_shape', 'mold_dia', 'mold_height',
'shrinkage_volumetric', 'shrinkage_diameter',
'shrinkage_linear',
'porosity', 'spacing', 'pore', 'wall', 'compositeType',
'norm_compress', 'norm_flexural', 'norm_youngs']].copy())
print(X.corr())
X.describe()
If you'd like to see a correlation matrix for a subset of the matrix above, create a new matrix using the grouping variable of interest, as shown below.
X_water = X[(X['fluid1_ID']) == 1]
print(X_water.corr())
X_water_cera = X_water[(X_water['material_group']) == 'Ceramic']
print(X_water_cera.corr())
See a correlation value that looks promising? Create a new variable and plot the data!
sub = data[(data['velocity']) > 0]
sub = sub[(sub['fluid1_ID']) == 1]
subP = sub[(sub['pore']) > 0]
subW = sub[(sub['wall']) > 0]
x1 = subP['velocity']
x2 = subW['velocity']
y1 = subP['pore']
y2 = subW['wall']
fig = plt.figure(figsize = (10,5))
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
minorLocator = AutoMinorLocator()
ax1.set(xlim = [1, 100])
ax1.set(ylim = [1, 500])
ax2.set(xlim = [1, 100])
ax2.set(ylim = [1, 500])
ax1.set_ylabel("Pore width", fontsize = 20)
ax1.set_xlabel('Velocity (um/s)', fontsize = 20)
ax2.set_ylabel("Wall width (um)", fontsize = 20)
ax2.set_xlabel('Velocity (um/s)', fontsize = 20)
ax1.set_yscale('log')
ax1.set_xscale('log')
ax2.set_yscale('log')
ax2.set_xscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax2.scatter(x2, y2, color = 'blue', s = 40, edgecolor = 'black')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
plt.tight_layout()
#printPapers(youngsPorosity_water, 'fig')
#printPapers(youngsPorosity_camphene, 'fig')
#printPapers(youngsPorosity_tba, 'fig')
sub1 = data[(data['T_constant']) > 0]
sub1 = sub1[(sub1['fluid1_ID']) == 1]
subP = sub1[(sub1['pore']) > 0]
subW = sub1[(sub1['wall']) > 0]
x1 = subP['T_constant']
x2 = subW['T_constant']
y1 = subP['pore']
y2 = subW['wall']
x = [263, 258, 253, 243]
y = [51, 41, 18, 16]
x3 = [263, 258, 253, 243]
y3 = [29, 27, 19, 20]
fig = plt.figure(figsize = (10,5))
ax1 = fig.add_subplot(1, 2, 1)
ax3 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
ax4 = fig.add_subplot(1, 2, 2)
minorLocator = AutoMinorLocator()
ax1.set(xlim = [100, 1000])
ax1.set(ylim = [1, 500])
ax2.set(xlim = [100, 1000])
ax2.set(ylim = [1, 500])
#ax1.xaxis.set_minor_locator(minorLocator)
ax1.set_ylabel("Pore width", fontsize = 20)
ax1.set_xlabel('Substrate temperature (K)', fontsize = 20)
ax2.set_ylabel("Wall width (um)", fontsize = 20)
ax2.set_xlabel('Substrate temperature (K)', fontsize = 20)
ax1.set_yscale('log')
ax1.set_xscale('log')
ax2.set_yscale('log')
ax2.set_xscale('log')
ax1.scatter(x1, y1, color = 'blue', s = 40, edgecolor = 'black')
ax3.scatter(x, y, color = 'red')
ax2.scatter(x2, y2, color = 'blue', s = 40, edgecolor = 'black')
ax4.scatter(x3, y3, color = 'red')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
plt.tight_layout()
#Uncomment to print the number of references
#printPapers(youngsPorosity_water, 'fig')
#printPapers(youngsPorosity_camphene, 'fig')
#printPapers(youngsPorosity_tba, 'fig')
An open-data initiative