diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index f50c337..b63b2a5 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -35,6 +35,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,6 +89,11 @@
+
+
+
+
+
@@ -83,7 +107,7 @@
1699837271026
-
+
diff --git a/src/lib.rs b/src/lib.rs
index 1351eaf..672b737 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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,
+ nt: u16,
+ nx: u16,
+ dt: f32,
+ data: Vec,
+}
+
+fn read_binary_file(file_name: &str) -> Vec {
+ 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)]
@@ -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)
+ }
}