std::ifstreamIN(infile.c_str(),std::ios::in);// open file
if(IN)
{
std::getline(IN,line1);
std::istringstreamread1(line1);// create a stream for the line
read1>>first;
while(strncmp(first.c_str(),"finish",6)!=0)// read line by line until finish is reached
{
if(strncmp(first.c_str(),"cosmolog",8)==0){// if the line contains information about cosmology
std::getline(IN,line2);// read the line word by word
std::istringstreamread2(line2);
read2>>second>>third;
while(strncmp(second.c_str(),"end",3)!=0)// Go ahead until "end" is reached
{
if(!strcmp(second.c_str(),"model"))// set model of universe
{
Cosmology.model=atoi(third.c_str());
}
elseif(!strcmp(second.c_str(),"H0"))// set Hubble constant
{
Cosmology.H0=atof(third.c_str());
Cosmology.h=Cosmology.H0/50.;
}
elseif(!strcmp(second.c_str(),"omegaM")||!strcmp(second.c_str(),"omega"))// set density of matter
{
Cosmology.omegaM=atof(third.c_str());
}
elseif(!strcmp(second.c_str(),"omegaX")||!strcmp(second.c_str(),"lambda"))// set cosmological constant
{
Cosmology.omegaX=atof(third.c_str());
}
elseif(!strcmp(second.c_str(),"wX")||!strcmp(second.c_str(),"q")||!strcmp(second.c_str(),"w0"))// set "q" for Model 2, "wX" for Model 3, "w0" for Model 4
{
Cosmology.wX=atof(third.c_str());
}
elseif(!strcmp(second.c_str(),"wa")||!strcmp(second.c_str(),"n")||!strcmp(second.c_str(),"delta")||!strcmp(second.c_str(),"w1"))// set "n" for Model 2, "delta" for model 3, "w1" for model 4
{
Cosmology.wa=atof(third.c_str());
}
elseif(!strcmp(second.c_str(),"omegaK"))// set universe curvature
if(!strncmp(second.c_str(),"Debug",5))// Read in if we are in debug mode
{
runmode->debug=1;
}
// Read the next line
std::getline(IN,line2);
std::istringstreamread2(line2);
read2>>second>>third;
}
}
elseif(!strncmp(first.c_str(),"potent",6))// each time we find a "potential" string in the configuration file, we add an halo
{
numberPotentials++;
std::getline(IN,line2);
std::istringstreamread2(line2);
doublez(0);
read2>>second>>third;
//std::cout << second << third << std::endl;
if(strcmp(second.c_str(),"end")==0)// Move to next potential and initialize it
{
if(z==0.)// Check if redshift from current halo was initialized
{
fprintf(stderr,"ERROR: A redshift is not defined for a potential \n");
exit(-1);
}
break;// Break while loop and move to next potential
}
// Read in values
if(!strcmp(second.c_str(),"profil")||// Get profile
!strcmp(second.c_str(),"profile"))
{
if(!strcmp(third.c_str(),"SIE")||
!strcmp(third.c_str(),"5"))
{
Nsis+=1;
}
if(!strcmp(third.c_str(),"8"))
{
Npiemd+=1;
}
}
elseif(!strcmp(second.c_str(),"z_lens"))// Get redshift
{
z=atof(third.c_str());
}
}
elseif(!strncmp(first.c_str(),"limit",5))// same for the limit of the potential
{
numberLimits++;
}
elseif(!strncmp(first.c_str(),"cline",5))
{
runmode->cline=1;
}
elseif(!strncmp(first.c_str(),"potfile",7))
{
runmode->potfile=1;
std::getline(IN,line2);
std::istringstreamread2(line2);
read2>>second>>third>>fourth;// Read in 4 words
while(strncmp(second.c_str(),"end",3))// Read until we reach end
{
if(!strcmp(second.c_str(),"filein"))
{
runmode->potfilename=fourth;
//std::cout<< line2 << runmode->potfilename;
break;
}
// Read the next line
std::getline(IN,line2);
std::istringstreamread2(line2);
read2>>second>>third;
}
}
// read the next line
std::getline(IN,line1);
std::istringstreamread1(line1);
read1>>first;
}
IN.close();
//if(numberLimits!=numberPotentials) printf("Warning : Number of clumps different than number of limits in %s\n", infile.c_str()); // must be limits for each halo
printf("Error : file %s not found\n",arclets_filename.c_str());
exit(-1);
}
}
/** @brief This module function reads in if a parameter will be optimized by the MCMC or stay fixed.
*
* This module function reads in if a parameter will be optimized by the MCMC or stay fixed.
* If it will be optimized, it specifies its minimum and maximum allowed values. Unless declared otherwise by the user, input values are fixed and won't be optimized.
*
* read an infile :
| .
| .
|limit
| x_center x x x x <--- these values contains : block min max accuracy
| y_center x x x x if block=1 this is a free parameter, otherwise not
| . . . . . min and max define the extremal value of this parameter
| . . . . . accuracy is a criterium of convergence for the MCMC
| end
| .
| .
|limit
| x_center x x x x
| y_center x x x x
| . . . . .
| . . . . .
| end
| .
| .
|finish
and fills the variables with these values
* @param infile path to input file
* @param host_potentialoptimization array where limits will be stored
elseif(!strcmp(second.c_str(),"ellipticitymass")||!strcmp(second.c_str(),"ellipticity")||!strcmp(second.c_str(),"ellipticite"))// Read in for ellipticity
/* @brief Read in the position of sources that are just once lensed to see where their images lensed back into the image plane appear and what their shape looks like ("cleanlens", no MCMC)
* !!Not used. Will be reworked!!
* Read in the position of sources that are just once lensed to see where their images lensed back into the image plane appear and what their shape looks like ("cleanlens", no MCMC)
*
* @param clean lens file, number of clean lens images
* @return coordinates for each image, shape of each image, redshifts, number of sets, number of images per set
printf("DEBUG: Center.x B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.position.x.block,host_potentialoptimization.position.x.min,host_potentialoptimization.position.x.max,host_potentialoptimization.position.x.sigma);
printf("DEBUG: Center.y B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.position.y.block,host_potentialoptimization.position.y.min,host_potentialoptimization.position.y.max,host_potentialoptimization.position.y.sigma);
printf("DEBUG: weight.y B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.weight.block,host_potentialoptimization.weight.min,host_potentialoptimization.weight.max,host_potentialoptimization.weight.sigma);
printf("DEBUG: ellipticity_angle B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.ellipticity_angle.block,host_potentialoptimization.ellipticity_angle.min,host_potentialoptimization.ellipticity_angle.max,host_potentialoptimization.ellipticity_angle.sigma);
printf("DEBUG: ellipticity B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.ellipticity.block,host_potentialoptimization.ellipticity.min,host_potentialoptimization.ellipticity.max,host_potentialoptimization.ellipticity.sigma);
printf("DEBUG: ellipticity_potential B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.ellipticity_potential.block,host_potentialoptimization.ellipticity_potential.min,host_potentialoptimization.ellipticity_potential.max,host_potentialoptimization.ellipticity_potential.sigma);
printf("DEBUG: rcore B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.rcore.block,host_potentialoptimization.rcore.min,host_potentialoptimization.rcore.max,host_potentialoptimization.rcore.sigma);
printf("DEBUG: rcut B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.rcut.block,host_potentialoptimization.rcut.min,host_potentialoptimization.rcut.max,host_potentialoptimization.rcut.sigma);
printf("DEBUG: rscale B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.rscale.block,host_potentialoptimization.rscale.min,host_potentialoptimization.rscale.max,host_potentialoptimization.rscale.sigma);
printf("DEBUG: exponent B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.exponent.block,host_potentialoptimization.exponent.min,host_potentialoptimization.exponent.max,host_potentialoptimization.exponent.sigma);
printf("DEBUG: vdisp B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.vdisp.block,host_potentialoptimization.vdisp.min,host_potentialoptimization.vdisp.max,host_potentialoptimization.vdisp.sigma);
printf("DEBUG: alpha B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.alpha.block,host_potentialoptimization.alpha.min,host_potentialoptimization.alpha.max,host_potentialoptimization.alpha.sigma);
printf("DEBUG: z B = %d, min = %f, max = %f, sigma = %f \n",host_potentialoptimization.z.block,host_potentialoptimization.z.min,host_potentialoptimization.z.max,host_potentialoptimization.z.sigma);