Changeset 3271 in Sophya for trunk/Cosmo/SimLSS/genefluct3d.cc
- Timestamp:
- Jun 20, 2007, 6:50:48 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/genefluct3d.cc
r3267 r3271 31 31 //------------------------------------------------------- 32 32 GeneFluct3D::GeneFluct3D(TArray< complex<r_8 > >& T) 33 : T_(T) , Nx_(0) , Ny_(0) , Nz_(0) , array_allocated_(false) , lp_(0) 34 , redshref_(-999.) , kredshref_(0.) , cosmo_(NULL) , growth_(NULL) 35 , loscom_ref_(-999.), loscom_min_(-999.), loscom_max_(-999.) 33 : Nx_(0) , Ny_(0) , Nz_(0) 34 , lp_(0) 35 , array_allocated_(false) , T_(T) 36 , cosmo_(NULL) , growth_(NULL) 37 , redsh_ref_(-999.), kredsh_ref_(0.), dred_ref_(-999.) 38 , loscom_ref_(-999.), dtrc_ref_(-999.), dlum_ref_(-999.), dang_ref_(-999.) 39 , nu_ref_(-999.), dnu_ref_ (-999.) 40 , loscom_min_(-999.), loscom_max_(-999.) 36 41 , loscom2zred_min_(0.) , loscom2zred_max_(0.) 37 42 { … … 76 81 if(kredshref<0.) { 77 82 if(Nz_<=0) { 78 char *bla = "GeneFluct3D::SetObservator_Error: for kredsh ref<0 SetSize should be called first";83 char *bla = "GeneFluct3D::SetObservator_Error: for kredsh_ref<0 SetSize should be called first"; 79 84 cout<<bla<<endl; throw ParmError(bla); 80 85 } 81 86 kredshref = Nz_/2.; 82 87 } 83 redsh ref_ = redshref;84 kredsh ref_ = kredshref;88 redsh_ref_ = redshref; 89 kredsh_ref_ = kredshref; 85 90 if(lp_>0) 86 cout<<"--- GeneFluct3D::SetObservator zref="<<redsh ref_<<" kref="<<kredshref_<<endl;91 cout<<"--- GeneFluct3D::SetObservator zref="<<redsh_ref_<<" kref="<<kredsh_ref_<<endl; 87 92 } 88 93 … … 206 211 if(lp_>0) cout<<"--- LosComRedshift: zinc="<<zinc<<" , npoints="<<npoints<<endl; 207 212 208 if(cosmo_ == NULL || redsh ref_<0.) {213 if(cosmo_ == NULL || redsh_ref_<0.) { 209 214 char *bla = "GeneFluct3D::LosComRedshift_Error: set Observator and Cosmology first"; 210 215 cout<<bla<<endl; throw ParmError(bla); 216 } 217 218 // La distance angulaire/luminosite/Dnu au pixel de reference 219 dred_ref_ = Dz_/(cosmo_->Dhubble()/cosmo_->E(redsh_ref_)); 220 loscom_ref_ = cosmo_->Dloscom(redsh_ref_); 221 dtrc_ref_ = cosmo_->Dtrcom(redsh_ref_); 222 dlum_ref_ = cosmo_->Dlum(redsh_ref_); 223 dang_ref_ = cosmo_->Dang(redsh_ref_); 224 nu_ref_ = Fr_HyperFin_Par/(1.+redsh_ref_); // GHz 225 dnu_ref_ = Fr_HyperFin_Par *dred_ref_/pow(1.+redsh_ref_,2.); // GHz 226 if(lp_>0) { 227 cout<<"...reference pixel redshref="<<redsh_ref_ 228 <<", dredref="<<dred_ref_ 229 <<", nuref="<<nu_ref_ <<" GHz" 230 <<", dnuref="<<dnu_ref_ <<" GHz"<<endl 231 <<" dlosc="<<loscom_ref_<<" Mpc com" 232 <<", dtrc="<<dtrc_ref_<<" Mpc com" 233 <<", dlum="<<dlum_ref_<<" Mpc" 234 <<", dang="<<dang_ref_<<" Mpc"<<endl; 211 235 } 212 236 … … 214 238 // cad dans le repere ou l'origine est au centre du pixel i=j=l=0. 215 239 // L'observateur est sur un axe centre sur le milieu de la face Oxy 216 double loscom_ref_ = cosmo_->Dloscom(redshref_);217 240 xobs_[0] = Nx_/2.*Dx_; 218 241 xobs_[1] = Ny_/2.*Dy_; 219 xobs_[2] = kredsh ref_*Dz_ - loscom_ref_;242 xobs_[2] = kredsh_ref_*Dz_ - loscom_ref_; 220 243 221 244 // L'observateur est-il dans le cube? … … 229 252 if(!obs_in_cube) loscom_min_ = -xobs_[2]; 230 253 254 // TO BE FIXED TO BE FIXED TO BE FIXED TO BE FIXED TO BE FIXED TO BE FIXED 255 if(loscom_min_<=1.e-50) 256 for(int i=0;i<50;i++) 257 cout<<"ATTENTION TOUTES LES PARTIES DU CODE NE MARCHENT PAS POUR UN OBSERVATEUR DANS LE CUBE"<<endl; 258 // TO BE FIXED TO BE FIXED TO BE FIXED TO BE FIXED TO BE FIXED TO BE FIXED 259 260 231 261 // Find MAXIMUM los com distance to the observer: 232 262 // ou que soit positionne l'observateur, la distance … … 234 264 loscom_max_ = 0.; 235 265 for(long i=0;i<=1;i++) { 236 double dx2 = xobs_[0] - i*(Nx_-1)*Dx_; dx2 *= dx2;266 double dx2 = DXcom(i*(Nx_-1)); dx2 *= dx2; 237 267 for(long j=0;j<=1;j++) { 238 double dy2 = xobs_[1] - j*(Ny_-1)*Dy_; dy2 *= dy2;268 double dy2 = DYcom(j*(Ny_-1)); dy2 *= dy2; 239 269 for(long k=0;k<=1;k++) { 240 double dz2 = xobs_[2] - k*(Nz_-1)*Dz_; dz2 *= dz2;270 double dz2 = DZcom(k*(Nz_-1)); dz2 *= dz2; 241 271 dz2 = sqrt(dx2+dy2+dz2); 242 272 if(dz2>loscom_max_) loscom_max_ = dz2; … … 245 275 } 246 276 if(lp_>0) { 247 cout<<"...zref="<<redsh ref_<<" kzref="<<kredshref_<<" losref="<<loscom_ref_<<" Mpc\n"277 cout<<"...zref="<<redsh_ref_<<" kzref="<<kredsh_ref_<<" losref="<<loscom_ref_<<" Mpc\n" 248 278 <<" xobs="<<xobs_[0]<<" , "<<xobs_[1]<<" , "<<xobs_[2]<<" Mpc " 249 279 <<" in_cube="<<obs_in_cube 250 <<" loscom_min="<<loscom_min_<<" loscom_max="<<loscom_max_<<" Mpc "<<endl;280 <<" loscom_min="<<loscom_min_<<" loscom_max="<<loscom_max_<<" Mpc (com)"<<endl; 251 281 } 252 282 … … 312 342 fwrt.WriteKey("DKY",Dky_," Mpc^-1"); 313 343 fwrt.WriteKey("DKZ",Dkz_," Mpc^-1"); 314 fwrt.WriteKey("ZREF",redsh ref_," reference redshift");315 fwrt.WriteKey("KZREF",kredsh ref_," reference redshift on z axe");344 fwrt.WriteKey("ZREF",redsh_ref_," reference redshift"); 345 fwrt.WriteKey("KZREF",kredsh_ref_," reference redshift on z axe"); 316 346 fwrt.Write(R_); 317 347 } catch (PThrowable & exc) { … … 364 394 R_.Info()["DY"] = (r_8)Dy_; 365 395 R_.Info()["DZ"] = (r_8)Dz_; 366 R_.Info()["ZREF"] = (r_8)redsh ref_;367 R_.Info()["KZREF"] = (r_8)kredsh ref_;396 R_.Info()["ZREF"] = (r_8)redsh_ref_; 397 R_.Info()["KZREF"] = (r_8)kredsh_ref_; 368 398 POutPersist pos(cfname.c_str()); 369 399 if(write_real) pos << PPFNameTag("rgen") << R_; … … 432 462 <<", Kmax="<<GetKmax()<<" Mpc^-1"<<endl; 433 463 cout<<" (2Pi/k: "<<2.*M_PI/Knyqx_<<" "<<2.*M_PI/Knyqy_<<" "<<2.*M_PI/Knyqz_<<" Mpc)"<<endl; 434 cout<<"Redshift "<<redsh ref_<<" for z axe at k="<<kredshref_<<endl;464 cout<<"Redshift "<<redsh_ref_<<" for z axe at k="<<kredsh_ref_<<endl; 435 465 } 436 466 … … 1044 1074 // de l'histo ne sont pas vraiment ce que l'on veut 1045 1075 // --- Limitations actuelle du code: 1046 // . les AGN sont supposes e n loi de puissance IDENTIQUEpour tout theta,phi1076 // . les AGN sont supposes evoluer avec la meme loi de puissance pour tout theta,phi 1047 1077 // . le flux des AGN est mis dans une colonne Oz (indice k) et pas sur la ligne de visee 1048 1078 // . la distribution est approximee a une gaussienne … … 1050 1080 // et pour un cube peu epais / distance observateur 1051 1081 // --- Parametres de la routine: 1052 // llfy : c'est le <log10(S)> du flux depose dans un pixel par les AGN 1053 // lsigma : c'est le sigma de la distribution 1054 // powlaw : c'est la pente de ls distribution cad que le flux "lmsol" 1082 // llfy : c'est le <log10(S)> du flux depose par les AGN 1083 // dans l'angle solide du pixel elementaire de reference du cube 1084 // lsigma : c'est le sigma de la distribution des log10(S) 1085 // powlaw : c'est la pente de la distribution cad que le flux "lmsol" 1055 1086 // et considere comme le flux a 1.4GHz et qu'on suppose une loi 1056 1087 // F(nu) = (1.4GHz/nu)^powlaw * F(1.4GHz) … … 1064 1095 check_array_alloc(); 1065 1096 1066 if(cosmo_ == NULL || redsh ref_<0.| loscom2zred_.size()<1) {1097 if(cosmo_ == NULL || redsh_ref_<0.| loscom2zred_.size()<1) { 1067 1098 char *bla = "GeneFluct3D::AddAGN_Error: set Observator and Cosmology first"; 1068 1099 cout<<bla<<endl; throw ParmError(bla); 1069 1100 } 1070 1101 1071 // La distance angulaire/luminosite/Dnu au centre 1072 double dangref = cosmo_->Dang(redshref_); 1073 double dlumref = cosmo_->Dlum(redshref_); 1074 double dredref = Dz_/(cosmo_->Dhubble()/cosmo_->E(redshref_)); 1075 double dnuref = Fr_HyperFin_Par *dredref/pow(1.+redshref_,2.); // GHz 1076 double fagnref = pow(10.,lfjy)*(dnuref*1.e9); // Jy.Hz 1077 double magnref = FluxHI2Msol(fagnref*Jansky2Watt_cst,dlumref); // Msol 1078 if(lp_>0) { 1079 cout<<"Au centre: z="<<redshref_<<", dredref="<<dredref<<", dnuref="<<dnuref<<" GHz"<<endl 1080 <<" dang="<<dangref<<" Mpc, dlum="<<dlumref<<" Mpc," 1081 <<" fagnref="<<fagnref<<" Jy.Hz (a 1.4GHz), magnref="<<magnref<<" Msol"<<endl; 1082 } 1102 // Le flux des AGN en Jy et en mass solaire 1103 double fagnref = pow(10.,lfjy)*(dnu_ref_*1.e9); // Jy.Hz = W/m^2 1104 double magnref = FluxHI2Msol(fagnref*Jansky2Watt_cst,dlum_ref_); // Msol 1105 if(lp_>0) 1106 cout<<"Au pixel de ref: fagnref="<<fagnref 1107 <<" Jy.Hz (a 1.4GHz), magnref="<<magnref<<" Msol"<<endl; 1083 1108 1084 1109 if(powlaw!=0.) { 1085 // F(nu) = (nu GHz/1.4 Ghz)^p * F(1.4GHz) et nu = 1.4 GHz /(1+z)1086 magnref *= pow(1/(1.+redsh ref_),powlaw);1110 // F(nu) = F(1.4GHz)*(nu GHz/1.4 Ghz)^p = F(1.4GHz)*(1/(1+z))^p , car nu = 1.4 GHz/(1+z) 1111 magnref *= pow(1/(1.+redsh_ref_),powlaw); 1087 1112 if(lp_>0) cout<<" powlaw="<<powlaw<<" -> change magnref to "<<magnref<<" Msol"<<endl; 1088 1113 } … … 1091 1116 vector<double> correction; 1092 1117 InterpFunc interpinv(loscom2zred_min_,loscom2zred_max_,loscom2zred_); 1118 long nzmod = ((Nz_>10)?Nz_/10:1); 1093 1119 for(long l=0;l<Nz_;l++) { 1094 double z = fabs( xobs_[2] - l*Dz_);1120 double z = fabs(DZcom(l)); 1095 1121 double zred = interpinv(z); 1096 double d ang = cosmo_->Dang(zred); // pour variation angle solide1122 double dtrc = cosmo_->Dtrcom(zred); // pour variation angle solide 1097 1123 double dlum = cosmo_->Dlum(zred); // pour variation conversion mass HI 1098 1124 double dred = Dz_/(cosmo_->Dhubble()/cosmo_->E(zred)); 1099 1125 double dnu = Fr_HyperFin_Par *dred/pow(1.+zred,2.); // pour variation dNu 1100 double corr = dnu/dnuref*pow(dangref/dang*dlum/dlumref,2.); 1101 if(powlaw!=0.) corr *= pow((1.+redshref_)/(1.+zred),powlaw); 1126 // on a: Mass ~ DNu * Dlum^2 / Dtrcom^2 1127 double corr = dnu/dnu_ref_*pow(dtrc_ref_/dtrc*dlum/dlum_ref_,2.); 1128 // F(nu) = F(1.4GHz)*(nu GHz/1.4 Ghz)^p = F(1.4GHz)*(1/(1+z))^p , car nu = 1.4 GHz/(1+z) 1129 if(powlaw!=0.) corr *= pow((1.+redsh_ref_)/(1.+zred),powlaw); 1102 1130 correction.push_back(corr); 1103 if(lp_>0 && (l==0 || abs(l-Nz_/2)<2 || l==Nz_-1)) {1104 cout<<"l="<<l<<" z="<<z<<" red="<<zred 1105 <<" d a="<<dang<<" dlu="<<dlum<<" dred="<<dred1106 <<" dnu="<<dnu<<" -> corr="<<corr<<endl;1131 if(lp_>0 && (l==0 || l==Nz_-1 || l%nzmod==0)) { 1132 cout<<"l="<<l<<" z="<<z<<" red="<<zred<<" dred="<<dred<<" dnu="<<dnu 1133 <<" dtrc="<<dtrc<<" dlum="<<dlum 1134 <<" -> cor="<<corr<<endl; 1107 1135 } 1108 1136 } … … 1134 1162 check_array_alloc(); 1135 1163 1164 vector<double> correction; 1165 InterpFunc *intercor = NULL; 1166 1167 if(with_evol) { 1168 // Sigma_Noise(en mass) : 1169 // Slim ~ 1/sqrt(DNu) * sqrt(nlobe) en W/m^2Hz 1170 // Flim ~ sqrt(DNu) * sqrt(nlobe) en W/m^2 1171 // Mlim ~ sqrt(DNu) * (Dlum)^2 * sqrt(nlobe) en Msol 1172 // nlobe ~ 1/Dtrcom^2 1173 // Mlim ~ sqrt(DNu) * (Dlum)^2 / Dtrcom 1174 if(cosmo_ == NULL || redsh_ref_<0.| loscom2zred_.size()<1) { 1175 char *bla = "GeneFluct3D::AddNoise2Real_Error: set Observator and Cosmology first"; 1176 cout<<bla<<endl; throw ParmError(bla); 1177 } 1178 InterpFunc interpinv(loscom2zred_min_,loscom2zred_max_,loscom2zred_); 1179 long nsz = loscom2zred_.size(), nszmod=((nsz>10)? nsz/10: 1); 1180 for(long i=0;i<nsz;i++) { 1181 double d = interpinv.X(i); 1182 double zred = interpinv(d); 1183 double dtrc = cosmo_->Dtrcom(zred); // pour variation angle solide 1184 double dlum = cosmo_->Dlum(zred); // pour variation conversion mass HI 1185 double dred = Dz_/(cosmo_->Dhubble()/cosmo_->E(zred)); 1186 double dnu = Fr_HyperFin_Par *dred/pow(1.+zred,2.); // pour variation dNu 1187 double corr = sqrt(dnu/dnu_ref_) * pow(dlum/dlum_ref_,2.) * dtrc_ref_/dtrc; 1188 if(lp_>0 && (i==0 || i==nsz-1 || i%nszmod==0)) 1189 cout<<"i="<<i<<" d="<<d<<" red="<<zred<<" dred="<<dred<<" dnu="<<dnu 1190 <<" dtrc="<<dtrc<<" dlum="<<dlum<<" -> cor="<<corr<<endl; 1191 correction.push_back(corr); 1192 } 1193 intercor = new InterpFunc(loscom2zred_min_,loscom2zred_max_,correction); 1194 } 1195 1196 double dx2=0., dy2=0., dz2=0.; 1136 1197 for(long i=0;i<Nx_;i++) { 1198 dx2 = DXcom(i); dx2 *= dx2; 1137 1199 for(long j=0;j<Ny_;j++) { 1200 dy2 = DYcom(j); dy2 *= dy2; 1138 1201 for(long l=0;l<Nz_;l++) { 1202 double corr = 1.; 1203 if(with_evol) { 1204 dz2 = DZcom(l); dz2 *= dz2; dz2 = sqrt(dx2+dy2+dz2); 1205 corr = (*intercor)(dz2); 1206 } 1139 1207 int_8 ip = IndexR(i,j,l); 1140 data_[ip] += snoise* NorRand();1141 } 1142 } 1143 } 1144 1145 } 1146 1208 data_[ip] += snoise*corr*NorRand(); 1209 } 1210 } 1211 } 1212 1213 if(intercor!=NULL) delete intercor; 1214 }
Note:
See TracChangeset
for help on using the changeset viewer.