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(),"fini",4)!=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
runmode->potfile=0;//weird seg fault due to this line, haven't figured out why
runmode->npotfile=0;
runmode->z_pot=0.8;
runmode->dpl=0;
runmode->dpl_gridcells=1000;
runmode->z_dpl=0.8;
runmode->inverse=0;
runmode->arclet=0;
runmode->debug=0;
runmode->nimagestot=0;
runmode->nsets=0;
runmode->gridcells=1000;
//std::cerr << sizeof(*runmode) << std::endl;
runmode->cline=0;
runmode->time=0;
runmode->inverse=0;
runmode->arclet=0;
runmode->ref_ra=0;
runmode->ref_dec=0;
intj=0;
std::stringimageFile_name;
intimageIndex=0;
intnumberPotentials=0,numberLimits=0;
/*************************** read nhalos, imfile_name, pixel_size, multipleimagesarea_size and runmode from configuration file *********************/
std::ifstreamIN(infile.c_str(),std::ios::in);
if(IN)
{
std::getline(IN,line1);
std::istringstreamread1(line1);// create a stream for the line
read1>>first;// Read the first word
//std::cout<<first;
while(strncmp(first.c_str(),"fini",4)!=0)// Continue until we reach finish
{
if(strncmp(first.c_str(),"runmode",7)==0){// Read in runmode information
read_runmode(IN,runmode);
}
elseif(!strncmp(first.c_str(),"potent",6))// each time we find a "potential" string in the configuration file, we add an halo
{
read_runmode_potential(IN,numberPotentials);
//std::cerr<<numberPotentials << std::endl;
}
elseif(!strncmp(first.c_str(),"image",5))// same for the limit of the potential
{
read_runmode_image(IN,runmode);
}
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))
{
read_runmode_potfile(IN,runmode);
}
// read the next line
std::getline(IN,line1);
std::istringstreamread1(line1);
read1>>first;
//std::cout<<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
runmode->nhalos=numberPotentials;
}
else
{
fprintf(stderr,"ERROR: file %s not found\n",infile.c_str());
exit(-1);
}
//
//getting nimage value (number of images), nset value (number of sources) and npotfile
//if image or multi mode is activated get nimage and nset
read_runmode_countimages(runmode);
//if source mode is activated, get nset
read_runmode_countsources(runmode);
//if potfile mode, count number of potential in potfile
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
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);