Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/config_file.hh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ public:
}

items_[in_section + '/' + name] = value;

size_t lastindex = filename.find_last_of('.');
std::string config_basename = filename.substr(0, lastindex);
items_["meta/config_basename"] = config_basename;
}
}

Expand Down Expand Up @@ -288,6 +292,12 @@ public:
return get_value_safe("", key, default_value);
}

std::string get_path_relative_to_config(std::string const &filename) const {
std::string empty_string;
const std::string basename = get_value_safe("meta", "config_basename", empty_string);
return basename + "_" + filename;
}

//! dumps all key-value pairs to a std::ostream
void dump(std::ostream &out) {
std::map<std::string, std::string>::const_iterator i = items_.begin();
Expand Down
2 changes: 1 addition & 1 deletion src/convolution_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class kernel_k : public kernel
pnorm_ = ptf->cosmo_params_["pnorm"];
kfac_ = 2.0 * M_PI / boxlength_;
kmax_ = kfac_ / 2;
tfk_ = new TransferFunction_k(type_, ptf_, nspec_, pnorm_);
tfk_ = new TransferFunction_k(type_, ptf_, nspec_, pnorm_, cf);

cparam_.nx = 1;
cparam_.ny = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/transfer_function.hh
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ public:
double pnorm_, sqrtpnorm_;
static tf_type type_;

TransferFunction_k(tf_type type, transfer_function *tf, real_t nspec, real_t pnorm)
TransferFunction_k(tf_type type, transfer_function *tf, real_t nspec, real_t pnorm, config_file &cf)
: pnorm_(pnorm)
{
ptf_ = tf;
nspec_ = nspec;
sqrtpnorm_ = sqrt(pnorm_);
type_ = type;

std::string fname("input_powerspec.txt");
std::string fname(cf.get_path_relative_to_config("input_powerspec.txt"));
if (type == delta_cdm || type == delta_matter)
{
std::ofstream ofs(fname.c_str());
Expand Down