Changeset 4008 in Sophya


Ignore:
Timestamp:
Jun 23, 2011, 2:53:23 PM (13 years ago)
Author:
cmv
Message:

add a 2sd power law in frequency for GSM fit, cmv 23/06/2011

Location:
trunk/Cosmo/SimLSS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/SimLSS/cmvgsmcfit.cc

    r3983 r4008  
    2525public:
    2626  MyFCN(TVector<r_4>& FreqMHz,TVector<r_4>& V,TVector<r_4>& EV);
     27  void SetNu0(double nu0Mhz) {_nu0 = nu0Mhz;}
     28  void SetTyp(bool law2 = false) {_law2 = law2;}
    2729  void InitFit(MnUserParameters& upar);
    2830  double Func(double fr,const vector<double>& par) const;
    2931  double operator()(const vector<double>& par) const;
    3032  double Up(void) const {return 1.;}
    31   void SetNu0(double nu0Mhz) {_nu0 = nu0Mhz;}
    3233  //protected:
    3334  double _nu0;
     35  bool _law2;
    3436  mutable int _ndata;
    3537  TVector<r_4> _F;
     
    4345{
    4446  int nslicemax = -1;
     47  int typfit = 0;
    4548  if(narg<=1) {
    46     cout<<"cmvgsmcfit cubefile.ppf [nslicemax]"<<endl;
     49    cout<<"cmvgsmcfit cubefile.ppf [nslicemax] [typfit=0,1]"<<endl;
    4750    return -1;
    4851  }
    4952
    5053  if(narg>2) nslicemax = atoi(arg[2]);
    51   cout<<"Fitting "<<arg[1]<<" , nslicemax="<<nslicemax<<endl;
     54  if(narg>3) typfit = atoi(arg[3]);
     55  cout<<"Fitting "<<arg[1]<<" , nslicemax="<<nslicemax<<" , typfit="<<typfit<<endl;
    5256
    5357int rc = 0;
     
    6165  pis>>PPFNameTag("freq")>>Freq;
    6266
    63   const int nvar = 8;
    64   const char *vname[nvar] = {"x2r","ok","ph","th","v0","vn","A","N"};
     67  const int nvar = 10;
     68  const char *vname[nvar] = {"x2r","ok","ph","th","v0","vn","A","N","B","DN"};
    6569  NTuple nt(nvar,vname);
    6670  double xnt[nvar]; for(int i=0;i<nvar;i++) xnt[i] = 0.;
     
    7074    cout<<"...j = "<<j<<endl;
    7175  for(int k=0;k<Cube.SizeZ();k++) {
     76    //cout<<"...k = "<<k<<endl;
    7277
    7378    TVector<r_4> V(Cube.SizeX()), EV(Cube.SizeX());
     
    7984    MyFCN myfcn(Freq,V,EV);
    8085    myfcn.SetNu0(Freq(0));
     86    //myfcn.SetNu0((Freq(0)+Freq(Freq.Size()-1))/2.);
     87    myfcn.SetTyp( ((typfit==1)? true: false) );
    8188    MnUserParameters upar;
    8289    myfcn.InitFit(upar);
     
    102109    xnt[2] = j; xnt[3] = k;
    103110    xnt[4] = V(0); xnt[5] = V(V.Size()-1);
    104     for(unsigned int i=0;i<par.size();i++) xnt[6+i] = par[i];
     111    for(int i=6;i<6+par.size() && i<nvar;i++) xnt[i] = par[i-6];
    105112    nt.Fill(xnt);
    106113    //vector<double> err = ustate.Errors();
     
    155162    throw SzMismatchError("MyFCN::MyFCN_Error: incompatible F / V / EV sizes");
    156163  _nu0 = _F(0);
     164  _law2 = false;
    157165  _ndata =_V.Size();
    158166}
     
    165173
    166174  upar.Add("A",a,a/50.);
    167   upar.Add("N",ni,fabs(ni/50.));
     175  upar.Add("Nu",ni,fabs(ni/50.));
     176
     177  if(!_law2) return;
     178  upar.Add("B",0.,a/200.);
     179  upar.Add("DNu",0.,fabs(ni/200.));
     180 
    168181}
    169182
    170183double MyFCN::Func(double fr,const vector<double>& par) const
    171 // v = A*(nu/nu0)^N
     184// v = A*(nu/nu0)^Nu
     185// v = A*(nu/nu0)^Nu + B/A*(nu/nu0)^(Nu+DNu) = A*(nu/nu0)^Nu * (1 + B*(nu/nu0)^DNu)
    172186{
    173187 double f = par[0]*pow(fr/_nu0,par[1]);
     188 if(_law2) f *= 1. + par[2]*pow(fr/_nu0,par[3]);
    174189 return f;
    175190}
     
    210225n/plot nt.log10(v0/vn)%v0 ! ! "crossmarker3"
    211226
    212 
    213227zone
    214 n/plot nt.A%_nl ! ! "crossmarker3"
    215 n/plot nt.N%_nl ! ! "crossmarker3"
    216 
    217 n/plot nt.A%v0 ! ! "crossmarker3"
    218 n/plot nt.(A-v0)/v0%_nl ! ! "crossmarker3"
    219 n/plot nt.N%A ! ! "crossmarker3"
     228n/plot nt.A%_nl ok>0 ! "crossmarker3"
     229n/plot nt.N%_nl ok>0 ! "crossmarker3"
     230n/plot nt.B%_nl ok>0 ! "crossmarker3"
     231n/plot nt.DN%_nl ok>0 ! "crossmarker3"
     232
     233n/plot nt.A%v0 ok>0 ! "crossmarker3"
     234n/plot nt.(A-v0)/v0%_nl ok>0 ! "crossmarker3"
     235
     236n/plot nt.N%A ok>0 ! "crossmarker3"
     237n/plot nt.B%A ok>0 ! "crossmarker3"
     238n/plot nt.DN%N ok>0 ! "crossmarker3"
    220239
    221240set n 0
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3924 r4008  
    964964---- ATTENTION: Le spectre Pk doit etre (dRho/Rho)(k)
    965965---- On genere la vitesse particuliere (dans le referentiel comobile au redshift "z")
    966      Vlos(k) = i*Beta(z)*k(los)/k^2*(dRho/Rho)(k)
     966     Vlos(k) = i*Beta(z)*k(los)/k^2*(dRho/Rho)(k)    (unite Mpc)
    967967        .avec Beta(z) = dln(D)/da = -(1+z)/D*dD/dz
    968         .on convertit en vitesse en faisant Vlos(k)/H(z)
     968        .puis on convertit en vitesse en faisant Vlos(k) * H(z)    (unite lm/s)
    969969*/
    970970{
Note: See TracChangeset for help on using the changeset viewer.