In [57]:
%matplotlib inline
%load_ext autoreload
%autoreload

import matplotlib.pyplot as plt
import numpy
import astrohack_projections
#numpy.random.seed(42)

# create crazy looking Gaussian for the 3D model
basevar = 0.5 * numpy.eye(3)

gal_model = astrohack_projections.galaxy_model_3d()
v = [3., 0., 0.]
gal_model.add_gaussian(1.0, numpy.array([0., -1., 0.]), basevar + numpy.outer(v,v))
v = [-1., 3., 0.]
gal_model.add_gaussian(1.0, numpy.array([2., 1., 0.]), basevar + numpy.outer(v,v))
v = [1., 3., 0.]
gal_model.add_gaussian(1.0, numpy.array([-2., 1., 0.]), basevar + numpy.outer(v,v))


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

In [58]:
album = astrohack_projections.album_and_model()
psf = astrohack_projections.mixture_of_gaussians(2)
psf.add_gaussian(1., numpy.array([0., 0.]), numpy.eye(2)*1.)

vmin = None

for i in xrange(32):
    image = astrohack_projections.image_and_model()
    alpha, beta, gamma = numpy.random.uniform(0.0, 360.0, size=3)
    intensity = numpy.random.uniform(100.0, 150.0)
    scale = 0.25 * numpy.exp(numpy.random.uniform())
    xshift = numpy.random.uniform(13., 16.)
    yshift = numpy.random.uniform(18., 21.)

    image = astrohack_projections.image_and_model()
    image.set_shape((30, 40))
    image.set_psf(psf)
    kwargs = {'alpha':alpha, 'beta':beta, 'gamma':gamma, 'intensity':intensity, 'scale':scale, 'xshift': xshift, 'yshift': yshift, 'bg':0.0}
    image.set_parameters(**kwargs)
    image.set_galaxy(gal_model)
    image.set_ivar(numpy.ones(image.get_shape()))
    image.construct_synthetic()
    image.set_data(image.get_synthetic() + numpy.random.normal(size=image.get_shape()) / numpy.sqrt(image.ivar))

    # save to album
    album.add_image(image)
print len(album)


32

In [59]:
def showme(album):
    plt.rcParams['figure.figsize'] = 20, 80
    plot_kwargs = {"interpolation": "nearest",
          "cmap": "afmhot",
          "origin": "lower"}
    for i in xrange(len(album)):
        image = album.get_all_images()[i]
        plt.subplot(16, 4, 2*i+1)
        vmin = -5. / numpy.sqrt(numpy.median(image.get_ivar())) # assumes bg = 0
        vmax = -2. * vmin # assumes bg = 0
        plt.imshow(image.get_data(), vmin=vmin, vmax=vmax, **plot_kwargs)
        plt.colorbar()
        plt.subplot(16, 4, 2*i+2)
        plt.imshow(image.get_synthetic(), vmin=vmin, vmax=vmax, **plot_kwargs)
        plt.colorbar()
        
#showme(album)

def showme_small(album, v=False):
    plt.rcParams['figure.figsize'] = 16, 4
    plot_kwargs = {"interpolation": "nearest",
          "cmap": "afmhot",
          "origin": "lower"}
    for j, i in enumerate([8, 9]):
        image = album.get_all_images()[i]
        plt.subplot(1, 4, 2*j+1)
        vmin = -5. / numpy.sqrt(numpy.median(image.get_ivar())) # assumes bg = 0
        vmax = -2. * vmin # assumes bg = 0
        if v==True:
            vmin = None
            vmax = None
        plt.imshow(image.get_data(), vmin=vmin, vmax=vmax, **plot_kwargs)
        plt.colorbar()
        plt.subplot(1, 4, 2*j+2)
        plt.imshow(image.get_synthetic(), vmin=vmin, vmax=vmax, **plot_kwargs)
        plt.colorbar()  

#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/synthetic_start.png")



In [60]:
# INITIALIZATION BLOCK!
import scipy.optimize as op

galpar0 = numpy.array([1., 2., 0., 0., 1., 1., 1., 0., 0., 0.,
                       1., 0., 2., 0., 1., 1., 1., 0., 0., 0.,
                       1., 0., 0., 2., 1., 1., 1., 0., 0., 0.])
imgpar0 = (10., 30., 30., 0.1, 0.5, 14., 20., 0.)

print "album before", album(galpar0)
for image in album:
    print "image before", image(imgpar0)
    
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/initialise.png")


album before 668128.291089
image before 37704.6079521
image before 23566.7588776
image before 20018.3389977
image before 100141.449611
image before 55335.5385039
image before 6743.63773778
image before 25581.2379792
image before 12969.7994351
image before 9013.16951786
image before 50363.2354238
image before 24101.3030206
image before 9107.55005492
image before 14065.9283294
image before 32742.6856729
image before 14451.8206094
image before 23503.6272367
image before 24689.3692808
image before 21266.8859189
image before 23746.9343099
image before 16501.4737569
image before 19016.4879965
image before 11149.2468324
image before 32024.1930011
image before 15969.3335987
image before 37899.0786314
image before 45720.3158597
image before 81972.9259302
image before 29515.4961173
image before 5652.65703215
image before 12048.843995
image before 30229.8397635
image before 47420.2630442

In [61]:
print "album before", album(galpar0)
result = op.minimize(album, galpar0, method="Powell")
print result
galpar = result['x']
print "album after", album(galpar)

showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_1.pdf")


album before 914234.034029
  status: 0
 success: True
   direc: array([[  1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00],
       [  4.29919099e+01,   3.55761596e-02,   2.71688837e-02,
          7.73076744e-03,  -6.36924601e-02,   2.87961851e-01,
          2.87027723e-02,   1.32432145e-01,  -9.84310956e-03,
         -5.23161228e-02,   3.86899520e+01,  -5.01511436e-02,
         -1.10392591e-01,   2.93232950e-02,   1.82393900e-01,
          1.73097337e-01,   1.49625345e+00,  -4.29023502e-01,
         -1.95170172e-01,   7.34949694e-02,  -2.06151620e+00,
          2.13374949e-02,  -6.12492853e-03,  -4.77601600e-04,
          1.47317116e+00,   2.07906863e-01,   5.82219538e-01,
         -3.47584253e-01,  -2.66257423e-01,   1.17718095e-01]])
    nfev: 2680
     fun: 390778.21690675488
       x: array([  2.85805168e+03,   1.18928343e-01,  -2.82139240e-01,
        -4.63424918e-02,   4.86959299e+00,   6.12687731e+00,
         1.10704673e-01,   2.27404001e+00,  -3.00524784e-01,
        -3.66230685e-01,   2.43052009e+03,  -5.81956702e-01,
         8.98802014e-01,   1.05966769e-01,   1.04673783e+01,
         1.09715264e+01,   6.72261733e+00,  -2.77124246e+00,
        -2.29611157e+00,   6.65616836e-02,   9.97840975e+02,
         8.68449169e-01,  -3.35120947e+00,   8.48018284e-01,
         1.61196038e+01,   3.45158144e+00,   2.01016362e+00,
        -1.81259804e-01,  -1.90973561e+00,   9.63777517e-02])
 message: 'Optimization terminated successfully.'
     nit: 8
album after 390778.216907

In [8]:
showme(album)



In [62]:
for image in album:
    imgpar0 = image.get_parameters_vector()
    print "image before", image(imgpar0)
    result = op.minimize(image, imgpar0)
    imgpar = result['x']
    print "image after", image(imgpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_2.pdf")


image before 15790.9345819
image after 8632.2600806
image before 13698.9118976
image after 2407.96573215
image before 12245.3542729
image after 1703.47223939
image before 45832.7632071
image after 9107.29541504
image before 22178.0873002
image after 1979.02887876
image before 8789.61718631
image after 1641.38159662
image before 10333.7480573
image after 4130.35656398
image before 8993.3116844
image after 1892.1849909
image before 6422.86295608
image after 2150.83584609
image before 17756.4804249
image after 3118.24493389
image before 7805.13002888
image after 3997.27555696
image before 8028.90483861
image after 1650.49083735
image before 7886.50642038
image after 2731.90768553
image before 10049.47315
image after 5999.91723955
image before 7460.6766957
image after 4131.62537819
image before 7771.63074971
image after 4896.474454
image before 8417.66441204
image after 2235.89452324
image before 6904.7912621
image after 4507.04775516
image before 7084.48288954
image after 4532.01371641
image before 6569.50346564
image after 1983.882094
image before 7732.87940389
image after 2719.16182321
image before 10469.2111442
image after 2229.23365302
image before 6841.29452295
image after 5026.40057523
image before 5099.98952207
image after 3754.49388258
image before 12520.1133157
image after 5519.84055198
image before 12572.1358702
image after 6588.80266129
image before 38656.6142672
image after 10419.8012563
image before 11437.2217466
image after 2414.25446297
image before 8358.65285666
image after 1707.77799616
image before 5340.83856802
image after 2748.24271969
image before 9641.23700868
image after 5260.415028
image before 22071.681227
image after 9123.46577649

In [63]:
galpar0 = album.galaxy.get_parameters_vector()
print "album before", album(galpar0)
result = op.minimize(album, galpar0, method="Powell")
print result
galpar = result['x']
print "album after", album(galpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_3.pdf")


album before 130956.957877
  status: 0
 success: True
   direc: array([[ -3.05929630e+01,   3.12313996e-02,   6.94959521e-02,
         -1.23786635e-02,   3.10592443e-02,   3.00279903e-01,
         -6.73398569e-03,   6.71175294e-02,  -1.12046032e-03,
         -2.37307486e-05,  -1.47388560e+01,   1.43423859e-01,
          8.86478231e-02,   4.99474387e-02,   1.02682252e+00,
         -3.27564432e-01,   3.51289467e-01,  -1.22623348e+00,
          1.45564343e-03,  -3.66336096e-01,   2.59755719e+01,
         -3.04612543e-01,   6.00273664e-02,  -2.38892252e-02,
         -3.16900445e+00,   3.39376959e-02,  -1.14821540e-01,
          1.77494526e-02,   4.21507587e-01,  -7.28246677e-03],
       [  0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  1.99246079e+01,  -3.75431559e-02,  -1.03781269e-02,
          7.53702373e-03,   2.48625158e-02,  -4.51643158e-02,
         -3.96049344e-03,  -7.99159422e-02,   4.67853878e-03,
         -7.05843656e-03,  -4.81038384e+01,   1.70118428e-01,
         -2.09789534e-02,   7.33855300e-03,   9.05375380e-01,
          6.51125700e-01,   4.25541995e-02,  -1.03303704e+00,
         -3.49421237e-01,   2.14306384e-01,   8.25935292e+00,
         -6.51484577e-03,   3.29105022e-03,  -1.01210012e-02,
         -9.38306279e-01,   4.29647245e-03,   1.30323496e-01,
          1.53647870e-01,   2.41476313e-02,  -4.49285174e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  4.80090352e+01,  -9.84772426e-03,   1.13992514e-02,
         -1.25715193e-03,   4.87680214e-02,   1.92610779e-02,
          8.25295927e-03,  -7.88669397e-02,  -8.82998981e-03,
          1.56441914e-02,  -5.96885619e+01,   2.01245244e-01,
         -8.96497362e-03,  -3.58217663e-02,   9.70949964e-01,
          3.96973682e-02,  -1.81326134e-02,  -1.09818814e+00,
         -4.90340222e-02,   1.92347788e-01,  -1.86240264e+01,
         -2.78698054e-02,   7.86958439e-03,  -5.09963436e-04,
         -1.52870071e+00,   4.33325562e-02,  -1.18872470e-02,
         -1.29415234e-01,   2.08005355e-01,   4.97811532e-03],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  1.31529579e+01,   2.15631549e-03,   4.35160102e-02,
         -7.98768517e-04,   1.16723746e-01,  -1.15062986e-03,
          3.51468965e-03,  -3.28633208e-02,  -1.74738542e-02,
          9.97974011e-03,   3.96427978e+01,  -8.74601086e-04,
         -1.46959905e-03,  -6.89872480e-03,   7.98837149e-01,
          6.11207462e-01,   5.02541757e-01,  -5.38754448e-01,
         -3.78151315e-01,   2.58527393e-02,  -1.78448619e+01,
          5.14591163e-02,  -1.74803212e-03,  -1.21833043e-02,
         -7.30995393e-01,  -5.30392088e-02,  -2.88584162e-02,
          1.94911304e-01,   1.77268403e-02,  -1.71822734e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  9.95481033e+00,   5.39900045e-04,   7.99883115e-03,
         -2.05860776e-03,   2.98981157e-02,  -8.44965773e-02,
         -4.33807113e-04,  -3.40961369e-02,   7.07211482e-03,
          6.82319386e-03,   4.88388193e+01,  -8.39342362e-04,
         -3.76878815e-02,   2.68423770e-02,   2.39244654e-01,
          2.66915280e-01,   4.15501974e-01,  -2.71292445e-01,
         -7.08624735e-02,   3.69368238e-02,  -2.77726478e+01,
         -6.16279921e-03,  -1.13553967e-02,   1.01468521e-02,
         -2.46278004e-01,  -2.87010896e-02,  -3.47328876e-02,
          4.85006230e-02,  -4.18656592e-02,   2.71016864e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00],
       [  2.55318909e+01,  -2.00676470e-02,  -6.76676886e-03,
          2.05169632e-03,   8.60994449e-02,   5.34656423e-02,
          4.93796388e-03,   3.36708656e-02,  -9.35387944e-03,
         -5.08436027e-03,   8.18875250e+00,   1.09845989e-01,
         -6.87865265e-02,   1.74548621e-06,   1.65167630e-01,
          9.86194950e-01,  -9.94621667e-02,  -7.06676126e-01,
          1.85517023e-01,  -6.65241242e-02,  -3.48569690e+01,
          2.36239355e-02,   6.22191370e-03,  -1.54562020e-03,
         -2.35464162e-01,  -1.85700517e-02,  -2.47708426e-02,
          4.35934839e-02,  -1.83993091e-02,  -6.76992947e-03]])
    nfev: 7089
     fun: 115970.92113683307
       x: array([  2.92517682e+03,   2.02306947e-01,  -2.19817465e-02,
        -6.65290725e-02,   5.50934735e+00,   6.82743773e+00,
         1.15468330e-01,   2.34520948e+00,  -3.24343094e-01,
        -3.52773070e-01,   2.31163927e+03,   1.48925987e-01,
         1.53575933e+00,   3.69048379e-01,   1.77859135e+01,
         1.62637380e+01,   7.54861177e+00,  -1.51377147e+01,
        -3.85370079e+00,   5.94510605e-01,   8.53114702e+02,
        -1.03911859e+00,  -2.52437757e+00,   4.44545531e-01,
         4.03024337e+00,   4.80323867e-01,   8.81549175e-01,
        -4.37640065e-01,  -5.54377817e-02,  -1.92415502e-01])
 message: 'Optimization terminated successfully.'
     nit: 21
album after 115970.921137

In [64]:
for image in album:
    imgpar0 = image.get_parameters_vector()
    print "image before", image(imgpar0)
    result = op.minimize(image, imgpar0)
    imgpar = result['x']
    print "image after", image(imgpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_4.pdf")


image before 6663.23385965
image after 5301.14608912
image before 2323.20505914
image after 2202.92728969
image before 2041.7124058
image after 1918.85454986
image before 8218.79382761
image after 6590.89329027
image before 2237.04724241
image after 1881.75142603
image before 1446.61472265
image after 1406.9953221
image before 2695.99158273
image after 2619.34760253
image before 1518.62468701
image after 1424.75790649
image before 2000.81885935
image after 1895.30918471
image before 3130.16827497
image after 2333.93522226
image before 3916.33478065
image after 3780.27712594
image before 1860.0387986
image after 1711.37506007
image before 2685.25416617
image after 2623.63930821
image before 5764.00611708
image after 5608.06057754
image before 3018.95408769
image after 2735.28154042
image before 4424.92646562
image after 4373.1921339
image before 2217.49130434
image after 1556.37403911
image before 4550.6988361
image after 3713.54794253
image before 3366.88000618
image after 2979.64377446
image before 2223.86487001
image after 1982.6579342
image before 2806.00374899
image after 2156.69161162
image before 2037.11778177
image after 1934.84677228
image before 4568.76315931
image after 4210.53407784
image before 3560.9962753
image after 3441.66258329
image before 5799.26086657
image after 5637.01386231
image before 5784.24316715
image after 5532.660435
image before 4702.92751263
image after 3947.47970227
image before 3191.25621138
image after 3078.95724101
image before 1487.14288078
image after 1450.94945107
image before 2735.48671591
image after 2539.51221729
image before 3407.65428385
image after 3315.69613437
image before 9564.50078947
image after 8744.23621392

In [65]:
galpar0 = album.galaxy.get_parameters_vector()
print "album before", album(galpar0)
result = op.minimize(album, galpar0, method="Powell")
#print result
galpar = result['x']
print "album after", album(galpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_5.pdf")


album before 104651.115412
album after 101345.027216

In [66]:
for image in album:
    imgpar0 = image.get_parameters_vector()
    print "image before", image(imgpar0)
    result = op.minimize(image, imgpar0)
    imgpar = result['x']
    print "image after", image(imgpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_6.pdf")


image before 4224.53270856
image after 4115.73472899
image before 2232.88867143
image after 2186.62544217
image before 1880.30087758
image after 1708.61595029
image before 5786.76005427
image after 5467.10842985
image before 1919.56579537
image after 1858.83212877
image before 1283.44110442
image after 1277.25130405
image before 2632.87409782
image after 2600.82519305
image before 1338.29303374
image after 1324.80751939
image before 1861.16332239
image after 1845.20584367
image before 2165.38933513
image after 2054.30463655
image before 3915.65300236
image after 3873.357456
image before 1720.71846846
image after 1711.92378041
image before 2625.29506728
image after 2592.99013977
image before 5800.52604578
image after 5749.93389018
image before 2417.29955236
image after 2387.21455489
image before 4499.76850447
image after 4414.85305025
image before 1521.77932538
image after 1460.93971193
image before 3502.48809491
image after 3465.99251233
image before 2787.80746718
image after 2752.55453609
image before 1888.69086736
image after 1818.61725696
image before 1776.49143589
image after 1746.88292865
image before 1630.53450217
image after 1622.57681211
image before 4557.4727147
image after 4529.47606663
image before 3096.56714847
image after 3032.36296748
image before 5524.83270882
image after 5480.23691377
image before 5802.02229122
image after 5208.64910395
image before 3770.72232772
image after 3579.77773239
image before 3240.1308358
image after 3160.20468126
image before 1346.39788799
image after 1337.05435252
image before 2363.85702965
image after 2315.29002056
image before 3072.78450741
image after 3022.02588586
image before 9136.05050981
image after 8880.68728878

In [67]:
galpar0 = album.galaxy.get_parameters_vector()
print "album before", album(galpar0)
result = op.minimize(album, galpar0, method="Powell")
#print result
galpar = result['x']
print "album after", album(galpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_7.pdf")


album before 98604.8407394
album after 95546.4044952

In [68]:
for image in album:
    imgpar0 = image.get_parameters_vector()
    print "image before", image(imgpar0)
    result = op.minimize(image, imgpar0)
    imgpar = result['x']
    print "image after", image(imgpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_8.pdf")


image before 3705.27565342
image after 3517.20186251
image before 2277.77862108
image after 1948.95439785
image before 1465.81291574
image after 1444.08575022
image before 4722.83767439
image after 4451.79294908
image before 1912.74966308
image after 1851.6839433
image before 1249.67764015
image after 1224.73360623
image before 2714.35943402
image after 2661.4584027
image before 1301.1173898
image after 1273.62850833
image before 1845.0194389
image after 1829.36199324
image before 2078.6386401
image after 1985.98224123
image before 4034.3795978
image after 3889.25182978
image before 1709.59928289
image after 1689.83439823
image before 2700.15588774
image after 2627.0363676
image before 5826.02606682
image after 5701.95811436
image before 2299.1103819
image after 2250.0534663
image before 4383.73092291
image after 4210.12175406
image before 1515.49495736
image after 1463.18286785
image before 3443.9779469
image after 3317.29783989
image before 2719.24771603
image after 2652.44786979
image before 1608.86188079
image after 1579.92940613
image before 1509.4515464
image after 1460.39683867
image before 1366.73967468
image after 1354.18195539
image before 4937.28802107
image after 3579.90715687
image before 2624.97224379
image after 2602.42846857
image before 5493.85441051
image after 5416.33939132
image before 4332.06764184
image after 4082.14058699
image before 3956.28464409
image after 3662.88108022
image before 3145.34993887
image after 3103.15285534
image before 1305.48631983
image after 1289.9143574
image before 2132.4130812
image after 2090.0054087
image before 2661.63212746
image after 2572.10182529
image before 8544.82447715
image after 8316.41816497

In [69]:
galpar0 = album.galaxy.get_parameters_vector()
print "album before", album(galpar0)
result = op.minimize(album, galpar0, method="Powell")
#print result
galpar = result['x']
print "album after", album(galpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_8.pdf")


album before 91122.0543149
album after 87908.2732927

In [70]:
for image in album:
    imgpar0 = image.get_parameters_vector()
    print "image before", image(imgpar0)
    result = op.minimize(image, imgpar0)
    imgpar = result['x']
    print "image after", image(imgpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_9.pdf")


image before 3440.51066441
image after 3304.88132074
image before 2008.87018954
image after 1928.13666856
image before 1368.05826486
image after 1347.66104387
image before 4031.91702514
image after 3485.04196338
image before 1729.01632668
image after 1667.71287985
image before 1231.10262461
image after 1222.50716673
image before 2781.61297982
image after 2647.57848549
image before 1245.30953331
image after 1230.05667963
image before 1789.256646
image after 1785.12003164
image before 1798.11841269
image after 1753.00262685
image before 3698.72684793
image after 3599.25372369
image before 1603.87948314
image after 1595.96636814
image before 2632.88040864
image after 2571.6290578
image before 5140.72871867
image after 5094.22236815
image before 2242.73200905
image after 2206.37933605
image before 4379.43568563
image after 4182.61958374
image before 1499.88431961
image after 1359.82974923
image before 3049.99547963
image after 2829.13694945
image before 2677.65828952
image after 2649.19738334
image before 1472.07695605
image after 1452.62977942
image before 1479.66195072
image after 1450.57482778
image before 1296.23484763
image after 1288.08457017
image before 2878.1759748
image after 2764.27358268
image before 2544.24918283
image after 2489.03964215
image before 5244.68943134
image after 4320.35844483
image before 3142.41584655
image after 3033.50428904
image before 4363.77317606
image after 3972.8265931
image before 3059.01171933
image after 3034.31958295
image before 1287.31639972
image after 1282.78776248
image before 1931.49810306
image after 1906.15985974
image before 2328.31744539
image after 2248.0687986
image before 8508.43956568
image after 8145.31229636

In [71]:
galpar0 = album.galaxy.get_parameters_vector()
print "album before", album(galpar0)
result = op.minimize(album, galpar0, method="Powell")
#print result
galpar = result['x']
print "album after", album(galpar)
#showme(album)
showme_small(album, v=True)
#plt.savefig("/Users/dalyabaron/Copy/Astrophysics/python/new_scripts/new_scripts/DeprojectAllGalaxies/fitting_pngs/run_10.pdf")


album before 83870.5922002
album after 78231.5345102

In [20]:
print result


  status: 0
 success: True
   direc: array([[  1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  2.21274453e+01,   2.89466172e-02,   2.63598780e-02,
          8.78263110e-03,  -6.44820008e-02,   7.37831574e-02,
         -1.00447227e-02,  -8.18948277e-03,  -3.05560073e-03,
         -1.20439755e-02,  -1.89005814e+01,  -1.53722532e-02,
          6.01945879e-04,   2.89236627e-03,   1.41905249e-01,
         -1.64379954e-02,   1.49198387e-02,  -3.03673327e-02,
         -4.56157739e-02,   1.05237842e-02,  -4.64865673e+00,
         -2.53254918e-02,   1.66035725e-02,  -8.20976278e-03,
         -7.16514283e-02,   6.83691591e-02,  -9.88318259e-04,
         -7.51723552e-03,  -2.01302663e-02,   1.75042306e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00],
       [  7.68210808e+00,  -2.15148527e-03,   1.02682968e-03,
          4.50237817e-04,  -5.54303211e-02,  -2.80431235e-02,
          1.71758936e-02,  -5.04315309e-02,  -1.68523118e-02,
         -1.82753956e-02,  -8.99005488e-02,   1.41996303e-02,
          4.79913157e-03,  -5.43372685e-04,   1.00080037e-01,
          8.82520674e-03,  -1.00337718e-03,  -3.23354896e-02,
          7.98188403e-03,   2.54085850e-03,   1.79410918e+00,
         -1.21290651e-02,   1.10125239e-02,  -5.79985343e-04,
         -6.37728730e-02,  -3.86086966e-02,   2.29796608e-03,
          5.49094570e-02,  -1.86320218e-02,   2.07445100e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [ -1.59590213e+01,   2.70661405e-03,  -5.72700063e-03,
          2.70386731e-03,  -3.21402973e-02,  -8.83596276e-02,
          1.75511386e-03,  -5.47824845e-02,  -8.78295635e-03,
          3.01374394e-03,   1.27366141e+01,   7.44287408e-03,
         -1.30539418e-03,   1.41097343e-03,  -4.65701504e-02,
         -6.93036524e-04,   4.27299352e-03,   1.00636993e-02,
          9.61155962e-04,  -3.13567673e-03,  -1.52019394e+01,
         -4.84086068e-03,  -1.59418192e-04,  -3.25226163e-03,
         -6.44096875e-02,  -1.07858011e-01,  -6.60823133e-03,
          7.88276981e-02,   4.09877360e-03,  -1.29092460e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  1.29839316e+01,  -2.57126508e-04,  -6.59289348e-03,
          1.09043947e-03,  -9.16211660e-02,   9.68426273e-03,
          1.26846229e-02,  -4.56505633e-02,  -2.64343624e-03,
         -1.86385695e-02,   5.13125348e+00,  -1.54141949e-02,
          1.76751717e-03,   2.28816108e-03,  -1.04676081e-01,
          6.40605651e-03,  -4.53183307e-03,   3.36522961e-02,
          3.88702431e-02,  -6.11939178e-03,  -1.61487160e+01,
         -1.15847380e-02,   5.04482251e-03,  -2.20939505e-04,
         -7.37996421e-02,   2.51368073e-02,   6.73012922e-04,
          1.51578291e-02,  -2.55093594e-02,   3.07148483e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  1.94453846e+01,  -1.22409481e-02,  -1.42128330e-02,
          1.17003610e-02,  -1.47203982e-01,  -1.40183526e-01,
          4.10482827e-03,  -1.53278507e-01,   3.52077598e-02,
          3.68047290e-02,   4.98899900e+00,  -3.42091519e-02,
          1.03121381e-02,   1.93807556e-03,   2.27091886e-01,
         -3.26447696e-02,   8.85400184e-03,   2.39527568e-02,
         -4.41723633e-02,   2.61420926e-03,  -2.06582734e+01,
          9.70504567e-03,  -1.99662554e-02,  -6.90456224e-03,
         -2.06685541e-01,  -1.57759396e-01,  -3.18728746e-03,
          1.82360408e-01,   2.12904880e-02,  -2.06174488e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [ -2.48339891e+00,  -3.57946426e-03,   5.63691318e-03,
         -1.65697177e-03,  -7.91482421e-02,  -5.69326092e-02,
         -1.35948007e-02,  -7.31478144e-02,   3.72823643e-02,
          3.54995084e-02,   1.56576479e-01,  -1.22928460e-02,
          3.18566703e-03,   8.33439587e-04,   1.63509938e-01,
          6.67630178e-03,   1.14434215e-04,  -2.61377266e-02,
         -2.88919368e-02,   3.78065999e-03,  -1.83441989e+01,
          2.20470799e-02,  -2.14123480e-02,  -1.57307055e-03,
         -1.08301837e-01,  -7.23443738e-02,  -5.96557756e-03,
          8.29441897e-02,   2.97627086e-02,  -3.01119042e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
       [ -2.10072526e+00,  -1.48028939e-02,  -1.33298742e-02,
         -1.13549332e-03,  -3.09624141e-02,  -1.59998699e-02,
          2.65408630e-03,  -2.31039462e-02,  -6.29545925e-03,
         -9.77951431e-03,  -8.56230102e+00,   1.00485643e-02,
         -6.47094285e-04,   1.59931003e-03,   2.37062881e-02,
         -1.50536039e-02,  -1.21526625e-02,   1.15287918e-02,
          2.26481020e-02,  -7.60910048e-03,   1.77413330e+00,
         -3.27624612e-03,   4.24645164e-03,   3.06086342e-04,
         -2.58613644e-02,  -1.73305604e-02,   7.58103671e-03,
          2.41158722e-02,  -1.77559171e-02,   2.23839023e-02],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          0.00000000e+00,   1.00000000e+00,   0.00000000e+00],
       [ -1.78393252e-03,   2.15953064e-02,   2.31960957e-02,
         -1.21705700e-02,  -8.79597109e-02,  -4.70503507e-02,
         -1.95234969e-02,  -6.91168053e-02,   4.05193007e-02,
          3.31489557e-02,   3.42252902e+00,  -3.94570617e-02,
          6.76772402e-03,   4.75626499e-03,   9.09457492e-02,
          1.14770156e-03,  -4.05044350e-03,   5.67044803e-04,
          3.05197680e-04,  -1.91542551e-03,  -2.76905272e+00,
          4.74008753e-03,  -1.10029232e-02,   3.56108619e-03,
         -4.09561643e-02,  -9.38023831e-02,   5.73147108e-03,
          6.94492448e-02,   1.44759743e-02,  -1.42385061e-02]])
    nfev: 6585
     fun: 52059.744707787984
       x: array([  1.46261862e+03,   1.44495368e+00,  -7.30140904e-01,
         6.60616490e-03,   3.59686742e+00,   3.67746423e+00,
         8.03509574e-01,   3.22867216e+00,  -1.01447719e+00,
        -1.13941024e+00,   1.62868919e+03,   1.94652151e-01,
         1.43801027e+00,   6.74660476e-02,   7.85318028e+00,
         7.33807872e-01,   4.59171145e-01,  -1.06055056e+00,
        -7.86178774e-01,   1.08887559e-01,   1.60819664e+03,
        -1.96857579e+00,  -9.17569157e-01,   2.51030326e-01,
         5.05484828e+00,   4.80938284e+00,   4.74499886e-01,
        -4.51208037e+00,  -4.64838060e-01,   4.97666076e-01])
 message: 'Optimization terminated successfully.'
     nit: 19