0

I would like to do a minimization and so determine some parameters and one which represent some translations. But i have translations in X and Y directions. I would like to know if it s possible to distingish them? Currently i have the "A2" parameter which take in count the 2 directions but i would like to get A2x and A2y for 2 directions... (i cant minimize in each direction...too easy if i can do that).

import numpy as np
import numpy.ma as ma


def test(vars, r, theta, donnees):
    Kappa = vars[0]
    A2 = vars[1]
    modele = ma.masked_invalid((Kappa + 1/2. + (-1))*np.cos(1*theta/2.) - 5/2.*np.cos((5-4)*theta/2.) +A2)  
    return (donnees-modele)   


#r and theta correspond to polar coordinates and 

from scipy.optimize import leastsq
vars = [Kappa, A2] #KI
identif = sco.leastsq(test, vars, args=(rvect, thetavect, Depvect),epsfcn=0.0001)

I m looking for to get something like that :

def test2(vars, r, theta, donnees):
    Kappa = vars[0]
    A2x = vars[1]
    A2y = vars[2]
    modele = ma.masked_invalid((Kappa + 1/2. + (-1))*np.cos(1*theta/2.) - 5/2.*np.cos((5-4)*theta/2.) +A2x + A2y)  
    return (donnees-modele)   
jww
  • 97,681
  • 90
  • 411
  • 885
user3601754
  • 3,792
  • 11
  • 43
  • 77
  • 1
    It's not clear what you want, what you have or how you expect to get there with what you've done. This makes it difficult for us to help, so please give **full example input and output** and explain what you've tried. – Veedrac Jan 04 '15 at 09:42
  • 1
    It doesn't matter what role the variables have, if they are x or y. They are just input variables of the optimization problem. If the resulting function is multidimensional, just add the squared distance to the data over all pixels. I believe scipy does that automatically. – NoDataDumpNoContribution Jan 04 '15 at 09:53
  • so work with the norm of the vector? yep it must work! :) thanks – user3601754 Jan 04 '15 at 10:59

0 Answers0