Commit 650d2d24 authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

rm fits writing from MCMC (was a bad idea)

parent 671f5c99
......@@ -428,49 +428,3 @@ void MCMC_sampler::set_par(Parser parser)
cout << _min_par << _max_par << _starting_point << _par_err <<endl;
*/
}
void
MCMC_sampler::write_samples_fits(const char* fn) {
const std::string fileName(fn);
cout << "writing FITS file=" << fileName << endl;
if (file_present(fileName)) {
std::cout << "the file " + fileName + " already exists: removing it"<<endl;
remove_file(fileName);
}
fitshandle fout(fileName,fitshandle::CREATE, READWRITE);
std::vector<fitscolumn> cols;
//define columns
//first is chi2
cols.push_back(fitscolumn("chi2", "no",1,TDOUBLE));
for (size_t i=0;i< _par_name.size();i++){
cols.push_back(fitscolumn(_par_name[i], "?",1,TDOUBLE));
}
fout.insert_bintab (cols);
//write chi2
arr<double> tab(_lkh_values.size());
for (size_t j=0;j<tab.size();j++) tab[j]= _lkh_values[j];
fout.write_column(1,tab);
//convert to arr and write starting at index 2
//need to transpoise into columns first
const int N=_mychain.size();
cout <<"chain length="<< N << endl;
vector< arr<double> > out(_dim);
for (size_t ivar=0;ivar<_dim;ivar++){
out[ivar].alloc(N);
for (size_t k=0;k<N;k++) out[ivar][k]=_mychain[k][ivar];
}
for (size_t i=0;i< _par_name.size();i++){
cout << "writing : parname=" << _par_name[i] << " size=" << out[i].size() << endl;
fout.write_column(i+2,out[i]);
}
fout.close();
}
......@@ -69,8 +69,6 @@ public:
void set_par(Parser parser); // set parameters value using Parser
void write_if_useful(std::vector<double>& vec,char* str);
void write_vecHep(std::vector<HepVector >& vec,char* str);
void write_samples_fits(const char* filename);
//accessors
......
......@@ -37,9 +37,9 @@ zeroot=$CAMELROOT/work/${parbase%".par"}_MC
if [ -d "$zeroot" ] ; then
echo "directory $zeroot exists: still want to run? (o/n)"
echo "directory $zeroot exists: still want to run? (y/n)"
read answer
if [ $answer != 'o' ] ; then
if [ $answer != 'y' ] ; then
echo "exiting"
exit 1
fi
......@@ -63,10 +63,8 @@ fi
cat > mc_setup <<EOF
do_mPk=true
class z_pk 0,0.57
derived H0
derived sigma8
derived sigma8(0.57)
derived rs_drag
dim=$ndim
algo=ada
......@@ -96,9 +94,8 @@ echo "seed=\$RANDOM" >> $parbase
cp $parbase $PWD/camel.par
./$localexec $parbase $PWD/samples\${SGE_TASK_ID}.txt samples.fits
./$localexec $parbase $PWD/samples\${SGE_TASK_ID}.txt
cp samples.fits $PWD/samples\${SGE_TASK_ID}.fits
cp ar_vs_length.txt $PWD/ar_vs_length\${SGE_TASK_ID}.txt
cp scale_vs_length.txt $PWD/scale_vs_length\${SGE_TASK_ID}.txt
cp corr.txt $PWD/corr\${SGE_TASK_ID}.txt
......
......@@ -39,16 +39,15 @@ zeroot=$CAMELROOT/work/${parbase%".par"}_MC
if [ -d "$zeroot" ] ; then
echo "directory $zeroot exists: still want to run? (o/n)"
echo "directory $zeroot exists: still want to run? (y/n)"
read answer
if [ $answer != 'o' ] ; then
if [ $answer != 'y' ] ; then
echo "exiting"
exit 1
fi
fi
ndim=`awk '$1=="par"{n++}; END {print n}' $parFile`
npar=`awk '$1=="par"{n++}; END {print n}' $parFile`
mkdir $zeroot
cd $zeroot
......@@ -60,17 +59,17 @@ echo "$cov"
echo "no covariance matrix found ndim=$ndim"
exit
fi
#here we could test the matrix size
cat > mc_setup <<EOF
dim=$ndim
length=$NSAMPLES
bunchSize=1000
algo=ada
length=$NSAMPLES
proposal_cov=$cov
ts=10000
t0=1000
scale=0.001
do_move=false
EOF
cat mc_setup
......@@ -88,9 +87,8 @@ echo "seed=\$RANDOM" >> $parbase
cp $parbase $PWD/camel.par
./$localexec $parbase $PWD/samples\${SGE_TASK_ID}.txt samples.fits
./$localexec $parbase $PWD/samples\${SGE_TASK_ID}.txt
cp samples.fits $PWD/samples\${SGE_TASK_ID}.fits
cp ar_vs_length.txt $PWD/ar_vs_length\${SGE_TASK_ID}.txt
cp scale_vs_length.txt $PWD/scale_vs_length\${SGE_TASK_ID}.txt
cp corr.txt $PWD/corr\${SGE_TASK_ID}.txt
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment