Skip to content

Commit

Permalink
Update simulator for more granular output
Browse files Browse the repository at this point in the history
  • Loading branch information
mhovd committed Nov 30, 2023
1 parent 05fbe4a commit 27647f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ where
.has_headers(false)
.from_reader(theta_file);
let theta: Array2<f64> = reader.deserialize_array2_dynamic().unwrap();
let scenarios = datafile::parse(&settings.paths.data).unwrap();

// Expand data
let idelta = settings.config.idelta.unwrap_or(0.0);
let tad = settings.config.tad.unwrap_or(0.0);
let mut scenarios = datafile::parse(&settings.paths.data).unwrap();
for scenario in &mut scenarios {
scenario.add_event_interval(idelta, tad);
}

let ypred = sim_obs(&engine, &scenarios, &theta, false);

Expand Down
11 changes: 11 additions & 0 deletions src/routines/settings/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use toml;
#[derive(Deserialize, Clone, Debug)]
pub struct Data {
pub paths: Paths,
pub config: Config,
}

#[derive(Deserialize, Clone, Debug)]
Expand All @@ -14,6 +15,12 @@ pub struct Paths {
pub theta: String,
}

#[derive(Deserialize, Clone, Debug)]
pub struct Config {
pub idelta: Option<f64>,
pub tad: Option<f64>,
}

pub fn read(filename: String) -> Data {
let contents = match fs::read_to_string(&filename) {
Ok(c) => c,
Expand All @@ -36,5 +43,9 @@ pub fn read(filename: String) -> Data {
data: parse.paths.data,
theta: parse.paths.theta,
},
config: Config {
idelta: parse.config.idelta,
tad: parse.config.tad,
},
}
}

0 comments on commit 27647f6

Please sign in to comment.