In [62]:
%pylab inline
import csv, os
from glob import glob
import pandas as pd
import shapely.affinity as af
import shapely.geometry as sh
from equivalent_ellipse import *
from scaled_figures import *
pylab.rcParams['savefig.dpi'] = 254
In [63]:
# Use pandas to load the csv file
cutoutData = pd.read_csv("cutoutdata.csv")
# Define width, length, and factor as the csv columns
# which had that corresponding header
width = cutoutData['width'].values
length = cutoutData['length'].values
factor = cutoutData['factor'].values
# Swap width and length values if order was mistaken
swap = width > length
store = width[swap]
width[swap] = length[swap]
length[swap] = store
ratio = width/length
In [64]:
newWidth = array([3,4,5,3,4,5,3,4,5,3,4])
newLength = array([13,13,13,9,10,10,6.5,8,8,5,6.5])
newRatio = newWidth/newLength
pylab.rcParams['savefig.dpi'] = 100
scatter(width,ratio)
scatter(newWidth,newRatio,c='red')
Out[64]:
In [65]:
toRemove = glob('../../figures/elongated/single/*')
for path in toRemove:
os.remove(path)
toRemove = glob('../../figures/elongated/joined/*')
for path in toRemove:
os.remove(path)
In [66]:
j = 0
pylab.rcParams['savefig.dpi'] = 254
for i in range(len(newWidth)):
ellipse = create_ellipse([0,0,newWidth[i],newLength[i],-45])
scaled_fig_start(12,12)
plot(ellipse.exterior.xy[0],ellipse.exterior.xy[1],'b-')
plot(ellipse.centroid.xy[0],ellipse.centroid.xy[1],'go')
text(-5.5,5,('Width: %.1f cm' % (newWidth[i])),fontsize=11)
text(-5.5,4.5,('Length: %.1f cm' % (newLength[i])),fontsize=11)
scaled_fig_end(12,12)
stringj = "%03d" %(j)
savefig('../../figures/elongated/single/'+stringj+'.png')
j += 1
In [67]:
images = sort(glob('../../figures/elongated/single/*'))
In [68]:
j = 0
for i in range(len(images)//2):
a = imread(images[2*i])
b = imread(images[2*i + 1])
c = concatenate((a,b),axis=0)
stringj = "%03d" %(j)
imsave('../../figures/elongated/joined/'+stringj+'.png',c, dpi=254)
j += 1
if mod(len(images),2) == 1:
i += 1
a = imread(images[2*i])
b = zeros(shape(a))
c = concatenate((a,b),axis=0)
stringj = "%03d" %(j)
imsave('../../figures/elongated/joined/'+stringj+'.png',c, dpi=254)
In [69]:
# See if this can be automated
# OPEN IMAGES IN GIMP "AS LAYER"
# SAVE IMAGES TO GIF "AS ANIMATION"
# Run imagemagick on resulting file:
# convert -units PixelsPerInch input.gif -density 254 output.pdf