Skip to content

Commit

Permalink
Fix improper .res header in multiPopMcmc when running parallax
Browse files Browse the repository at this point in the history
- Parallax runs still use "modulus" in .res file header
- Modifies the file IO backend to output the appropriate header based on whether parallax or distMod is in use
- Affects only multiple population MCMC
  • Loading branch information
argiopetech committed Feb 26, 2019
1 parent 21e1569 commit 1f30b0e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
8 changes: 5 additions & 3 deletions base9/IO/MultiPopMcmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void MultiPopMcmc_FileBackingStore::save(MultiPopMcmcRecord data)

if (data.iter.val == 1)
{
header(clust0.priorVar);
header(clust0.priorVar, data.modIsParallax);
}

for (int p = 0; p < NPARAMS; p++)
Expand All @@ -39,12 +39,14 @@ void MultiPopMcmc_FileBackingStore::save(MultiPopMcmcRecord data)
}


void MultiPopMcmc_FileBackingStore::header(array<double, NPARAMS> const &priors)
void MultiPopMcmc_FileBackingStore::header(array<double, NPARAMS> const &priors, bool modIsParallax)
{
auto distanceName = modIsParallax ? " parallax" : " modulus";

const array<string, NPARAMS> paramNames = { " logAge",
" YA",
" FeH",
" modulus",
distanceName,
" absorption",
" carbonicity",
" YB",
Expand Down
3 changes: 2 additions & 1 deletion base9/IO/MultiPopMcmc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class MultiPopMcmc_FileBackingStore : public FileBackingStore<MultiPopMcmcRecord
void save(MultiPopMcmcRecord) override;

protected:
void header(std::array<double, NPARAMS> const&) override;
void header(std::array<double, NPARAMS> const &params) override { header(params, false); }
void header(std::array<double, NPARAMS> const&, bool);
};


Expand Down
2 changes: 2 additions & 0 deletions base9/IO/Records.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct MultiPopMcmcRecord
const Cluster clust1;

const double logPost;

const bool modIsParallax;
};

typedef BackingStore<MultiPopMcmcRecord> MultiPopBackingStore;
Expand Down
4 changes: 2 additions & 2 deletions base9/IO/SinglePopMcmc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class SinglePopMcmc_FileBackingStore : public FileBackingStore<SinglePopMcmcReco
void save(SinglePopMcmcRecord) override;

protected:
void header(std::array<double, NPARAMS> const &params) { header(params, false); }
void header(std::array<double, NPARAMS> const&, bool modIsParallax);
void header(std::array<double, NPARAMS> const &params) override { header(params, false); }
void header(std::array<double, NPARAMS> const&, bool);
};


Expand Down
7 changes: 5 additions & 2 deletions multiPopMcmc/Chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ class Chain : public McmcApplication
MultiPopBackingStore &mcmcStore;
StarParamsBackingStore &paramsStore;

bool modIsParallax;

double logPostCurr = -std::numeric_limits<double>::infinity();

std::vector<double> starData;

public:
Chain(uint32_t seed, double fsLike, std::array<double, NPARAMS> priorVar, T clust, MultiPopBackingStore &mcmcStore, StarParamsBackingStore &paramsStore)
Chain(uint32_t seed, double fsLike, std::array<double, NPARAMS> priorVar, T clust, MultiPopBackingStore &mcmcStore, StarParamsBackingStore &paramsStore, bool modIsParallax)
: McmcApplication(seed), fsLike(fsLike), priorVar(priorVar), clust(clust), mcmcStore(mcmcStore), paramsStore(paramsStore)
, modIsParallax(modIsParallax)
{}

void reset()
Expand Down Expand Up @@ -111,7 +114,7 @@ class Chain : public McmcApplication
{
const auto iter = mcmcStore.nextIteration();

mcmcStore.save({iter, stage, clust.lambda, clust.clust[0], clust.clust[1], logPostCurr});
mcmcStore.save({iter, stage, clust.lambda, clust.clust[0], clust.clust[1], logPostCurr, modIsParallax});

if (starData.size() >= 2)
{
Expand Down
2 changes: 1 addition & 1 deletion multiPopMcmc/MpiMcmcApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ int MpiMcmcApplication::run()

fieldStarLikelihood->save({fsLike});

Chain<DualPopCluster> chain(static_cast<uint32_t>(std::uniform_int_distribution<>()(gen)), fsLike, ctrl.priorVar, clust, *mcmcStore, *paramsStore);
Chain<DualPopCluster> chain(static_cast<uint32_t>(std::uniform_int_distribution<>()(gen)), fsLike, ctrl.priorVar, clust, *mcmcStore, *paramsStore, settings.modIsParallax);

allocateSSEMem();

Expand Down

0 comments on commit 1f30b0e

Please sign in to comment.