title: Curve Fitting For 3 dimensional data in python
body: <p>I have X and Y data with (7,360,720) dimension (global grid cells with 0.5 resolution) as input data and I want to fit Sigmoid curve with below code and obtaining curve parameters in the same shape as X and Y:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import  os, sys
  from    collections import OrderedDict  as odict
  import  numpy   as np
  import  pylab   as pl
  import numpy.ma as ma
  from scipy.optimize import curve_fit
  
  
  f=open('test.csv','w')
  def sigmoid(x,a,b, c):
          y = a+(b*(1 - np.exp(-c*(x**2))))
          return y
  for i in range(360):
        for j in range(720):
          xdata=[0,x[0,i,j],x[1,i,j],x[2,i,j],x[3,i,j],x[4,i,j],x[5,i,j],x[6,i,j]] 
          ydata=[0,y[0,i,j],y[1,i,j],y[2,i,j],y[3,i,j],y[4,i,j],y[5,i,j],y[6,i,j]]
          popt, pcov = curve_fit(sigmoid, xdata, ydata)
          print popt
          f.write(','.join(map(str,popt)))
          f.write("\n")
  f.close()
  </code></pre>
  
  <p>Now this code write and sore fitting result in .csv file with 3 columns(a,b,c), but I want o write and store fitting result in the file with (360,720) shape as grid cells. also this code show me below error:
  RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 800.</p>