Skip to content

Commit

Permalink
saving work
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgraham4401 committed Nov 13, 2023
1 parent e4e6341 commit 05e4369
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
28 changes: 26 additions & 2 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 30 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
use std::io::Read;

#[derive()]
#[derive(Debug)]
pub struct Gather {
id: u16,
number_time_samples: u16,
number_traces: u16,
time_sampling: f32,
data: Vec<f32>,
nt: u16,
nx: u16,
dt: f32,
data: Vec<u8>,
}

fn read_binary_file(file_name: &str) -> Vec<u8> {
let mut file = std::fs::File::open(file_name).unwrap();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).unwrap();
buffer
}

fn load_data_into_gather(path: &str, time_sampling: f32, samples_per_trace: u16, number_of_traces: u16 ) -> Gather {
Gather {
id: 1,
data: read_binary_file(path),
dt: time_sampling,
nt: samples_per_trace,
nx: number_of_traces,
}
}

#[cfg(test)]
Expand All @@ -16,4 +34,11 @@ mod tests {
fn it_works() {
assert_eq!(2, 2);
}

#[test]
fn reads_binary_file() {
let file_path: &str = "./resources/shot6220.bin";
let gather = load_data_into_gather(file_path, 0.004, 3101, 1000);
println!("Gather: {:?}", gather)
}
}

0 comments on commit 05e4369

Please sign in to comment.